nix-config/modules/home-manager/nvim/lsp/default.nix

194 lines
5.1 KiB
Nix
Raw Normal View History

2024-03-24 23:39:49 +01:00
{
config,
pkgs,
lib,
...
}: {
options.user.nvim.enable-lsp = lib.mkEnableOption "nvim lsp";
2024-03-24 23:39:49 +01:00
config =
lib.mkIf (config.user.nvim.enable-lsp && config.user.nvim.enable)
2024-03-24 23:39:49 +01:00
{
user.nvim.enable-completions = true;
programs.nixvim = {helpers, ...}: {
2024-03-24 23:39:49 +01:00
plugins.lsp = {
enable = true;
servers = {
2024-12-01 23:18:34 +01:00
basedpyright.enable = true;
2024-03-24 23:39:49 +01:00
bashls.enable = true;
2024-12-01 23:18:34 +01:00
bitbake_language_server.enable = true;
2024-03-24 23:39:49 +01:00
clangd.enable = true;
2024-12-01 23:18:34 +01:00
hls.enable = true;
hls.installGhc = true;
jsonls.enable = true;
lua_ls.enable = true;
2024-12-01 23:18:34 +01:00
marksman.enable = true;
nil_ls.enable = true;
nil_ls.settings.formatting.command = ["alejandra"];
2024-03-24 23:39:49 +01:00
nushell.enable = true;
2024-12-01 23:18:34 +01:00
ruff.enable = true;
taplo.enable = true;
2024-03-24 23:39:49 +01:00
texlab.enable = true;
typst_lsp.enable = true;
2024-12-01 23:18:34 +01:00
uiua.enable = true;
2024-03-24 23:39:49 +01:00
yamlls.enable = true;
2024-12-01 23:18:34 +01:00
zls.enable = true;
2024-03-24 23:39:49 +01:00
};
};
plugins.cmp.settings.sources = [
{name = "nvim_lsp";}
];
2024-07-31 17:26:59 +02:00
plugins.which-key.settings.spec = [
{
__unkeyed-1 = "<leader>l";
group = "+lsp";
}
];
2024-03-24 23:39:49 +01:00
keymaps = [
{
action = helpers.mkRaw "vim.lsp.buf.declaration";
2024-03-24 23:39:49 +01:00
key = "<leader>lc";
mode = "n";
options = {
silent = true;
desc = "declaration";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.definition";
2024-03-24 23:39:49 +01:00
key = "<leader>ld";
mode = "n";
options = {
silent = true;
desc = "definition";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.hover";
2024-03-24 23:39:49 +01:00
key = "<leader>lh";
mode = "n";
options = {
silent = true;
desc = "hover";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.implementation";
2024-03-24 23:39:49 +01:00
key = "<leader>li";
mode = "n";
options = {
silent = true;
desc = "implementation";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.signature_help";
2024-03-24 23:39:49 +01:00
key = "<leader>ls";
mode = "n";
options = {
silent = true;
desc = "signature_help";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.add_workspace_folder";
2024-03-24 23:39:49 +01:00
key = "<leader>lwa";
mode = "n";
options = {
silent = true;
desc = "add folder";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.remove_workspace_folder";
2024-03-24 23:39:49 +01:00
key = "<leader>lwr";
mode = "n";
options = {
silent = true;
desc = "remove folder";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.list_workspace_folders";
2024-03-24 23:39:49 +01:00
key = "<leader>lw";
mode = "n";
options = {
silent = true;
desc = "workspace";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.rename";
2024-03-24 23:39:49 +01:00
key = "<leader>lr";
mode = "n";
options = {
silent = true;
desc = "rename";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.code_action";
2024-03-24 23:39:49 +01:00
key = "<leader>la";
mode = "n";
options = {
silent = true;
desc = "code action";
};
}
{
action = helpers.mkRaw "vim.lsp.buf.references";
2024-03-24 23:39:49 +01:00
key = "<leader>le";
mode = "n";
options = {
silent = true;
desc = "list references";
};
}
{
action = helpers.mkRaw "function() vim.lsp.buf.format{async=true} end";
2024-03-24 23:39:49 +01:00
key = "<leader>lm";
mode = "n";
options = {
silent = true;
desc = "format buffer";
};
}
{
action = helpers.mkRaw "vim.diagnostic.open_float";
2024-03-24 23:39:49 +01:00
key = "<leader>lo";
mode = "n";
options = {
silent = true;
desc = "open float";
};
}
{
action = helpers.mkRaw "vim.diagnostic.goto_next";
2024-03-24 23:39:49 +01:00
key = "]d";
mode = "n";
options = {
silent = true;
desc = "next diagnostic";
};
}
{
action = helpers.mkRaw "vim.diagnostic.goto_prev";
2024-03-24 23:39:49 +01:00
key = "[d";
mode = "n";
options = {
silent = true;
desc = "prev diagnostic";
};
}
];
};
home.packages = with pkgs; [
alejandra
];
};
2024-03-25 04:56:01 +01:00
imports = [
2024-11-06 14:00:50 +01:00
./rustaceanvim.nix
2024-03-25 04:56:01 +01:00
./clangd.nix
];
2024-03-24 23:39:49 +01:00
}