From 35d96e1e6943e5bb077f6e01111f24f7ba18f428 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 4 Mar 2022 17:36:01 +0100 Subject: [PATCH] home: vim: configure 'nvim-cmp' for LSP --- home/vim/plugin/settings/completion.vim | 1 + home/vim/plugin/settings/lspconfig.vim | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/home/vim/plugin/settings/completion.vim b/home/vim/plugin/settings/completion.vim index 2069902..12741d6 100644 --- a/home/vim/plugin/settings/completion.vim +++ b/home/vim/plugin/settings/completion.vim @@ -7,6 +7,7 @@ local cmp = require("cmp") cmp.setup({ sources = { { name = "buffer" }, + { name = "nvim_lsp" }, { name = "nvim_lua" }, { name = "path" }, }, diff --git a/home/vim/plugin/settings/lspconfig.vim b/home/vim/plugin/settings/lspconfig.vim index 2442059..5d1b135 100644 --- a/home/vim/plugin/settings/lspconfig.vim +++ b/home/vim/plugin/settings/lspconfig.vim @@ -2,9 +2,14 @@ lua << EOF local lsp = require("lspconfig") local utils = require("ambroisie.utils") +-- Inform servers we are able to do completion, snippets, etc... +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) + -- C/C++ if utils.is_executable("clangd") then lsp.clangd.setup({ + capabilities = capabilities, on_attach = utils.on_attach, }) end @@ -12,6 +17,7 @@ end -- Nix if utils.is_executable("rnix-lsp") then lsp.rnix.setup({ + capabilities = capabilities, on_attach = utils.on_attach, }) end @@ -19,6 +25,7 @@ end -- Python if utils.is_executable("pyright") then lsp.pyright.setup({ + capabilities = capabilities, on_attach = utils.on_attach, }) end @@ -26,6 +33,7 @@ end -- Rust if utils.is_executable("rust-analyzer") then lsp.rust_analyzer.setup({ + capabilities = capabilities, on_attach = utils.on_attach, }) end