diff options
author | christianchiarulli <[email protected]> | 2021-06-29 22:45:48 -0400 |
---|---|---|
committer | christianchiarulli <[email protected]> | 2021-06-29 22:45:48 -0400 |
commit | 592e348689a3fba6467249be1163f8f91572e15f (patch) | |
tree | 270ba51407a091c1a98453b9fb6c1c6d688a4a09 /lua | |
parent | 73276a79c023ff36f5ced5d852bfff8356d261c7 (diff) |
updates
Diffstat (limited to 'lua')
-rw-r--r-- | lua/keymappings.lua | 2 | ||||
-rw-r--r-- | lua/lv-autocommands/init.lua | 125 | ||||
-rw-r--r-- | lua/lv-utils/init.lua | 163 | ||||
-rw-r--r-- | lua/lv-which-key/init.lua | 81 |
4 files changed, 141 insertions, 230 deletions
diff --git a/lua/keymappings.lua b/lua/keymappings.lua index dcce2562..0e8284d3 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,5 +1,3 @@ -vim.api.nvim_set_keymap('n', '-', ':RnvimrToggle<CR>', {noremap = true, silent = true}) - -- better window movement vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', {silent = true}) vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', {silent = true}) diff --git a/lua/lv-autocommands/init.lua b/lua/lv-autocommands/init.lua index 28dda448..0026690b 100644 --- a/lua/lv-autocommands/init.lua +++ b/lua/lv-autocommands/init.lua @@ -1,54 +1,103 @@ +-- TODO when autocommands are better in lua, scope these to plugins and langs local utils = require('lv-utils') -local auto_formatters = { } +local auto_formatters = {} -local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} -if O.lang.python.autoformat then table.insert(auto_formatters, python_autoformat) end +if O.lang.python.active then + local python_autoformat = { + 'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)' + } + if O.lang.python.autoformat then + table.insert(auto_formatters, python_autoformat) + end +end -local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} -local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} -local typescript_autoformat = {'BufWritePre', '*.ts', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} -local typescriptreact_autoformat = {'BufWritePre', '*.tsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} -if O.lang.tsserver.autoformat then - table.insert(auto_formatters, javascript_autoformat) - table.insert(auto_formatters, javascriptreact_autoformat) - table.insert(auto_formatters, typescript_autoformat) - table.insert(auto_formatters, typescriptreact_autoformat) +if O.lang.tsserver.active then + local javascript_autoformat = { + 'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)' + } + local javascriptreact_autoformat = { + 'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)' + } + local typescript_autoformat = { + 'BufWritePre', '*.ts', 'lua vim.lsp.buf.formatting_sync(nil, 1000)' + } + local typescriptreact_autoformat = { + 'BufWritePre', '*.tsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)' + } + if O.lang.tsserver.autoformat then + table.insert(auto_formatters, javascript_autoformat) + table.insert(auto_formatters, javascriptreact_autoformat) + table.insert(auto_formatters, typescript_autoformat) + table.insert(auto_formatters, typescriptreact_autoformat) + end end -local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} -if O.lang.lua.autoformat then table.insert(auto_formatters, lua_format) end +if O.lang.lua.active then + local lua_format = { + 'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)' + } + if O.lang.lua.autoformat then table.insert(auto_formatters, lua_format) end +end -local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} -if O.lang.json.autoformat then table.insert(auto_formatters, json_format) end +if O.lang.json.active then + local json_format = { + 'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)' + } + if O.lang.json.autoformat then table.insert(auto_formatters, json_format) end +end -local ruby_format = {'BufWritePre', '*.rb', 'lua vim.lsp.buf.formatting_sync(nil,1000)'} -if O.lang.ruby.autoformat then table.insert(auto_formatters, ruby_format) end +if O.lang.ruby.active then + local ruby_format = { + 'BufWritePre', '*.rb', 'lua vim.lsp.buf.formatting_sync(nil,1000)' + } + if O.lang.ruby.autoformat then table.insert(auto_formatters, ruby_format) end +end -local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'} -if O.lang.go.autoformat then table.insert(auto_formatters, go_format) end +if O.lang.go.active then + local go_format = { + 'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)' + } + if O.lang.go.autoformat then table.insert(auto_formatters, go_format) end +end -local rust_format = {'BufWritePre', '*.rs', 'lua vim.lsp.buf.formatting_sync(nil,1000)'} -if O.lang.rust.autoformat then table.insert(auto_formatters, rust_format) end +if O.lang.rust.active then + local rust_format = { + 'BufWritePre', '*.rs', 'lua vim.lsp.buf.formatting_sync(nil,1000)' + } + if O.lang.rust.autoformat then table.insert(auto_formatters, rust_format) end +end utils.define_augroups({ _general_settings = { - {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', 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'}, - {'VimLeavePre', '*', 'set title set titleold='}, + { + 'TextYankPost', '*', + 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', 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' + }, {'VimLeavePre', '*', 'set title set titleold='}, {'FileType', 'qf', 'set nobuflisted'}, - {'BufWinEnter', 'lv-config.lua', 'PackerCompile'}, - {'BufWinLeave', 'lv-config.lua', 'PackerCompile'}, - {'BufWritePost', 'lv-config.lua', 'PackerCompile'} + -- {'BufWinEnter', 'lv-config.lua', 'PackerCompile'}, + -- {'BufWinLeave', 'lv-config.lua', 'PackerCompile'}, + -- {'BufWritePost', 'lv-config.lua', 'PackerCompile'} -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'}, -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'}, }, _java = { -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, - {'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'} + { + 'FileType', 'java', + 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>' + } }, _go = { @@ -56,16 +105,22 @@ utils.define_augroups({ {'FileType', 'go', 'setlocal tabstop=4'}, {'FileType', 'go', 'setlocal shiftwidth=4'}, {'FileType', 'go', 'setlocal softtabstop=4'}, - {'FileType', 'go', 'setlocal noexpandtab'}, + {'FileType', 'go', 'setlocal noexpandtab'} }, _dashboard = { -- seems to be nobuflisted that makes my stuff disapear will do more testing { 'FileType', 'dashboard', 'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= ' - }, {'FileType', 'dashboard', 'set showtabline=0 | autocmd BufLeave <buffer> set showtabline=2'} + }, { + 'FileType', 'dashboard', + 'set showtabline=0 | autocmd BufLeave <buffer> set showtabline=2' + } + }, + _markdown = { + {'FileType', 'markdown', 'setlocal wrap'}, + {'FileType', 'markdown', 'setlocal spell'} }, - _markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}}, -- _solidity = { -- {'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'}, -- {'BufNewFile', '*.sol', 'setlocal filetype=solidity'} @@ -77,7 +132,7 @@ utils.define_augroups({ _buffer_bindings = { {'FileType', 'dashboard', 'nnoremap <silent> <buffer> q :q<CR>'}, {'FileType', 'lspinfo', 'nnoremap <silent> <buffer> q :q<CR>'}, - {'FileType', 'floaterm', 'nnoremap <silent> <buffer> q :q<CR>'}, + {'FileType', 'floaterm', 'nnoremap <silent> <buffer> q :q<CR>'} }, _auto_formatters = auto_formatters }) diff --git a/lua/lv-utils/init.lua b/lua/lv-utils/init.lua index 0fb30971..016bba62 100644 --- a/lua/lv-utils/init.lua +++ b/lua/lv-utils/init.lua @@ -22,169 +22,6 @@ function lv_utils.define_augroups(definitions) -- {{{1 end end --- lsp - -function lv_utils.add_to_workspace_folder() - vim.lsp.buf.add_workspace_folder() -end - -function lv_utils.clear_references() - vim.lsp.buf.clear_references() -end - -function lv_utils.code_action() - vim.lsp.buf.code_action() -end - -function lv_utils.declaration() - vim.lsp.buf.declaration() - vim.lsp.buf.clear_references() -end - -function lv_utils.definition() - vim.lsp.buf.definition() - vim.lsp.buf.clear_references() -end - -function lv_utils.document_highlight() - vim.lsp.buf.document_highlight() -end - -function lv_utils.document_symbol() - vim.lsp.buf.document_symbol() -end - -function lv_utils.formatting() - vim.lsp.buf.formatting() -end - -function lv_utils.formatting_sync() - vim.lsp.buf.formatting_sync() -end - -function lv_utils.hover() - vim.lsp.buf.hover() -end - -function lv_utils.implementation() - vim.lsp.buf.implementation() -end - -function lv_utils.incoming_calls() - vim.lsp.buf.incoming_calls() -end - -function lv_utils.list_workspace_folders() - vim.lsp.buf.list_workspace_folders() -end - -function lv_utils.outgoing_calls() - vim.lsp.buf.outgoing_calls() -end - -function lv_utils.range_code_action() - vim.lsp.buf.range_code_action() -end - -function lv_utils.range_formatting() - vim.lsp.buf.range_formatting() -end - -function lv_utils.references() - vim.lsp.buf.references() - vim.lsp.buf.clear_references() -end - -function lv_utils.remove_workspace_folder() - vim.lsp.buf.remove_workspace_folder() -end - -function lv_utils.rename() - vim.lsp.buf.rename() -end - -function lv_utils.signature_help() - vim.lsp.buf.signature_help() -end - -function lv_utils.type_definition() - vim.lsp.buf.type_definition() -end - -function lv_utils.workspace_symbol() - vim.lsp.buf.workspace_symbol() -end - --- diagnostic - -function lv_utils.get_all() - vim.lsp.diagnostic.get_all() -end - -function lv_utils.get_next() - vim.lsp.diagnostic.get_next() -end - -function lv_utils.get_prev() - vim.lsp.diagnostic.get_prev() -end - -function lv_utils.goto_next() - vim.lsp.diagnostic.goto_next() -end - -function lv_utils.goto_prev() - vim.lsp.diagnostic.goto_prev() -end - -function lv_utils.show_line_diagnostics() - vim.lsp.diagnostic.show_line_diagnostics() -end - --- git signs - -function lv_utils.next_hunk() - require('gitsigns').next_hunk() -end - -function lv_utils.prev_hunk() - require('gitsigns').prev_hunk() -end - -function lv_utils.stage_hunk() - require('gitsigns').stage_hunk() -end - -function lv_utils.undo_stage_hunk() - require('gitsigns').undo_stage_hunk() -end - -function lv_utils.reset_hunk() - require('gitsigns').reset_hunk() -end - -function lv_utils.reset_buffer() - require('gitsigns').reset_buffer() -end - -function lv_utils.preview_hunk() - require('gitsigns').preview_hunk() -end - -function lv_utils.blame_line() - require('gitsigns').blame_line() -end - --- misc -function lv_utils.file_exists(name) - local f = io.open(name, "r") - if f ~= nil then - io.close(f) - return true - else - return false - end -end return lv_utils diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index f3e05cad..3ca4a1cd 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -92,7 +92,7 @@ local mappings = { ["f"] = "Find File", ["h"] = "No Highlight", b = { - name = "+Buffers", + name = "Buffers", j = {"<cmd>BufferPick<cr>", "jump to buffer"}, w = {"<cmd>BufferWipeout<cr>", "wipeout buffer"}, e = { @@ -113,22 +113,31 @@ local mappings = { } }, - d = { - name = "Diagnostics", - t = {"<cmd>TroubleToggle<cr>", "trouble"}, - w = {"<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", "workspace"}, - d = {"<cmd>TroubleToggle lsp_document_diagnostics<cr>", "document"}, - q = {"<cmd>TroubleToggle quickfix<cr>", "quickfix"}, - l = {"<cmd>TroubleToggle loclist<cr>", "loclist"}, - r = {"<cmd>TroubleToggle lsp_references<cr>", "references"} - }, +-- diagnostics vanilla nvim +-- -- diagnostic +-- function lv_utils.get_all() +-- vim.lsp.diagnostic.get_all() +-- end +-- function lv_utils.get_next() +-- vim.lsp.diagnostic.get_next() +-- end +-- function lv_utils.get_prev() +-- vim.lsp.diagnostic.get_prev() +-- end +-- function lv_utils.goto_next() +-- vim.lsp.diagnostic.goto_next() +-- end +-- function lv_utils.goto_prev() +-- vim.lsp.diagnostic.goto_prev() +-- end +-- function lv_utils.show_line_diagnostics() +-- vim.lsp.diagnostic.show_line_diagnostics() +-- end -- " Available Debug Adapters: -- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ - -- " -- " Adapter configuration and installation instructions: -- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation - -- " -- " Debug Adapter protocol: -- " https://microsoft.github.io/debug-adapter-protocol/ -- " Debugging @@ -151,15 +160,15 @@ local mappings = { -- }, g = { name = "Git", - j = {"<cmd>lua require 'lv-utils'.next_hunk()<cr>", "Next Hunk"}, - k = {"<cmd>lua require 'lv-utils'.prev_hunk()<cr>", "Prev Hunk"}, - l = {"<cmd>lua require 'lv-utils'.blame_line()<cr>", "Blame"}, - p = {"<cmd>lua require 'lv-utils'.preview_hunk()<cr>", "Preview Hunk"}, - r = {"<cmd>lua require 'lv-utils'.reset_hunk()<cr>", "Reset Hunk"}, - R = {"<cmd>lua require 'lv-utils'.reset_buffer()<cr>", "Reset Buffer"}, - s = {"<cmd>lua require 'lv-utils'.stage_hunk()<cr>", "Stage Hunk"}, + j = {"<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk"}, + k = {"<cmd>lua require 'gitsigns'.prev_hunk()<cr>", "Prev Hunk"}, + l = {"<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame"}, + p = {"<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk"}, + r = {"<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk"}, + R = {"<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer"}, + s = {"<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk"}, u = { - "<cmd>lua require 'lv-utils'.undo_stage_hunk()<cr>", + "<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>", "Undo Stage Hunk" }, o = {"<cmd>Telescope git_status<cr>", "Open changed file"}, @@ -182,7 +191,7 @@ local mappings = { "<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics" }, - f = {"<cmd>lua require 'lv-utils'.formatting()<cr>", "Format"}, + f = {"<cmd>lua vim.lsp.buf.formatting()<cr>", "Format"}, h = {"<cmd>Lspsaga hover_doc<cr>", "Hover Doc"}, i = {"<cmd>LspInfo<cr>", "Info"}, l = {"<cmd>Lspsaga lsp_finder<cr>", "LSP Finder"}, @@ -209,17 +218,17 @@ local mappings = { name = "Search", b = {"<cmd>Telescope git_branches<cr>", "Checkout branch"}, c = {"<cmd>Telescope colorscheme<cr>", "Colorscheme"}, - d = { - "<cmd>Telescope lsp_document_diagnostics<cr>", - "Document Diagnostics" - }, - D = { - "<cmd>Telescope lsp_workspace_diagnostics<cr>", - "Workspace Diagnostics" - }, + -- d = { + -- "<cmd>Telescope lsp_document_diagnostics<cr>", + -- "Document Diagnostics" + -- }, + -- D = { + -- "<cmd>Telescope lsp_workspace_diagnostics<cr>", + -- "Workspace Diagnostics" + -- }, f = {"<cmd>Telescope find_files<cr>", "Find File"}, h = {"<cmd>Telescope help_tags<cr>", "Find Help"}, - m = {"<cmd>Telescope marks<cr>", "Marks"}, + -- m = {"<cmd>Telescope marks<cr>", "Marks"}, M = {"<cmd>Telescope man_pages<cr>", "Man Pages"}, r = {"<cmd>Telescope oldfiles<cr>", "Open Recent File"}, R = {"<cmd>Telescope registers<cr>", "Registers"}, @@ -232,6 +241,18 @@ local mappings = { } } +if O.plugin.trouble.active then + mappings['d'] = { + name = "Diagnostics", + t = {"<cmd>TroubleToggle<cr>", "trouble"}, + w = {"<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", "workspace"}, + d = {"<cmd>TroubleToggle lsp_document_diagnostics<cr>", "document"}, + q = {"<cmd>TroubleToggle quickfix<cr>", "quickfix"}, + l = {"<cmd>TroubleToggle loclist<cr>", "loclist"}, + r = {"<cmd>TroubleToggle lsp_references<cr>", "references"} + } +end + if O.plugin.gitlinker.active then mappings["gy"] = "Gitlink" end if O.plugin.zen.active then vim.api.nvim_set_keymap("n", "<leader>z", ":ZenMode<CR>", |