mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
plugin/lsp: simplify automatic keymap description
Do not create description prefix generically, but use extra argument for `mkMaps`. Change-Id: Id08297623edf750d8f33eb031748668be0c8bfa5
This commit is contained in:
parent
d867aaea43
commit
3c6dd42ff8
1 changed files with 4 additions and 12 deletions
|
@ -192,20 +192,12 @@ in
|
||||||
keymapsOnEvents.LspAttach =
|
keymapsOnEvents.LspAttach =
|
||||||
let
|
let
|
||||||
mkMaps =
|
mkMaps =
|
||||||
prefix:
|
prefix: descPrefix:
|
||||||
mapAttrsToList (
|
mapAttrsToList (
|
||||||
key: action:
|
key: action:
|
||||||
let
|
let
|
||||||
actionStr = action.action or action;
|
actionStr = action.action or action;
|
||||||
actionProps = optionalAttrs (isAttrs action) (removeAttrs action [ "action" ]);
|
actionProps = optionalAttrs (isAttrs action) (removeAttrs action [ "action" ]);
|
||||||
desc =
|
|
||||||
let
|
|
||||||
split = splitString "." prefix;
|
|
||||||
splitlen = length split;
|
|
||||||
prefixFinal = (elemAt split (splitlen - 2)) + " ";
|
|
||||||
optPrefix = optionalString (splitlen > 2) prefixFinal;
|
|
||||||
in
|
|
||||||
"Lsp " + optPrefix + actionStr;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
mode = "n";
|
mode = "n";
|
||||||
|
@ -214,13 +206,13 @@ in
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
inherit (cfg.keymaps) silent;
|
inherit (cfg.keymaps) silent;
|
||||||
inherit desc;
|
desc = "${descPrefix} ${actionStr}";
|
||||||
} // actionProps;
|
} // actionProps;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
mkMaps "vim.diagnostic." cfg.keymaps.diagnostic
|
mkMaps "vim.diagnostic." "Lsp diagnostic" cfg.keymaps.diagnostic
|
||||||
++ mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf
|
++ mkMaps "vim.lsp.buf." "Lsp buf" cfg.keymaps.lspBuf
|
||||||
++ cfg.keymaps.extra;
|
++ cfg.keymaps.extra;
|
||||||
|
|
||||||
# Enable inlay-hints
|
# Enable inlay-hints
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue