lsp/lspsaga: convert setupOpts format

This commit is contained in:
raf 2025-03-17 20:25:57 +03:00
parent bc978c4fad
commit 0367f490ba
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
3 changed files with 24 additions and 12 deletions

View file

@ -66,6 +66,9 @@
- Add [snacks.nvim] under `vim.utility.snacks-nvim` as a general-purpose utility - Add [snacks.nvim] under `vim.utility.snacks-nvim` as a general-purpose utility
plugin. plugin.
- Move LSPSaga to `setupOpts` format, allowing freeform configuration in
`vim.lsp.lspsaga.setupOpts`.
[amadaluzia](https://github.com/amadaluzia): [amadaluzia](https://github.com/amadaluzia):
[haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim

View file

@ -4,12 +4,12 @@
... ...
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.strings) optionalString;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.lsp; cfg = config.vim.lsp;
self = import ./lspsaga.nix {inherit lib;}; self = import ./lspsaga.nix {inherit config lib;};
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings; mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions; mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
@ -18,6 +18,10 @@ in {
vim = { vim = {
startPlugins = ["lspsaga-nvim"]; startPlugins = ["lspsaga-nvim"];
pluginRC.lspsaga = entryAnywhere ''
require('lspsaga').init_lsp_saga(${toLuaObject cfg.lspsaga.setupOpts})
'';
maps = { maps = {
visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action"; visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
normal = mkMerge [ normal = mkMerge [
@ -40,14 +44,6 @@ in {
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help")) (mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
]; ];
}; };
pluginRC.lspsaga = entryAnywhere ''
require('lspsaga').init_lsp_saga({
${optionalString config.vim.ui.borders.plugins.lspsaga.enable ''
border_style = '${config.vim.ui.borders.plugins.lspsaga.style}',
''}
})
'';
}; };
}; };
} }

View file

@ -1,10 +1,23 @@
{lib, ...}: let {
inherit (lib.options) mkEnableOption; config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) borderType mkPluginSetupOption;
in { in {
options.vim.lsp.lspsaga = { options.vim.lsp.lspsaga = {
enable = mkEnableOption "LSP Saga"; enable = mkEnableOption "LSP Saga";
setupOpts = mkPluginSetupOption "lspsaga" {
border_style = mkOption {
type = borderType;
default = config.vim.ui.borders.globalStyle;
description = "Border type, see {command}`:help nvim_open_win`";
};
};
mappings = { mappings = {
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf"; lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh"; renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";