diff options
author | aktersnurra <grydholm@kth.se> | 2021-04-19 21:43:23 +0200 |
---|---|---|
committer | aktersnurra <grydholm@kth.se> | 2021-04-19 21:43:23 +0200 |
commit | 23b895222a16925d39d04d45dedbedec9db0c752 (patch) | |
tree | eb5759eed884c1ddcb32f1b702e55dc4521bf60e /.config/nvim/lua/_utils | |
parent | 174cd547dc32bb6d50ab5da329ad1bc4d516c20a (diff) |
Updates to nvim
Diffstat (limited to '.config/nvim/lua/_utils')
-rw-r--r-- | .config/nvim/lua/_utils/init.lua | 110 |
1 files changed, 48 insertions, 62 deletions
diff --git a/.config/nvim/lua/_utils/init.lua b/.config/nvim/lua/_utils/init.lua index 43bbf2e..4d5c890 100644 --- a/.config/nvim/lua/_utils/init.lua +++ b/.config/nvim/lua/_utils/init.lua @@ -1,6 +1,6 @@ -local _utils = {} +local nv_utils = {} -function _utils.define_augroups(definitions) -- {{{1 +function nv_utils.define_augroups(definitions) -- {{{1 -- Create autocommand groups based on the passed definitions -- -- The key will be the name of the group, and each definition @@ -21,183 +21,169 @@ function _utils.define_augroups(definitions) -- {{{1 vim.cmd('augroup END') end end -_utils.define_augroups({ - _general_settings = { - { - 'TextYankPost', '*', - 'lua require(\'vim.highlight\').on_yank({higroup = \'QuickScopePrimary\', timeout = 200})' - }, - {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, - {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, - {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, - -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'}, - -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'}, - }, - numbertoggle = { - {'BufEnter,FocusGained,InsertLeave', '*', 'set relativenumber'}, - {'BufLeave,FocusLost,InsertEnter', '*', 'set norelativenumber'}, - }, -}) --- Add this to lightbulb, java makes this annoying tho --- autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb() -- lsp -function _utils.add_to_workspace_folder() +function nv_utils.add_to_workspace_folder() vim.lsp.buf.add_workspace_folder() - end -function _utils.clear_references() +function nv_utils.clear_references() vim.lsp.buf.clear_references() end -function _utils.code_action() +function nv_utils.code_action() vim.lsp.buf.code_action() end -function _utils.declaration() +function nv_utils.declaration() vim.lsp.buf.declaration() vim.lsp.buf.clear_references() end -function _utils.definition() +function nv_utils.definition() vim.lsp.buf.definition() vim.lsp.buf.clear_references() end -function _utils.document_highlight() +function nv_utils.document_highlight() vim.lsp.buf.document_highlight() end -function _utils.document_symbol() +function nv_utils.document_symbol() vim.lsp.buf.document_symbol() end -function _utils.formatting() +function nv_utils.formatting() vim.lsp.buf.formatting() end -function _utils.formatting_sync() +function nv_utils.formatting_sync() vim.lsp.buf.formatting_sync() end -function _utils.hover() +function nv_utils.hover() vim.lsp.buf.hover() end -function _utils.implementation() +function nv_utils.implementation() vim.lsp.buf.implementation() end -function _utils.incoming_calls() +function nv_utils.incoming_calls() vim.lsp.buf.incoming_calls() end -function _utils.list_workspace_folders() +function nv_utils.list_workspace_folders() vim.lsp.buf.list_workspace_folders() end -function _utils.outgoing_calls() +function nv_utils.outgoing_calls() vim.lsp.buf.outgoing_calls() end -function _utils.range_code_action() +function nv_utils.range_code_action() vim.lsp.buf.range_code_action() end -function _utils.range_formatting() +function nv_utils.range_formatting() vim.lsp.buf.range_formatting() end -function _utils.references() +function nv_utils.references() vim.lsp.buf.references() vim.lsp.buf.clear_references() end -function _utils.remove_workspace_folder() +function nv_utils.remove_workspace_folder() vim.lsp.buf.remove_workspace_folder() end -function _utils.rename() +function nv_utils.rename() vim.lsp.buf.rename() end -function _utils.signature_help() +function nv_utils.signature_help() vim.lsp.buf.signature_help() end -function _utils.type_definition() +function nv_utils.type_definition() vim.lsp.buf.type_definition() end -function _utils.workspace_symbol() +function nv_utils.workspace_symbol() vim.lsp.buf.workspace_symbol() end -- diagnostic -function _utils.get_all() +function nv_utils.get_all() vim.lsp.diagnostic.get_all() end -function _utils.get_next() +function nv_utils.get_next() vim.lsp.diagnostic.get_next() end -function _utils.get_prev() +function nv_utils.get_prev() vim.lsp.diagnostic.get_prev() end -function _utils.goto_next() +function nv_utils.goto_next() vim.lsp.diagnostic.goto_next() end -function _utils.goto_prev() +function nv_utils.goto_prev() vim.lsp.diagnostic.goto_prev() end -function _utils.show_line_diagnostics() +function nv_utils.show_line_diagnostics() vim.lsp.diagnostic.show_line_diagnostics() end -- git signs -function _utils.next_hunk() +function nv_utils.next_hunk() require('gitsigns').next_hunk() end -function _utils.prev_hunk() +function nv_utils.prev_hunk() require('gitsigns').prev_hunk() end -function _utils.stage_hunk() +function nv_utils.stage_hunk() require('gitsigns').stage_hunk() end -function _utils.undo_stage_hunk() +function nv_utils.undo_stage_hunk() require('gitsigns').undo_stage_hunk() end -function _utils.reset_hunk() +function nv_utils.reset_hunk() require('gitsigns').reset_hunk() end -function _utils.reset_buffer() +function nv_utils.reset_buffer() require('gitsigns').reset_buffer() end -function _utils.preview_hunk() +function nv_utils.preview_hunk() require('gitsigns').preview_hunk() end -function _utils.blame_line() +function nv_utils.blame_line() require('gitsigns').blame_line() end -- misc +function nv_utils.file_exists(name) + local f = io.open(name, "r") + if f ~= nil then + io.close(f) + return true + else + return false + end +end --- autoformat --- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) - -return _utils +return nv_utils |