nix-community.nixvim/tests/test-sources/plugins/lsp/_lsp.nix

160 lines
3.9 KiB
Nix
Raw Normal View History

{ lib, ... }:
2024-05-05 19:39:35 +02:00
{
2023-03-22 07:42:02 +01:00
empty = {
plugins.lsp.enable = true;
};
example = {
plugins.lsp = {
enable = true;
inlayHints = true;
2023-03-22 07:42:02 +01:00
keymaps = {
silent = true;
diagnostic = {
"<leader>k" = "goto_prev";
"<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";
"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;
clangd = {
enable = true;
onAttach.function = ''
print('The clangd language server has been attached !')
'';
};
# Do not install the language server using nixvim
gopls = {
enable = true;
package = null;
};
nil_ls.enable = true;
rust_analyzer = {
enable = true;
installCargo = true;
installRustc = true;
};
ruff_lsp = {
enable = true;
extraOptions = {
2024-05-05 19:39:35 +02:00
init_options.settings.args = [ "--config=/path/to/config.toml" ];
};
};
2023-03-22 07:42:02 +01:00
pylsp = {
enable = true;
2024-05-05 19:39:35 +02:00
filetypes = [ "python" ];
2023-03-22 07:42:02 +01:00
autostart = false;
};
# rootDir
tinymist = {
2023-12-19 11:21:35 +01:00
enable = true;
rootDir = ''
require 'lspconfig.util'.root_pattern('.git', 'main.typ')
'';
};
2023-03-22 07:42:02 +01:00
};
};
};
volar-tsls-integration =
{ config, ... }:
{
plugins.lsp = {
enable = true;
servers = {
volar.enable = true;
ts_ls = {
enable = true;
filetypes = [ "typescript" ];
};
};
};
assertions = [
{
assertion = lib.any (x: x == "vue") config.plugins.lsp.servers.ts_ls.filetypes;
message = "Expected `vue` filetype configuration.";
}
{
assertion = lib.any (
x: x.name == "@vue/typescript-plugin"
) config.plugins.lsp.servers.ts_ls.extraOptions.init_options.plugins;
message = "Expected `@vue/typescript-plugin` plugin.";
}
{
assertion = lib.any (x: x == "typescript") config.plugins.lsp.servers.ts_ls.filetypes;
message = "Expected `typescript` filetype configuration.";
}
];
};
tsls-filetypes =
{ config, ... }:
{
plugins.lsp = {
enable = true;
servers = {
ts_ls = {
enable = true;
};
};
};
assertions = [
{
assertion = lib.all (x: x != "vue") config.plugins.lsp.servers.ts_ls.filetypes;
message = "Did not expect `vue` filetype configuration.";
}
(lib.mkIf (config.plugins.lsp.servers.ts_ls.extraOptions ? init_options) {
assertion = lib.all (
x: x.name != "@vue/typescript-plugin"
) config.plugins.lsp.servers.ts_ls.extraOptions.init_options.plugins;
message = "Did not expect `@vue/typescript-plugin` plugin.";
})
{
assertion = lib.any (x: x == "typescript") config.plugins.lsp.servers.ts_ls.filetypes;
message = "Expected `typescript` filetype configuration.";
}
];
};
2023-03-22 07:42:02 +01:00
}