2024-10-05 14:23:31 +02:00
|
|
|
{ lib, ... }:
|
2023-09-27 10:43:23 +02:00
|
|
|
{
|
2023-03-22 07:42:02 +01:00
|
|
|
empty = {
|
|
|
|
plugins.lsp.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
example = {
|
|
|
|
plugins.lsp = {
|
|
|
|
enable = true;
|
2024-03-23 17:03:15 +00:00
|
|
|
inlayHints = true;
|
2023-03-22 07:42:02 +01:00
|
|
|
|
|
|
|
keymaps = {
|
|
|
|
silent = true;
|
|
|
|
diagnostic = {
|
|
|
|
"<leader>k" = "goto_prev";
|
2023-07-17 15:37:00 +02:00
|
|
|
"<leader>j" = {
|
|
|
|
action = "goto_next";
|
|
|
|
desc = "Go to next diagnostic";
|
|
|
|
};
|
2023-03-22 07:42:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
lspBuf = {
|
|
|
|
"gd" = "definition";
|
|
|
|
"gD" = "references";
|
|
|
|
"gt" = "type_definition";
|
|
|
|
"gi" = "implementation";
|
2023-07-17 15:37:00 +02:00
|
|
|
"K" = {
|
|
|
|
action = "hover";
|
|
|
|
desc = "Hover";
|
|
|
|
};
|
2023-03-22 07:42:02 +01:00
|
|
|
};
|
2024-03-25 21:39:21 +00:00
|
|
|
|
|
|
|
extra = [
|
|
|
|
{
|
|
|
|
key = "<leader>li";
|
|
|
|
action = "<CMD>LspInfo<Enter>";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
key = "<leader>lx";
|
|
|
|
action = "<CMD>LspStop<Enter>";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
key = "<leader>ls";
|
|
|
|
action = "<CMD>LspStart<Enter>";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
key = "<leader>lr";
|
|
|
|
action = "<CMD>LspRestart<Enter>";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
key = "<leader>ll";
|
|
|
|
action = "<CMD>LspLog<Enter>";
|
|
|
|
}
|
|
|
|
];
|
2023-03-22 07:42:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
servers = {
|
|
|
|
bashls.enable = true;
|
2023-04-19 14:30:02 +02:00
|
|
|
clangd = {
|
|
|
|
enable = true;
|
|
|
|
onAttach.function = ''
|
|
|
|
print('The clangd language server has been attached !')
|
|
|
|
'';
|
|
|
|
};
|
2023-05-22 11:28:18 +02:00
|
|
|
# Do not install the language server using nixvim
|
|
|
|
gopls = {
|
|
|
|
enable = true;
|
2024-02-14 11:22:33 +01:00
|
|
|
package = null;
|
2023-05-22 11:28:18 +02:00
|
|
|
};
|
2024-10-05 15:55:49 +02:00
|
|
|
nil_ls.enable = true;
|
|
|
|
rust_analyzer = {
|
2023-11-23 13:53:22 +01:00
|
|
|
enable = true;
|
|
|
|
installCargo = true;
|
|
|
|
installRustc = true;
|
|
|
|
};
|
2024-11-17 16:54:41 +01:00
|
|
|
ruff = {
|
2023-04-28 12:17:05 +02:00
|
|
|
enable = true;
|
|
|
|
extraOptions = {
|
|
|
|
init_options.settings.args = [ "--config=/path/to/config.toml" ];
|
|
|
|
};
|
|
|
|
};
|
2023-03-22 07:42:02 +01:00
|
|
|
pylsp = {
|
|
|
|
enable = true;
|
|
|
|
filetypes = [ "python" ];
|
|
|
|
autostart = false;
|
|
|
|
};
|
2025-04-25 16:00:16 +01:00
|
|
|
# rootMarkers
|
2024-08-17 01:07:53 +02:00
|
|
|
tinymist = {
|
2023-12-19 11:21:35 +01:00
|
|
|
enable = true;
|
2025-04-25 16:00:16 +01:00
|
|
|
rootMarkers = [
|
|
|
|
".git"
|
|
|
|
"main.typ"
|
|
|
|
];
|
2023-05-25 19:41:18 +02:00
|
|
|
};
|
2023-03-22 07:42:02 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-20 20:40:56 -05:00
|
|
|
volar-tsls-integration =
|
2024-11-06 08:20:18 +01:00
|
|
|
{ config, ... }:
|
2024-09-20 20:40:56 -05:00
|
|
|
{
|
|
|
|
plugins.lsp = {
|
|
|
|
enable = true;
|
|
|
|
servers = {
|
|
|
|
volar.enable = true;
|
2024-10-05 15:55:49 +02:00
|
|
|
ts_ls = {
|
2024-11-06 08:20:18 +01:00
|
|
|
enable = true;
|
2024-09-20 20:40:56 -05:00
|
|
|
filetypes = [ "typescript" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
assertions = [
|
|
|
|
{
|
2024-10-05 15:55:49 +02:00
|
|
|
assertion = lib.any (x: x == "vue") config.plugins.lsp.servers.ts_ls.filetypes;
|
2024-09-20 20:40:56 -05:00
|
|
|
message = "Expected `vue` filetype configuration.";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = lib.any (
|
|
|
|
x: x.name == "@vue/typescript-plugin"
|
2024-10-05 15:55:49 +02:00
|
|
|
) config.plugins.lsp.servers.ts_ls.extraOptions.init_options.plugins;
|
2024-09-20 20:40:56 -05:00
|
|
|
message = "Expected `@vue/typescript-plugin` plugin.";
|
|
|
|
}
|
|
|
|
{
|
2024-10-05 15:55:49 +02:00
|
|
|
assertion = lib.any (x: x == "typescript") config.plugins.lsp.servers.ts_ls.filetypes;
|
2024-09-20 20:40:56 -05:00
|
|
|
message = "Expected `typescript` filetype configuration.";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
tsls-filetypes =
|
2024-11-06 08:20:18 +01:00
|
|
|
{ config, ... }:
|
2024-09-20 20:40:56 -05:00
|
|
|
{
|
|
|
|
plugins.lsp = {
|
|
|
|
enable = true;
|
|
|
|
servers = {
|
2024-10-05 15:55:49 +02:00
|
|
|
ts_ls = {
|
2024-11-06 08:20:18 +01:00
|
|
|
enable = true;
|
2024-09-20 20:40:56 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
assertions = [
|
|
|
|
{
|
2024-10-05 15:55:49 +02:00
|
|
|
assertion = lib.all (x: x != "vue") config.plugins.lsp.servers.ts_ls.filetypes;
|
2024-09-20 20:40:56 -05:00
|
|
|
message = "Did not expect `vue` filetype configuration.";
|
|
|
|
}
|
2024-10-05 15:55:49 +02:00
|
|
|
(lib.mkIf (config.plugins.lsp.servers.ts_ls.extraOptions ? init_options) {
|
2024-09-20 20:40:56 -05:00
|
|
|
assertion = lib.all (
|
|
|
|
x: x.name != "@vue/typescript-plugin"
|
2024-10-05 15:55:49 +02:00
|
|
|
) config.plugins.lsp.servers.ts_ls.extraOptions.init_options.plugins;
|
2024-09-20 20:40:56 -05:00
|
|
|
message = "Did not expect `@vue/typescript-plugin` plugin.";
|
|
|
|
})
|
|
|
|
{
|
2024-10-05 15:55:49 +02:00
|
|
|
assertion = lib.any (x: x == "typescript") config.plugins.lsp.servers.ts_ls.filetypes;
|
2024-09-20 20:40:56 -05:00
|
|
|
message = "Expected `typescript` filetype configuration.";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-11-26 13:19:50 +00:00
|
|
|
|
|
|
|
settings-merge =
|
|
|
|
{ config, lib, ... }:
|
|
|
|
{
|
|
|
|
test.runNvim = false;
|
|
|
|
|
|
|
|
plugins = {
|
|
|
|
lsp = {
|
|
|
|
enable = true;
|
|
|
|
servers.nil_ls = {
|
|
|
|
enable = true;
|
|
|
|
settings.formatting.command = lib.mkForce [
|
|
|
|
"real"
|
|
|
|
"example"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
enabledServers = lib.mkAfter [
|
|
|
|
{
|
|
|
|
name = "second";
|
|
|
|
extraOptions.settings = lib.mkIf false {
|
|
|
|
should.be = "missing";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "third";
|
|
|
|
extraOptions.settings = lib.mkIf true {
|
|
|
|
should.be = "present";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
assertions =
|
|
|
|
let
|
|
|
|
toLua = lib.nixvim.lua.toLua' {
|
|
|
|
removeNullAttrValues = true;
|
|
|
|
removeEmptyAttrValues = true;
|
|
|
|
removeEmptyListEntries = false;
|
|
|
|
removeNullListEntries = false;
|
|
|
|
multiline = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
print = lib.generators.toPretty {
|
|
|
|
multiline = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
serverCount = builtins.length config.plugins.lsp.enabledServers;
|
|
|
|
expectedCount = 3;
|
|
|
|
|
|
|
|
nilServer = builtins.head config.plugins.lsp.enabledServers;
|
|
|
|
nilSettings = toLua nilServer.extraOptions.settings;
|
|
|
|
expectedNilSettings = toLua {
|
|
|
|
nil.formatting.command = [
|
|
|
|
"real"
|
|
|
|
"example"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
secondServer = builtins.elemAt config.plugins.lsp.enabledServers 1;
|
|
|
|
expectedSecondServer = {
|
|
|
|
name = "second";
|
|
|
|
extraOptions = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
thirdServer = builtins.elemAt config.plugins.lsp.enabledServers 2;
|
|
|
|
expectedThirdServer = {
|
|
|
|
name = "third";
|
|
|
|
extraOptions.settings.should.be = "present";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
[
|
|
|
|
{
|
|
|
|
assertion = serverCount == expectedCount;
|
|
|
|
message = "Expected ${toString expectedCount} enabled LSP server!";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = nilSettings == expectedNilSettings;
|
|
|
|
message = ''
|
|
|
|
nil's `extraOptions.settings` does not match expected value.
|
|
|
|
|
|
|
|
Expected: ${expectedNilSettings}
|
|
|
|
|
|
|
|
Actual: ${nilSettings}
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = secondServer == expectedSecondServer;
|
|
|
|
message = ''
|
|
|
|
`secondServer` does not match expected value.
|
|
|
|
|
|
|
|
Expected: ${print expectedSecondServer}
|
|
|
|
|
|
|
|
Actual: ${print secondServer}
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = secondServer == expectedSecondServer;
|
|
|
|
message = ''
|
|
|
|
`thirdServer` does not match expected value.
|
|
|
|
|
|
|
|
Expected: ${print expectedThirdServer}
|
|
|
|
|
|
|
|
Actual: ${print thirdServer}
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2025-06-08 23:30:08 +01:00
|
|
|
|
|
|
|
package-fallback =
|
|
|
|
{ config, ... }:
|
|
|
|
{
|
|
|
|
test.buildNixvim = false;
|
|
|
|
|
|
|
|
plugins.lsp = {
|
|
|
|
enable = true;
|
|
|
|
servers = {
|
|
|
|
nil_ls = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
packageFallback = true;
|
|
|
|
};
|
|
|
|
rust_analyzer = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
installCargo = true;
|
|
|
|
installRustc = true;
|
|
|
|
|
|
|
|
packageFallback = true;
|
|
|
|
};
|
|
|
|
hls = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
installGhc = true;
|
|
|
|
packageFallback = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
assertions =
|
|
|
|
let
|
|
|
|
assertAfter = name: pkg: [
|
|
|
|
{
|
|
|
|
assertion = lib.all (x: x != pkg) config.extraPackages;
|
|
|
|
message = "Expected `${name}` not to be in extraPackages";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = lib.any (x: x == pkg) config.extraPackagesAfter;
|
|
|
|
message = "Expected `${name}` to be in extraPackagesAfter";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
in
|
|
|
|
with config.plugins.lsp.servers;
|
|
|
|
(
|
|
|
|
assertAfter "nil" nil_ls.package
|
|
|
|
++ assertAfter "rust-analyzer" rust_analyzer.package
|
|
|
|
++ assertAfter "cargo" rust_analyzer.cargoPackage
|
|
|
|
++ assertAfter "rustc" rust_analyzer.rustcPackage
|
|
|
|
++ assertAfter "haskell-language-server" hls.package
|
|
|
|
++ assertAfter "ghc" hls.ghcPackage
|
|
|
|
);
|
|
|
|
};
|
2023-03-22 07:42:02 +01:00
|
|
|
}
|