diff --git a/common/neovim/lua/keymap.lua b/common/neovim/lua/keymap.lua index bdaaf61..414ae64 100644 --- a/common/neovim/lua/keymap.lua +++ b/common/neovim/lua/keymap.lua @@ -1,21 +1,21 @@ -for _,keys in ipairs{'jj', 'jJ', 'Jj', 'JJ', 'jk', 'jK', 'Jk', 'JK'} do vim.api.nvim_set_keymap('i', keys, '', {}) end +for _, keys in ipairs { 'jj', 'jJ', 'Jj', 'JJ', 'jk', 'jK', 'Jk', 'JK' } do vim.api.nvim_set_keymap('i', keys, '', {}) end local m = { - s = {silent = true}, - n = {noremap = true}, - sn = {silent = true, noremap = true}, + s = { silent = true }, + n = { noremap = true }, + sn = { silent = true, noremap = true }, } local keymap = { n = { - ['/'] = {':let @/ = "":', m.s}, + ['/'] = { ':let @/ = "":', m.s }, - ['r'] = {':luafile ' .. vim.g.vimdir .. '/init.lua:echo \'Reloaded init.lua\'', m.s}, - ['gv'] = {':e ' .. vim.g.vimdir .. '/init.lua', m.s}, + ['r'] = { ':luafile ' .. vim.g.vimdir .. '/init.lua:echo \'Reloaded init.lua\'', m.s }, + ['gv'] = { ':e ' .. vim.g.vimdir .. '/init.lua', m.s }, - ['w'] = {':bd', m.s}, - ['h'] = {':b#', m.s}, - ['k'] = {':bnext', m.s}, - ['j'] = {':bprevious', m.s}, + ['w'] = { ':bd', m.s }, + ['h'] = { ':b#', m.s }, + ['k'] = { ':bnext', m.s }, + ['j'] = { ':bprevious', m.s }, [''] = ':qa', @@ -44,37 +44,32 @@ local keymap = { t = {}, [''] = { - [''] = {'', m.sn}, + [''] = { '', m.sn }, -- remove trailing whitespace [''] = 'mw:%s/\\s\\+$//:let @/ = ""\'w', ['gs'] = ':setlocal spell!', - [',w'] = {'CamelCaseMotion_w', m.s}, - [',b'] = {'CamelCaseMotion_b', m.s}, - [',e'] = {'CamelCaseMotion_e', m.s}, - [',ge'] = {'CamelCaseMotion_ge', m.s}, + [',w'] = { 'CamelCaseMotion_w', m.s }, + [',b'] = { 'CamelCaseMotion_b', m.s }, + [',e'] = { 'CamelCaseMotion_e', m.s }, + [',ge'] = { 'CamelCaseMotion_ge', m.s }, }, o = { - ['ib'] = {'CamelCaseMotion_ib', m.s}, - ['ie'] = {'CamelCaseMotion_ie', m.s}, + ['ib'] = { 'CamelCaseMotion_ib', m.s }, + ['ie'] = { 'CamelCaseMotion_ie', m.s }, }, x = { ['<'] = ''] = '>gv', - ['ib'] = {'CamelCaseMotion_ib', m.s}, - ['ie'] = {'CamelCaseMotion_ie', m.s}, - }, - c = { - [''] = '', - [''] = '', + ['ib'] = { 'CamelCaseMotion_ib', m.s }, + ['ie'] = { 'CamelCaseMotion_ie', m.s }, }, i = { [''] = '', - [''] = {'(completion_trigger)', m.s}, }, } -for mode,mappings in pairs(keymap) do - for key,bind in pairs(mappings) do +for mode, mappings in pairs(keymap) do + for key, bind in pairs(mappings) do if type(bind) == 'table' then vim.api.nvim_set_keymap(mode, key, bind[1], bind[2]) else diff --git a/common/neovim/lua/lsp.lua b/common/neovim/lua/lsp.lua index 1193845..06b1e8d 100644 --- a/common/neovim/lua/lsp.lua +++ b/common/neovim/lua/lsp.lua @@ -1,4 +1,4 @@ -local lsp = require'lspconfig' +local lsp = require 'lspconfig' -- local coq = require'coq' -- TODO: replace with nvim lsp bindings for jumping to next linting issue? @@ -9,7 +9,7 @@ local opts = { silent = true, } -local lsp_format = require'lsp-format' +local lsp_format = require 'lsp-format' local on_attach = function(client, bufnr) lsp_format.on_attach(client) @@ -18,24 +18,25 @@ local on_attach = function(client, bufnr) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g]', 'lua vim.diagnostic.goto_next()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g[', 'lua vim.diagnostic.goto_prev()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'i', '', 'lua vim.lsp.buf.signature_help()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'i', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting_seq_sync()', opts) end +local capabilities = require 'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities()) local common_config = { - capabilities = require'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities()), + capabilities = capabilities, on_attach = on_attach, flags = { debounce_text_changes = 150 @@ -45,13 +46,19 @@ local common_config = { local lsp_configs = { gopls = {}, elixirls = { - cmd = { vim.fn.expand'~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' }, + cmd = { vim.fn.expand '~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' }, + settings = { + elixirLS = { + dialyzerEnabled = true, + fetchDeps = false, + } + } }, sumneko_lua = { settings = { Lua = { diagnostics = { - globals = {'vim'} + globals = { 'vim' } } } } @@ -66,17 +73,17 @@ local lsp_configs = { } for server, config in pairs(lsp_configs) do - for k,v in pairs(common_config) do config[k] = v end + for k, v in pairs(common_config) do config[k] = v end lsp[server].setup(config) end -local lsp_installer = require'nvim-lsp-installer' +local lsp_installer = require 'nvim-lsp-installer' lsp_installer.on_server_ready(function(server) - local server_opts = {} + local server_opts = {} - -- if server.name == "elixirls" then - -- server_opts.cmd = { vim.fn.expand'~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' } - -- end + -- if server.name == "elixirls" then + -- server_opts.cmd = { vim.fn.expand'~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' } + -- end - server:setup(server_opts) + server:setup(server_opts) end) diff --git a/common/neovim/lua/plugins.lua b/common/neovim/lua/plugins.lua index facfa1f..309ce3e 100644 --- a/common/neovim/lua/plugins.lua +++ b/common/neovim/lua/plugins.lua @@ -1,7 +1,7 @@ -local packer_install_path = vim.fn.stdpath'data' .. '/site/pack/packer/start/packer.nvim' +local packer_install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' if #vim.fn.glob(packer_install_path) == 0 then - vim.fn.system{'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_install_path} - vim.api.nvim_command'packadd packer.nvim' + vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_install_path } + vim.api.nvim_command 'packadd packer.nvim' end local has_words_before = function() @@ -9,7 +9,7 @@ local has_words_before = function() return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end -local packer = require'packer' +local packer = require 'packer' packer.startup(function() local plugins = { @@ -22,7 +22,7 @@ packer.startup(function() 'christoomey/vim-tmux-navigator', -- navigate vim splits and tmux panes fluidly 'machakann/vim-sandwich', -- edit surrounding characters 'michaeljsmith/vim-indent-object', -- adds indent-level text objects - 'wellle/targets.vim', -- add many other text objects + -- 'wellle/targets.vim', -- add many other text objects 'bkad/CamelCaseMotion', -- invaluable motions for properly operating on various casings { @@ -30,7 +30,7 @@ packer.startup(function() 'olimorris/persisted.nvim', config = function() local should_autoload = #vim.v.argv == 1 - require'persisted'.setup{ + require 'persisted'.setup { autoload = should_autoload, autosave = should_autoload, } @@ -40,7 +40,7 @@ packer.startup(function() -- toggle comments 'terrortylor/nvim-comment', config = function() - require'nvim_comment'.setup() + require 'nvim_comment'.setup() end }, { @@ -57,7 +57,7 @@ packer.startup(function() }, { 'tzachar/cmp-fuzzy-path', - requires = {'hrsh7th/nvim-cmp', 'tzachar/fuzzy.nvim'}, + requires = { 'hrsh7th/nvim-cmp', 'tzachar/fuzzy.nvim' }, }, -- TODO: add keymap ig for toggling these 'lukas-reineke/indent-blankline.nvim', -- indentation guide lines @@ -70,15 +70,38 @@ packer.startup(function() 'hrsh7th/cmp-buffer', -- add buffer information to completion engine 'hrsh7th/cmp-path', -- add filesystem information to complete enging 'hrsh7th/cmp-cmdline', -- add completion for vim commands + 'onsails/lspkind-nvim', 'saadparwaiz1/cmp_luasnip', { -- completion engine 'hrsh7th/nvim-cmp', config = function() - local cmp = require'cmp' - local luasnip = require'luasnip' + local cmp = require 'cmp' + local luasnip = require 'luasnip' - cmp.setup{ + local prev_item = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end + + local next_item = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end + + cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) @@ -88,36 +111,16 @@ packer.startup(function() [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [''] = cmp.mapping{ + [''] = cmp.config.disable, + [''] = cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close(), }, - [''] = cmp.config.disable, - [''] = cmp.config.disable, - [''] = cmp.mapping.confirm{select = true}, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - --[[ [""] = cmp.mapping(function(fallback) - - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - ]]-- + [''] = cmp.mapping.confirm { select = false }, + [""] = cmp.mapping(next_item, { "i", "s" }), + [""] = cmp.mapping(prev_item, { "i", "s" }), + [''] = cmp.mapping(next_item, { "i", "s" }), + [''] = cmp.mapping(prev_item, { "i", "s" }), }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, @@ -128,20 +131,30 @@ packer.startup(function() { name = 'path' }, { name = 'fuzzy_path' }, }), + formatting = { + format = require("lspkind").cmp_format { + with_text = true, + menu = { + nvim_lsp = "[LSP]", + }, + } + }, } cmp.setup.cmdline('/', { + -- mapping = cmp.mapping.preset.cmdline(), sources = { - {name = 'buffer'}, - {name = 'fuzzy_path'}, + { name = 'buffer' }, + { name = 'fuzzy_path' }, } }) cmp.setup.cmdline(':', { + -- mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ - {name = 'path'} + { name = 'path' } }, { - {name = 'cmdline'} + { name = 'cmdline' } }) }) end, @@ -154,8 +167,8 @@ packer.startup(function() 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', config = function() - require'nvim-treesitter.configs'.setup { - ensure_installed = "maintained", + require 'nvim-treesitter.configs'.setup { + ensure_installed = "all", sync_install = false, ignore_install = {}, indent = { @@ -175,5 +188,5 @@ packer.startup(function() }, 'lukas-reineke/lsp-format.nvim', } - for _,plugin in pairs(plugins) do packer.use(plugin) end + for _, plugin in pairs(plugins) do packer.use(plugin) end end) diff --git a/common/tmux/conf b/common/tmux/conf index 1203785..b56729e 100644 --- a/common/tmux/conf +++ b/common/tmux/conf @@ -30,7 +30,7 @@ set -g monitor-activity on set -g visual-bell on set -g bell-action other set -g mode-keys vi -set -g history-limit 102400000 +set -g history-limit 1024000 set -g status on set -g status-position bottom set -g status-bg colour0