home: vim: configure 'nvim-cmp' for LSP

This commit is contained in:
Bruno BELANYI 2022-03-04 17:36:01 +01:00
parent 05e7883dab
commit 35d96e1e69
2 changed files with 9 additions and 0 deletions

View file

@ -7,6 +7,7 @@ local cmp = require("cmp")
cmp.setup({ cmp.setup({
sources = { sources = {
{ name = "buffer" }, { name = "buffer" },
{ name = "nvim_lsp" },
{ name = "nvim_lua" }, { name = "nvim_lua" },
{ name = "path" }, { name = "path" },
}, },

View file

@ -2,9 +2,14 @@ lua << EOF
local lsp = require("lspconfig") local lsp = require("lspconfig")
local utils = require("ambroisie.utils") 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++ -- C/C++
if utils.is_executable("clangd") then if utils.is_executable("clangd") then
lsp.clangd.setup({ lsp.clangd.setup({
capabilities = capabilities,
on_attach = utils.on_attach, on_attach = utils.on_attach,
}) })
end end
@ -12,6 +17,7 @@ end
-- Nix -- Nix
if utils.is_executable("rnix-lsp") then if utils.is_executable("rnix-lsp") then
lsp.rnix.setup({ lsp.rnix.setup({
capabilities = capabilities,
on_attach = utils.on_attach, on_attach = utils.on_attach,
}) })
end end
@ -19,6 +25,7 @@ end
-- Python -- Python
if utils.is_executable("pyright") then if utils.is_executable("pyright") then
lsp.pyright.setup({ lsp.pyright.setup({
capabilities = capabilities,
on_attach = utils.on_attach, on_attach = utils.on_attach,
}) })
end end
@ -26,6 +33,7 @@ end
-- Rust -- Rust
if utils.is_executable("rust-analyzer") then if utils.is_executable("rust-analyzer") then
lsp.rust_analyzer.setup({ lsp.rust_analyzer.setup({
capabilities = capabilities,
on_attach = utils.on_attach, on_attach = utils.on_attach,
}) })
end end