mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +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 =
|
||||
let
|
||||
mkMaps =
|
||||
prefix:
|
||||
prefix: descPrefix:
|
||||
mapAttrsToList (
|
||||
key: action:
|
||||
let
|
||||
actionStr = action.action or 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
|
||||
{
|
||||
mode = "n";
|
||||
|
@ -214,13 +206,13 @@ in
|
|||
|
||||
options = {
|
||||
inherit (cfg.keymaps) silent;
|
||||
inherit desc;
|
||||
desc = "${descPrefix} ${actionStr}";
|
||||
} // actionProps;
|
||||
}
|
||||
);
|
||||
in
|
||||
mkMaps "vim.diagnostic." cfg.keymaps.diagnostic
|
||||
++ mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf
|
||||
mkMaps "vim.diagnostic." "Lsp diagnostic" cfg.keymaps.diagnostic
|
||||
++ mkMaps "vim.lsp.buf." "Lsp buf" cfg.keymaps.lspBuf
|
||||
++ cfg.keymaps.extra;
|
||||
|
||||
# Enable inlay-hints
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue