mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
LSP: Register keymaps on LspAttach
This commit is contained in:
parent
7baefc8aa5
commit
03009d0b99
2 changed files with 82 additions and 27 deletions
|
@ -134,6 +134,35 @@ in {
|
||||||
};
|
};
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extra = mkOption {
|
||||||
|
type = with types; listOf helpers.keymaps.mapOptionSubmodule;
|
||||||
|
description = "Extra keymaps to register on 'LspAttach'.";
|
||||||
|
example = [
|
||||||
|
{
|
||||||
|
key = "<leader>lx";
|
||||||
|
action = "<CMD>LspStop<Enter>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "<leader>ls";
|
||||||
|
action = "<CMD>LspStart<Enter>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "<leader>lr";
|
||||||
|
action = "<CMD>LspRestart<Enter>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "gd";
|
||||||
|
action = "require('telescope.builtin').lsp_definitions()";
|
||||||
|
lua = true;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "K";
|
||||||
|
action = "<CMD>Lspsaga hover_doc<Enter>";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
enabledServers = mkOption {
|
enabledServers = mkOption {
|
||||||
|
@ -231,34 +260,37 @@ in {
|
||||||
mkIf cfg.enable {
|
mkIf cfg.enable {
|
||||||
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
|
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
|
||||||
|
|
||||||
keymaps = let
|
keymapsOnEvents = {
|
||||||
mkMaps = prefix:
|
"LspAttach" = let
|
||||||
mapAttrsToList
|
mkMaps = prefix:
|
||||||
(
|
mapAttrsToList
|
||||||
key: action: let
|
(
|
||||||
actionStr =
|
key: action: let
|
||||||
if isString action
|
actionStr =
|
||||||
then action
|
if isString action
|
||||||
else action.action;
|
then action
|
||||||
actionProps =
|
else action.action;
|
||||||
if isString action
|
actionProps =
|
||||||
then {}
|
if isString action
|
||||||
else filterAttrs (n: v: n != "action") action;
|
then {}
|
||||||
in {
|
else filterAttrs (n: v: n != "action") action;
|
||||||
mode = "n";
|
in {
|
||||||
inherit key;
|
mode = "n";
|
||||||
action.__raw = prefix + actionStr;
|
inherit key;
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
# Enable all LSP servers
|
# Enable all LSP servers
|
||||||
extraConfigLua = ''
|
extraConfigLua = ''
|
||||||
|
|
|
@ -27,6 +27,29 @@
|
||||||
desc = "Hover";
|
desc = "Hover";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extra = [
|
||||||
|
{
|
||||||
|
key = "<leader>li";
|
||||||
|
action = "<CMD>LspInfo<Enter>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "<leader>lx";
|
||||||
|
action = "<CMD>LspStop<Enter>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "<leader>ls";
|
||||||
|
action = "<CMD>LspStart<Enter>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "<leader>lr";
|
||||||
|
action = "<CMD>LspRestart<Enter>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "<leader>ll";
|
||||||
|
action = "<CMD>LspLog<Enter>";
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
servers = {
|
servers = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue