diff --git a/neovim/.config/nvim/init.lua b/neovim/.config/nvim/init.lua index d05c108..a44a38c 100644 --- a/neovim/.config/nvim/init.lua +++ b/neovim/.config/nvim/init.lua @@ -109,3 +109,5 @@ vim.cmd 'colorscheme moonfly' --tabline stuff (gt and gT are prev/next tab in stock vim) map('n', 'gf', ':TablineBufferNext', opts) map('n', 'gF', ':TablineBufferPrevious', opts) + --gitsigns + map('n', 'hl', ':Gitsigns toggle_current_line_blame', opts) diff --git a/neovim/.config/nvim/lua/LSPconfig.lua b/neovim/.config/nvim/lua/LSPconfig.lua index b26b298..bd581f9 100644 --- a/neovim/.config/nvim/lua/LSPconfig.lua +++ b/neovim/.config/nvim/lua/LSPconfig.lua @@ -2,33 +2,33 @@ local nvim_lsp = require('lspconfig') -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer -local on_attach = function(client, bufnr) - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end +local on_attach = function() + local function set_keymap(...) vim.api.nvim_set_keymap(...) end + local function set_option(...) vim.api.nvim_set_option(...) end -- Enable completion triggered by - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local opts = { noremap=true, silent=true } -- See `:help vim.lsp.*` for documentation on any of the below functions - buf_set_keymap('', ';lc', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('', ';lf', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('', ';lh', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('', ';li', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('', ';ls', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('', ';lwa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('', ';lwr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('', ';lw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('', ';lt', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('', ';lr', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('', ';la', 'lua vim.lsp.buf.code_action()', opts) - buf_set_keymap('', ';lc', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('', ';lo', 'lua vim.diagnostic.open_float()', opts) - buf_set_keymap('', ';ln', 'lua vim.diagnostic.goto_prev()', opts) - buf_set_keymap('', ';lp', 'lua vim.diagnostic.goto_next()', opts) - buf_set_keymap('', ';lm', 'lua vim.lsp.buf.formatting()', opts) + set_keymap('', ';lc', 'lua vim.lsp.buf.declaration()', opts) + set_keymap('', ';lf', 'lua vim.lsp.buf.definition()', opts) + set_keymap('', ';lh', 'lua vim.lsp.buf.hover()', opts) + set_keymap('', ';li', 'lua vim.lsp.buf.implementation()', opts) + set_keymap('', ';ls', 'lua vim.lsp.buf.signature_help()', opts) + set_keymap('', ';lwa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + set_keymap('', ';lwr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + set_keymap('', ';lw', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + set_keymap('', ';lt', 'lua vim.lsp.buf.type_definition()', opts) + set_keymap('', ';lr', 'lua vim.lsp.buf.rename()', opts) + set_keymap('', ';la', 'lua vim.lsp.buf.code_action()', opts) + set_keymap('', ';lc', 'lua vim.lsp.buf.references()', opts) + set_keymap('', ';lo', 'lua vim.diagnostic.open_float()', opts) + set_keymap('', ';ln', 'lua vim.diagnostic.goto_prev()', opts) + set_keymap('', ';lp', 'lua vim.diagnostic.goto_next()', opts) + set_keymap('', ';lm', 'lua vim.lsp.buf.formatting()', opts) end @@ -36,7 +36,6 @@ end -- map buffer local keybindings when the language server attaches local servers = { 'pyright', 'rust_analyzer', 'texlab'} for _, lsp in ipairs(servers) do - on_attach() nvim_lsp[lsp].setup { flags = { debounce_text_changes = 150, @@ -48,7 +47,6 @@ end local runtime_path = vim.split(package.path, ';') table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?/init.lua") -on_attach() require'lspconfig'.sumneko_lua.setup { settings = { Lua = { @@ -73,3 +71,4 @@ require'lspconfig'.sumneko_lua.setup { }, }, } +on_attach() diff --git a/neovim/.config/nvim/lua/cmp-lsp.lua b/neovim/.config/nvim/lua/cmp-lsp.lua index a22d2ac..f9cf4be 100644 --- a/neovim/.config/nvim/lua/cmp-lsp.lua +++ b/neovim/.config/nvim/lua/cmp-lsp.lua @@ -5,6 +5,7 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) +local luasnip = require 'luasnip' local lspconfig = require('lspconfig') @@ -23,6 +24,11 @@ vim.o.completeopt = 'menuone,noselect' -- nvim-cmp setup local cmp = require 'cmp' cmp.setup { + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, mapping = { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), @@ -37,6 +43,8 @@ cmp.setup { [''] = function(fallback) if cmp.visible() then cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() else fallback() end @@ -44,6 +52,8 @@ cmp.setup { [''] = function(fallback) if cmp.visible() then cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) else fallback() end @@ -51,5 +61,7 @@ cmp.setup { }, sources = { { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' } }, } diff --git a/neovim/.config/nvim/lua/packages.lua b/neovim/.config/nvim/lua/packages.lua index 3ad0a23..23852e5 100644 --- a/neovim/.config/nvim/lua/packages.lua +++ b/neovim/.config/nvim/lua/packages.lua @@ -90,6 +90,8 @@ return require('packer').startup(function(use) requires = { 'neovim/nvim-lspconfig', 'hrsh7th/cmp-nvim-lsp', + 'saadparwaiz1/cmp_luasnip', + 'L3MON4D3/LuaSnip' } }