mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 09:48:42 +02:00
plugins/nvim-lsp: keymaps options (#254)
This commit is contained in:
parent
4d4f4d17f7
commit
9d68949da7
2 changed files with 94 additions and 0 deletions
|
@ -16,6 +16,37 @@ in {
|
|||
plugins.lsp = {
|
||||
enable = mkEnableOption "neovim's built-in LSP";
|
||||
|
||||
keymaps = {
|
||||
silent = mkOption {
|
||||
type = types.bool;
|
||||
description = "Whether nvim-lsp keymaps should be silent";
|
||||
default = false;
|
||||
};
|
||||
|
||||
diagnostic = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = "Mappings for `vim.diagnostic.<action>` functions.";
|
||||
example = {
|
||||
"<leader>k" = "goto_prev";
|
||||
"<leader>j" = "goto_next";
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
|
||||
lspBuf = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = "Mappings for `vim.lsp.buf.<action>` functions.";
|
||||
example = {
|
||||
"gd" = "definition";
|
||||
"gD" = "references";
|
||||
"gt" = "type_definition";
|
||||
"gi" = "implementation";
|
||||
"K" = "hover";
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
enabledServers = mkOption {
|
||||
type = with types;
|
||||
listOf (oneOf [
|
||||
|
@ -79,6 +110,30 @@ in {
|
|||
mkIf cfg.enable {
|
||||
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
|
||||
|
||||
maps.normal = let
|
||||
diagnosticMaps =
|
||||
mapAttrs
|
||||
(key: action: {
|
||||
silent = cfg.keymaps.silent;
|
||||
action = "vim.diagnostic.${action}";
|
||||
lua = true;
|
||||
})
|
||||
cfg.keymaps.diagnostic;
|
||||
|
||||
lspBuf =
|
||||
mapAttrs
|
||||
(key: action: {
|
||||
silent = cfg.keymaps.silent;
|
||||
action = "vim.lsp.buf.${action}";
|
||||
lua = true;
|
||||
})
|
||||
cfg.keymaps.lspBuf;
|
||||
in
|
||||
mkMerge [
|
||||
diagnosticMaps
|
||||
lspBuf
|
||||
];
|
||||
|
||||
# Enable all LSP servers
|
||||
extraConfigLua = ''
|
||||
-- LSP {{{
|
||||
|
|
39
tests/plugins/nvim-lsp.nix
Normal file
39
tests/plugins/nvim-lsp.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.lsp.enable = true;
|
||||
};
|
||||
|
||||
test = {
|
||||
plugins.lsp = {
|
||||
enable = true;
|
||||
|
||||
keymaps = {
|
||||
silent = true;
|
||||
diagnostic = {
|
||||
"<leader>k" = "goto_prev";
|
||||
"<leader>j" = "goto_next";
|
||||
};
|
||||
|
||||
lspBuf = {
|
||||
"gd" = "definition";
|
||||
"gD" = "references";
|
||||
"gt" = "type_definition";
|
||||
"gi" = "implementation";
|
||||
"K" = "hover";
|
||||
};
|
||||
};
|
||||
|
||||
servers = {
|
||||
bashls.enable = true;
|
||||
clangd.enable = true;
|
||||
nil_ls.enable = true;
|
||||
rust-analyzer.enable = true;
|
||||
pylsp = {
|
||||
enable = true;
|
||||
filetypes = ["python"];
|
||||
autostart = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue