mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-27 11:08:53 +02:00
plugins/nvim-lsp: let keymaps actions be attrs
This commit is contained in:
parent
54ebe3b0ee
commit
71c0b4cb59
2 changed files with 29 additions and 22 deletions
|
@ -24,7 +24,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
diagnostic = mkOption {
|
diagnostic = mkOption {
|
||||||
type = types.attrsOf types.str;
|
type = with types; attrsOf (either str attrs);
|
||||||
description = "Mappings for `vim.diagnostic.<action>` functions.";
|
description = "Mappings for `vim.diagnostic.<action>` functions.";
|
||||||
example = {
|
example = {
|
||||||
"<leader>k" = "goto_prev";
|
"<leader>k" = "goto_prev";
|
||||||
|
@ -34,7 +34,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
lspBuf = mkOption {
|
lspBuf = mkOption {
|
||||||
type = types.attrsOf types.str;
|
type = with types; attrsOf (either str attrs);
|
||||||
description = "Mappings for `vim.lsp.buf.<action>` functions.";
|
description = "Mappings for `vim.lsp.buf.<action>` functions.";
|
||||||
example = {
|
example = {
|
||||||
"gd" = "definition";
|
"gd" = "definition";
|
||||||
|
@ -111,27 +111,28 @@ in {
|
||||||
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
|
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
|
||||||
|
|
||||||
maps.normal = let
|
maps.normal = let
|
||||||
diagnosticMaps =
|
mkMaps = prefix:
|
||||||
mapAttrs
|
mapAttrs
|
||||||
(key: action: {
|
(key: action: let
|
||||||
|
actionStr =
|
||||||
|
if isString action
|
||||||
|
then action
|
||||||
|
else action.action;
|
||||||
|
actionProps =
|
||||||
|
if isString action
|
||||||
|
then {}
|
||||||
|
else filterAttrs (n: v: n != "action") action;
|
||||||
|
in
|
||||||
|
{
|
||||||
inherit (cfg.keymaps) silent;
|
inherit (cfg.keymaps) silent;
|
||||||
action = "vim.diagnostic.${action}";
|
action = prefix + actionStr;
|
||||||
lua = true;
|
lua = true;
|
||||||
})
|
}
|
||||||
cfg.keymaps.diagnostic;
|
// actionProps);
|
||||||
|
|
||||||
lspBuf =
|
|
||||||
mapAttrs
|
|
||||||
(key: action: {
|
|
||||||
inherit (cfg.keymaps) silent;
|
|
||||||
action = "vim.lsp.buf.${action}";
|
|
||||||
lua = true;
|
|
||||||
})
|
|
||||||
cfg.keymaps.lspBuf;
|
|
||||||
in
|
in
|
||||||
mkMerge [
|
mkMerge [
|
||||||
diagnosticMaps
|
(mkMaps "vim.diagnostic." cfg.keymaps.diagnostic)
|
||||||
lspBuf
|
(mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf)
|
||||||
];
|
];
|
||||||
|
|
||||||
# Enable all LSP servers
|
# Enable all LSP servers
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
silent = true;
|
silent = true;
|
||||||
diagnostic = {
|
diagnostic = {
|
||||||
"<leader>k" = "goto_prev";
|
"<leader>k" = "goto_prev";
|
||||||
"<leader>j" = "goto_next";
|
"<leader>j" = {
|
||||||
|
action = "goto_next";
|
||||||
|
desc = "Go to next diagnostic";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
lspBuf = {
|
lspBuf = {
|
||||||
|
@ -19,7 +22,10 @@
|
||||||
"gD" = "references";
|
"gD" = "references";
|
||||||
"gt" = "type_definition";
|
"gt" = "type_definition";
|
||||||
"gi" = "implementation";
|
"gi" = "implementation";
|
||||||
"K" = "hover";
|
"K" = {
|
||||||
|
action = "hover";
|
||||||
|
desc = "Hover";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue