plugins/lsp: Reduce indent on attr set and use helpers.mkRaw

This commit is contained in:
Daniel 2024-03-26 13:38:45 +00:00 committed by Gaétan Lepage
parent 03009d0b99
commit e229e3ad44

View file

@ -260,37 +260,35 @@ in {
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig]; extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
keymapsOnEvents = { keymapsOnEvents.LspAttach = let
"LspAttach" = let mkMaps = prefix:
mkMaps = prefix: mapAttrsToList
mapAttrsToList (
( key: action: let
key: action: let actionStr =
actionStr = if isString action
if isString action then action
then action else action.action;
else action.action; actionProps =
actionProps = if isString action
if isString action then {}
then {} else filterAttrs (n: v: n != "action") action;
else filterAttrs (n: v: n != "action") action; in {
in { mode = "n";
mode = "n"; inherit key;
inherit key; action = helpers.mkRaw (prefix + actionStr);
action.__raw = prefix + actionStr;
options = options =
{ {
inherit (cfg.keymaps) silent; inherit (cfg.keymaps) silent;
} }
// actionProps; // actionProps;
} }
); );
in in
(mkMaps "vim.diagnostic." cfg.keymaps.diagnostic) (mkMaps "vim.diagnostic." cfg.keymaps.diagnostic)
++ (mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf) ++ (mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf)
++ cfg.keymaps.extra; ++ cfg.keymaps.extra;
};
# Enable all LSP servers # Enable all LSP servers
extraConfigLua = '' extraConfigLua = ''