diff --git a/home/vimrc.lua b/home/vimrc.lua index 22df171..9b31e3a 100644 --- a/home/vimrc.lua +++ b/home/vimrc.lua @@ -114,6 +114,11 @@ vim.api.nvim_create_autocmd('LspAttach', { -- map buffer local keybindings when the language server attaches local cmp = require 'cmp' cmp.setup({ + snippet = { + expand = function(args) + vim.fn["UltiSnips#Anon"](args.body) + end, + }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'buffer' }, @@ -132,7 +137,7 @@ cmp.setup({ [""] = cmp.mapping({ i = function(fallback) if cmp.visible() then - cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert }) + cmp.select_prev_item({ behavior = cmp.SelectBehavimr.Insert }) else fallback() end @@ -168,10 +173,27 @@ cmp.setup({ } }) -local servers = { 'pyright', 'rust_analyzer', 'ccls', 'lua_ls', 'rnix', 'texlab', 'verible' } +local servers = { 'pyright', 'rust_analyzer', 'ccls', 'lua_ls', 'nixd', 'texlab', 'verible' } local capabilities = require('cmp_nvim_lsp').default_capabilities() +local on_attach = function(bufnr) + vim.api.nvim_create_autocmd("CursorHold", { + buffer = bufnr, + callback = function() + local opts = { + focusable = false, + close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, + border = "rounded", + source = "always", + prefix = " ", + scope = "line", + } + vim.diagnostic.open_float(nil, opts) + end, + }) +end for _, lsp in pairs(servers) do require('lspconfig')[lsp].setup { + on_attach = on_attach(), capabilities = capabilities } end diff --git a/home/vimrc.nix b/home/vimrc.nix index c3ca439..6256394 100644 --- a/home/vimrc.nix +++ b/home/vimrc.nix @@ -3,27 +3,32 @@ vimUtils, fetchFromGitHub, }: { - extraPackages = [ - pkgs.ccls - pkgs.clang - pkgs.luaformatter - pkgs.nil - pkgs.pyright - pkgs.rnix-lsp - pkgs.rust-analyzer - pkgs.sumneko-lua-language-server - pkgs.svls - pkgs.texlab - pkgs.tree-sitter - pkgs.zls - pkgs.verible + extraPackages = with pkgs; [ + ccls + clang + luaformatter + nixd + pyright + rust-analyzer + sumneko-lua-language-server + svls + texlab + tree-sitter + verible + zls ]; plugins = with pkgs.vimPlugins; [ + cmp-buffer + cmp-cmdline + cmp-nvim-lsp + cmp-nvim-ultisnips + cmp-path colorizer fugitive fzf-vim gruvbox + nvim-cmp nvim-lspconfig nvim-treesitter nvim-ts-rainbow @@ -35,10 +40,5 @@ vim-slime vim-snippets zig-vim - cmp-nvim-lsp - cmp-buffer - cmp-path - cmp-cmdline - nvim-cmp ]; }