mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-28 11:30:06 +02:00
feat: add option for customizing lsp capabilities (#1021)
This commit is contained in:
parent
4448c4ce63
commit
c4ae452396
1 changed files with 32 additions and 0 deletions
|
@ -146,6 +146,15 @@ in {
|
||||||
description = "The server's name";
|
description = "The server's name";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
capabilities = mkOption {
|
||||||
|
type = types.nullOr (types.attrsOf types.bool);
|
||||||
|
description = "Control resolved capabilities for the language server.";
|
||||||
|
default = null;
|
||||||
|
example = {
|
||||||
|
documentFormattingProvider = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
extraOptions = mkOption {
|
extraOptions = mkOption {
|
||||||
type = attrs;
|
type = attrs;
|
||||||
description = "Extra options for the server";
|
description = "Extra options for the server";
|
||||||
|
@ -196,6 +205,27 @@ in {
|
||||||
if wrappers == []
|
if wrappers == []
|
||||||
then s
|
then s
|
||||||
else (head wrappers) (runWrappers (tail wrappers) s);
|
else (head wrappers) (runWrappers (tail wrappers) s);
|
||||||
|
updateCapabilities = let
|
||||||
|
servers =
|
||||||
|
builtins.filter
|
||||||
|
(server: server.capabilities != null && server.capabilities != {})
|
||||||
|
cfg.enabledServers;
|
||||||
|
in
|
||||||
|
lib.concatMapStringsSep "\n" (
|
||||||
|
server: let
|
||||||
|
updates =
|
||||||
|
lib.concatMapStringsSep "\n"
|
||||||
|
(name: ''
|
||||||
|
client.server_capabilities.${name} = ${helpers.toLuaObject server.capabilities.${name}}
|
||||||
|
'')
|
||||||
|
(builtins.attrNames server.capabilities);
|
||||||
|
in ''
|
||||||
|
if client.name == "${server.name}" then
|
||||||
|
${updates}
|
||||||
|
end
|
||||||
|
''
|
||||||
|
)
|
||||||
|
servers;
|
||||||
in
|
in
|
||||||
mkIf cfg.enable {
|
mkIf cfg.enable {
|
||||||
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
|
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
|
||||||
|
@ -237,6 +267,8 @@ in {
|
||||||
|
|
||||||
local __lspServers = ${helpers.toLuaObject cfg.enabledServers}
|
local __lspServers = ${helpers.toLuaObject cfg.enabledServers}
|
||||||
local __lspOnAttach = function(client, bufnr)
|
local __lspOnAttach = function(client, bufnr)
|
||||||
|
${updateCapabilities}
|
||||||
|
|
||||||
${cfg.onAttach}
|
${cfg.onAttach}
|
||||||
end
|
end
|
||||||
local __lspCapabilities = function()
|
local __lspCapabilities = function()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue