pkgsets/nvim: update lsp config to use opts

This commit is contained in:
Kevin Baensch 2025-03-21 23:55:52 +01:00
parent d8f29e12b5
commit 378da9479f
Signed by: derped
GPG key ID: C0F1D326C7626543
17 changed files with 355 additions and 339 deletions

View file

@ -5,10 +5,12 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::bash" config.machine.pkgs) # lua
''
lspconfig.bashls.setup({
cmd = {"${pkgs.nodePackages.bash-language-server}/bin/bash-language-server", "start"},
filetypes = {"sh"},
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::bash" config.machine.pkgs) {
bashls = {
cmd = [
"${pkgs.nodePackages.bash-language-server}/bin/bash-language-server"
"start"
];
filetypes = [ "sh" ];
};
}

View file

@ -5,18 +5,17 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::c" config.machine.pkgs) # lua
''
lspconfig.ccls.setup {
cmd = { "${pkgs.ccls}/bin/ccls" },
init_options = {
compilationDatabaseDirectory = "build";
index = {
threads = 0;
};
clang = {
excludeArgs = { "-frounding-math"} ;
};
}
}
''
lib.optionalAttrs (lib.elem "nvim::lsp::c" config.machine.pkgs) {
ccls = {
cmd = [ "${pkgs.ccls}/bin/ccls" ];
init_options = {
# compilationDatabaseDirectory = "build";
index = {
threads = 0;
};
clang = {
excludeArgs = [ "-frounding-math" ];
};
};
};
}

View file

@ -5,9 +5,11 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::emmet" config.machine.pkgs) # lua
''
lspconfig.emmet_language_server.setup({
cmd = {"${pkgs.emmet-language-server}/bin/emmet-language-server", "--stdio"}
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::emmet" config.machine.pkgs) {
emmet_language_server = {
cmd = [
"${pkgs.emmet-language-server}/bin/emmet-language-server"
"--stdio"
];
};
}

View file

@ -5,9 +5,8 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::go" config.machine.pkgs) # lua
''
lspconfig.gopls.setup({
cmd = {"${pkgs.gopls}/bin/gopls"}
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::go" config.machine.pkgs) {
gopls = {
cmd = [ "${pkgs.gopls}/bin/gopls" ];
};
}

View file

@ -5,9 +5,11 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::harper" config.machine.pkgs) # lua
''
lspconfig.harper_ls.setup({
cmd = { "${pkgs.harper}/bin/harper-ls", "--stdio" },
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::harper" config.machine.pkgs) {
harper_ls = {
cmd = [
"${pkgs.harper}/bin/harper-ls"
"--stdio"
];
};
}

View file

@ -5,12 +5,11 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::html" config.machine.pkgs) # lua
''
local html_capabilities = vim.lsp.protocol.make_client_capabilities()
html_capabilities.textDocument.completion.completionItem.snippetSupport = true
lspconfig.html.setup({
capabilities = html_capabilities,
cmd = {"${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server"}
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::html" config.machine.pkgs) {
# local html_capabilities = vim.lsp.protocol.make_client_capabilities()
# html_capabilities.textDocument.completion.completionItem.snippetSupport = true
html = {
capabilities = _: "vim.lsp.protocol.make_client_capabilities()";
cmd = [ "${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server" ];
};
}

View file

@ -5,20 +5,23 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::ltex" config.machine.pkgs) # lua
''
lspconfig.ltex.setup({
cmd = { "${pkgs.ltex-ls}/bin/ltex-ls" },
settings = {
ltex = {
language = "de-DE",
},
},
})
vim.api.nvim_create_user_command(
"LtexLang",
"lua SetLtexLang(<q-args>)",
{ nargs = 1, desc = "Set ltex-ls language" }
)
''
lib.optionalAttrs (lib.elem "nvim::lsp::ltex" config.machine.pkgs) {
ltex = {
cmd = [ "${pkgs.ltex-ls}/bin/ltex-ls" ];
settings = {
ltex = {
language = "de-DE";
};
};
on_attach =
_: # lua
''
function(client, bufnr)
vim.api.nvim_create_user_command(
"LtexLang",
"lua SetLtexLang(<q-args>)",
{ nargs = 1, desc = "Set ltex-ls language" }
)
end'';
};
}

View file

@ -5,22 +5,21 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::lua" config.machine.pkgs) # lua
''
lspconfig.lua_ls.setup({
cmd = {"${pkgs.lua-language-server}/bin/lua-language-server"},
settings = {
Lua = {
runtime = {
version = 'LuaJIT'
},
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
}
}
}
}
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::lua" config.machine.pkgs) {
lua_ls = {
cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ];
settings = {
Lua = {
runtime = {
version = "LuaJIT";
};
workspace = {
checkThirdParty = false;
library = [
(_: "vim.env.VIMRUNTIME")
];
};
};
};
};
}

View file

@ -5,9 +5,11 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::markdown" config.machine.pkgs) # lua
''
lspconfig.marksman.setup {
cmd = { "${pkgs.marksman}/bin/marksman", "server" },
}
''
lib.optionalAttrs (lib.elem "nvim::lsp::markdown" config.machine.pkgs) {
marksman = {
cmd = [
"${pkgs.marksman}/bin/marksman"
"server"
];
};
}

View file

@ -5,22 +5,21 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::nix-nil" config.machine.pkgs) # lua
''
lspconfig.nil_ls.setup({
cmd = {"${pkgs.nil}/bin/nil"},
settings = {
['nil'] = {
formatting = {
command = { "${pkgs.nixfmt-rfc-style}/bin/nixfmt" }
},
maxMemoryMB = 4069,
-- nix = {
-- flake = {
-- autoEvalInputs = true
-- }
-- }
}
}
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::nix-nil" config.machine.pkgs) {
nil_ls = {
cmd = [ "${pkgs.nil}/bin/nil" ];
settings = {
"['nil']" = {
formatting = {
command = [ "${pkgs.nixfmt-rfc-style}/bin/nixfmt" ];
};
maxMemoryMB = 4069;
# nix = {
# flake = {
# autoEvalInputs = true;
# };
# };
};
};
};
}

View file

@ -5,38 +5,42 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::nix-nixd" config.machine.pkgs) # lua
''
lspconfig.nixd.setup({
cmd = { "${pkgs.nixd}/bin/nixd" },
settings = {
nixd = {
-- on_init = function(client)
-- local path = client.workspace_folders[1].name
lib.optionalAttrs (lib.elem "nvim::lsp::nix-nixd" config.machine.pkgs) {
nixd = {
cmd = [ "${pkgs.nixd}/bin/nixd" ];
settings = {
nixd = {
on_init =
_: # lua
''
function(client)
local path = client.workspace_folders[1].name
-- if path == '/path/to/project1' then
-- client.config.settings["rust-analyzer"].checkOnSave.overrideCommand = { "cargo", "check" }
-- client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
-- end
if path == '/path/to/project1' then
client.config.settings["rust-analyzer"].checkOnSave.overrideCommand = { "cargo", "check" }
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
-- return true
-- end,
nixpkgs = {
expr = 'import (builtins.getFlake ("git+file:///etc/nixos")).inputs.nixpkgs {}',
},
formatting = {
command = { "${pkgs.nixfmt-rfc-style}/bin/nixfmt" },
},
options = {
nixos = {
expr = '(builtins.getFlake ("git+file:///etc/nixos")).outputs.nixosConfigurations.Lilim.options',
},
-- TODO: Find a good general expression for this.
-- home_manager = {
-- expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."ruixi@k-on".options',
-- },
},
},
},
})
''
return true
end
'';
nixpkgs = {
expr = ''import (builtins.getFlake ("git+file:///etc/nixos")).inputs.nixpkgs {}'';
};
formatting = {
command = [ "${pkgs.nixfmt-rfc-style}/bin/nixfmt" ];
};
options = {
nixos = {
expr = ''(builtins.getFlake ("git+file:///etc/nixos")).outputs.nixosConfigurations.Lilim.options'';
};
# TODO: Find a good general expression for this.
# home_manager = {
# expr =
# "'(builtins.getFlake (\"git+file://\" + toString ./.)).homeConfigurations.\"ruixi@k-on\".options'";
# };
};
};
};
};
}

View file

@ -5,15 +5,17 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::php" config.machine.pkgs) # lua
''
lspconfig.phpactor.setup({
cmd = {"${pkgs.phpactor}/bin/phpactor", "language-server"},
init_options = {
["symfony.enabled"] = true,
["language_server_phpstan.enabled"] = true,
["language_server_phpstan.bin"] = "${pkgs.phpPackages.phpstan}/bin/phpstan",
["language_server_phpstan.level"] = 5,
},
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::php" config.machine.pkgs) {
phpactor = {
cmd = [
"${pkgs.phpactor}/bin/phpactor"
"language-server"
];
init_options = {
"[\"symfony.enabled\"]" = true;
"[\"language_server_phpstan.enabled\"]" = true;
"[\"language_server_phpstan.bin\"]" = "${pkgs.phpPackages.phpstan}/bin/phpstan";
"[\"language_server_phpstan.level\"]" = 5;
};
};
}

View file

@ -5,40 +5,50 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::python" config.machine.pkgs) # lua
''
lspconfig.pyright.setup({
cmd = {"${pkgs.pyright}/bin/pyright-langserver", "--stdio"},
lib.optionalAttrs (lib.elem "nvim::lsp::python" config.machine.pkgs) {
pyright = {
cmd = [
"${pkgs.pyright}/bin/pyright-langserver"
"--stdio"
];
settings = {
pyright = {
disableOrganizeImports = true;
};
python = {
# analysis = {
# ignore = { '*' },
# },
};
};
};
ruff = {
cmd = [
"${pkgs.ruff}/bin/ruff"
"server"
"--preview"
];
init_options = {
settings = {
pyright = {
disableOrganizeImports = true,
},
python = {
-- analysis = {
-- ignore = { '*' },
-- },
},
},
})
lspconfig.ruff.setup({
cmd = {"${pkgs.ruff}/bin/ruff", "server", "--preview"},
init_options = {
settings = {
-- Modification to any of these settings has no effect.
enable = true,
ignoreStandardLibrary = true,
organizeImports = true,
fixAll = true,
lint = {
enable = true,
run = 'onType',
},
},
},
on_attach = function(client, bufnr)
if client.name == 'ruff' then
client.server_capabilities.hoverProvider = false;
end
end,
})
''
# Modification to any of these settings has no effect.
enable = true;
ignoreStandardLibrary = true;
organizeImports = true;
fixAll = true;
lineLength = 120;
lint = {
enable = true;
run = "onType";
};
};
};
on_attach =
_: # lua
''
function(client, bufnr)
if client.name == 'ruff' then
client.server_capabilities.hoverProvider = false;
end
end'';
};
}

View file

@ -5,9 +5,13 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::rust" config.machine.pkgs) # lua
''
lspconfig.rust_analyzer.setup({
cmd = {"${pkgs.rustup}/bin/rustup", "run", "nightly", "rust-analyzer"}
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::rust" config.machine.pkgs) {
rust_analyzer = {
cmd = [
"${pkgs.rustup}/bin/rustup"
"run"
"nightly"
"rust-analyzer"
];
};
}

View file

@ -5,9 +5,11 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::typescript" config.machine.pkgs) # lua
''
lspconfig.ts_ls.setup({
cmd = {"${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server", "--stdio"}
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::typescript" config.machine.pkgs) {
ts_ls = {
cmd = [
"${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server"
"--stdio"
];
};
}

View file

@ -5,20 +5,22 @@
...
}:
lib.optionalString (lib.elem "nvim::lsp::yaml" config.machine.pkgs) # lua
''
lspconfig.yamlls.setup({
cmd = { "${pkgs.yaml-language-server}/bin/yaml-language-server", "--stdio" },
settings = {
yaml = {
schemaStore = {
-- Disable to use Store from SchemaStore-nvim plugin
enable = false,
-- Avoid TypeError: Cannot read properties of undefined (reading 'length')
url = "",
},
schemas = require('schemastore').yaml.schemas(),
},
},
})
''
lib.optionalAttrs (lib.elem "nvim::lsp::yaml" config.machine.pkgs) {
yamlls = {
cmd = [
"${pkgs.yaml-language-server}/bin/yaml-language-server"
"--stdio"
];
settings = {
yaml = {
schemaStore = {
# Disable to use Store from SchemaStore-nvim plugin
enable = false;
# Avoid TypeError: Cannot read properties of undefined (reading 'length')
url = "";
};
schemas = _: "require('schemastore').yaml.schemas()";
};
};
};
}