mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-21 19:09:49 +01:00
feat: add lspsaga keybindings
This commit is contained in:
parent
4adb03cd1d
commit
cd98cc29f1
2 changed files with 46 additions and 77 deletions
|
@ -6,41 +6,35 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
self = import ./lspsaga.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim.startPlugins = ["lspsaga"];
|
||||
|
||||
vim.maps.visual = {
|
||||
"<silent><leader>ca" = {action = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";};
|
||||
};
|
||||
vim.maps.visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||
|
||||
vim.maps.normal =
|
||||
{
|
||||
"<silent><leader>lf" = {action = "<cmd>lua require'lspsaga.provider'.lsp_finder()<CR>";};
|
||||
"<silent><leader>lh" = {action = "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>";};
|
||||
"<silent><C-f>" = {action = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>";};
|
||||
"<silent><C-b>" = {action = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>";};
|
||||
"<silent><leader>lr" = {action = "<cmd>lua require'lspsaga.rename'.rename()<CR>";};
|
||||
"<silent><leader>ld" = {action = "<cmd>lua require'lspsaga.provider'.preview_definition()<CR>";};
|
||||
"<silent><leader>ll" = {action = "<cmd>lua require'lspsaga.diagnostic'.show_line_diagnostics()<CR>";};
|
||||
"<silent><leader>lc" = {action = "<cmd>lua require'lspsaga.diagnostic'.show_cursor_diagnostics()<CR>";};
|
||||
"<silent><leader>lp" = {action = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev()<CR>";};
|
||||
"<silent><leader>ln" = {action = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next()<CR>";};
|
||||
}
|
||||
// (
|
||||
if (!cfg.nvimCodeActionMenu.enable)
|
||||
then {
|
||||
"<silent><leader>ca" = {action = "<cmd>lua require('lspsaga.codeaction').code_action()<CR>";};
|
||||
}
|
||||
else {}
|
||||
)
|
||||
// (
|
||||
if (!cfg.lspSignature.enable)
|
||||
then {
|
||||
"<silent><leader>ls" = {action = "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>";};
|
||||
}
|
||||
else {}
|
||||
);
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder")
|
||||
(mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc")
|
||||
|
||||
(mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end")
|
||||
(mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end")
|
||||
|
||||
(mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename")
|
||||
(mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition")
|
||||
|
||||
(mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics")
|
||||
(mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics")
|
||||
|
||||
(mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')")
|
||||
(mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')")
|
||||
|
||||
(mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action"))
|
||||
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
|
||||
];
|
||||
|
||||
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
||||
-- Enable lspsaga
|
||||
|
|
|
@ -1,53 +1,28 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
options.vim.lsp = {lspsaga = {enable = mkEnableOption "LSP Saga";};};
|
||||
with builtins; {
|
||||
options.vim.lsp.lspsaga = {
|
||||
enable = mkEnableOption "LSP Saga";
|
||||
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim.startPlugins = ["lspsaga"];
|
||||
mappings = {
|
||||
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
|
||||
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
|
||||
|
||||
vim.maps.visual = {
|
||||
"<silent><leader>ca" = {action = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";};
|
||||
smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" "<C-f>";
|
||||
smartScrollDown = mkMappingOption "Smart scroll up [LSPSaga]" "<C-b>";
|
||||
|
||||
rename = mkMappingOption "Rename [LSPSaga]" "<leader>lr";
|
||||
previewDefinition = mkMappingOption "Preview definition [LSPSaga]" "<leader>ld";
|
||||
|
||||
showLineDiagnostics = mkMappingOption "Show line diagnostics [LSPSaga]" "<leader>ll";
|
||||
showCursorDiagnostics = mkMappingOption "Show cursor diagnostics [LSPSaga]" "<leader>lc";
|
||||
|
||||
nextDiagnostic = mkMappingOption "Next diagnostic [LSPSaga]" "<leader>ln";
|
||||
previousDiagnostic = mkMappingOption "Previous diagnostic [LSPSaga]" "<leader>lp";
|
||||
|
||||
codeAction = mkMappingOption "Code action [LSPSaga]" "<leader>ca";
|
||||
|
||||
signatureHelp = mkMappingOption "Signature help [LSPSaga]" "<ledaer>ls";
|
||||
};
|
||||
|
||||
vim.maps.normal =
|
||||
{
|
||||
"<silent><leader>lf" = {action = "<cmd>lua require'lspsaga.provider'.lsp_finder()<CR>";};
|
||||
"<silent><leader>lh" = {action = "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>";};
|
||||
"<silent><C-f>" = {action = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>";};
|
||||
"<silent><C-b>" = {action = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>";};
|
||||
"<silent><leader>lr" = {action = "<cmd>lua require'lspsaga.rename'.rename()<CR>";};
|
||||
"<silent><leader>ld" = {action = "<cmd>lua require'lspsaga.provider'.preview_definition()<CR>";};
|
||||
"<silent><leader>ll" = {action = "<cmd>lua require'lspsaga.diagnostic'.show_line_diagnostics()<CR>";};
|
||||
"<silent><leader>lc" = {action = "<cmd>lua require'lspsaga.diagnostic'.show_cursor_diagnostics()<CR>";};
|
||||
"<silent><leader>lp" = {action = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev()<CR>";};
|
||||
"<silent><leader>ln" = {action = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next()<CR>";};
|
||||
}
|
||||
// (
|
||||
if (!cfg.nvimCodeActionMenu.enable)
|
||||
then {
|
||||
"<silent><leader>ca" = {action = "<cmd>lua require('lspsaga.codeaction').code_action()<CR>";};
|
||||
}
|
||||
else {}
|
||||
)
|
||||
// (
|
||||
if (!cfg.lspSignature.enable)
|
||||
then {
|
||||
"<silent><leader>ls" = {action = "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>";};
|
||||
}
|
||||
else {}
|
||||
);
|
||||
|
||||
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
||||
-- Enable lspsaga
|
||||
local saga = require 'lspsaga'
|
||||
saga.init_lsp_saga()
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue