diff --git a/home/nvim/default.nix b/home/nvim/default.nix index 489046b..3fb3a54 100644 --- a/home/nvim/default.nix +++ b/home/nvim/default.nix @@ -32,8 +32,8 @@ cmp-nvim-ultisnips nvim-cmp { - plugin: nvim-lspconfig; - config = builtins.readfile ./lsp.vim + plugin = nvim-lspconfig; + config = builtins.readFile ./lsp.vim; } { plugin = fzf-vim; diff --git a/home/nvim/lsp.vim b/home/nvim/lsp.vim new file mode 100644 index 0000000..f7f7dff --- /dev/null +++ b/home/nvim/lsp.vim @@ -0,0 +1,72 @@ +lua <'] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'ultisnips' }, -- For ultisnips users. + }, { + { name = 'buffer' }, + }) + }) + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) + }) + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + +-- -- Set up lspconfig. +-- local capabilities = require('cmp_nvim_lsp').default_capabilities() +-- -- Replace with each lsp server you've enabled. +-- require('lspconfig')['typescript'].setup { +-- capabilities = capabilities +-- } + local servers = { "r_language_server", "tsserver" } + for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + }, + capabilities = capabilities + } + end +EOF