nvim-lsp: added nvim-cmp completion capabilities (#158)

Co-authored-by: Pedro Alves <pta2002@pta2002.com>
This commit is contained in:
Gaétan Lepage 2023-02-20 17:32:05 +01:00 committed by GitHub
parent 60faa3cf93
commit bb3721e92d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View file

@ -453,6 +453,14 @@ in {
}) })
known_source_names); known_source_names);
in in
mkIf cfg.auto_enable_sources attrs_enabled; mkMerge [
(mkIf cfg.auto_enable_sources attrs_enabled)
(mkIf (elem "nvim_lsp" found_sources)
{
lsp.capabilities = ''
capabilities = require('cmp_nvim_lsp').default_capabilities()
'';
})
];
}; };
} }

View file

@ -21,6 +21,7 @@
./git/gitmessenger.nix ./git/gitmessenger.nix
./git/gitsigns.nix ./git/gitsigns.nix
./git/neogit.nix ./git/neogit.nix
./languages/clangd-extensions.nix ./languages/clangd-extensions.nix
./languages/ledger.nix ./languages/ledger.nix
./languages/markdown-preview.nix ./languages/markdown-preview.nix

View file

@ -44,6 +44,12 @@ in {
default = ""; default = "";
}; };
capabilities = mkOption {
type = types.lines;
description = "Lua code that modifies inplace the `capabilities` table.";
default = "";
};
setupWrappers = mkOption { setupWrappers = mkOption {
type = with types; listOf (functionTo str); type = with types; listOf (functionTo str);
description = "Code to be run to wrap the setup args. Takes in an argument containing the previous results, and returns a new string of code."; description = "Code to be run to wrap the setup args. Takes in an argument containing the previous results, and returns a new string of code.";
@ -78,13 +84,22 @@ in {
-- LSP {{{ -- LSP {{{
do do
${cfg.preConfig} ${cfg.preConfig}
local __lspServers = ${helpers.toLuaObject cfg.enabledServers} local __lspServers = ${helpers.toLuaObject cfg.enabledServers}
local __lspOnAttach = function(client, bufnr) local __lspOnAttach = function(client, bufnr)
${cfg.onAttach} ${cfg.onAttach}
end end
local __lspCapabilities = function()
capabilities = vim.lsp.protocol.make_client_capabilities()
${cfg.capabilities}
return capabilities
end
local __setup = ${runWrappers cfg.setupWrappers "{ local __setup = ${runWrappers cfg.setupWrappers "{
on_attach = __lspOnAttach on_attach = __lspOnAttach,
capabilities = __lspCapabilities()
}"} }"}
for i,server in ipairs(__lspServers) do for i,server in ipairs(__lspServers) do