diff --git a/docs/manual/configuring/custom-plugins/configuring.md b/docs/manual/configuring/custom-plugins/configuring.md index c0935f03..5106d29b 100644 --- a/docs/manual/configuring/custom-plugins/configuring.md +++ b/docs/manual/configuring/custom-plugins/configuring.md @@ -67,7 +67,7 @@ of individual sections of configuration as needed. nvf provides helper functions in the extended library, usually under `inputs.nvf.lib.nvim.dag` that you may use. -Please refer to the [DAG section](/index.xhtml#ch-dag-entries) in the nvf manual +Please refer to the [DAG section](#ch-dag-entries) in the nvf manual to find out more about the DAG system. ::: diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 22bc0c43..c84ef199 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -2,17 +2,25 @@ ## Breaking changes +[Lspsaga documentation]: https://nvimdev.github.io/lspsaga/ + - `git-conflict` keybinds are now prefixed with `` to avoid conflicting with builtins. - `alpha` is now configured with nix, default config removed. +- Lspsaga module no longer ships default keybindings. The keybind format has + been changed by upstream, and old keybindings do not have equivalents under + the new API they provide. Please manually set your keybinds according to + [Lspsaga documentation] following the new API. + [NotAShelf](https://github.com/notashelf): [typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim [render-markdown.nvim]: https://github.com/MeanderingProgrammer/render-markdown.nvim [yanky.nvim]: https://github.com/gbprod/yanky.nvim [yazi.nvim]: https://github.com/mikavilpas/yazi.nvim +[snacks.nvim]: https://github.com/folke/snacks.nvim - Add [typst-preview.nvim] under `languages.typst.extensions.typst-preview-nvim`. @@ -62,6 +70,14 @@ - Add [yazi.nvim] as a companion plugin for Yazi, the terminal file manager. +- Add [snacks.nvim] under `vim.utility.snacks-nvim` as a general-purpose utility + plugin. + +- Move LSPSaga to `setupOpts` format, allowing freeform configuration in + `vim.lsp.lspsaga.setupOpts`. + +- Lazyload Lspsaga and remove default keybindings for it. + [amadaluzia](https://github.com/amadaluzia): [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim diff --git a/flake.lock b/flake.lock index 72912dee..3ced812a 100644 --- a/flake.lock +++ b/flake.lock @@ -38,11 +38,11 @@ }, "mnw": { "locked": { - "lastModified": 1741647548, - "narHash": "sha256-UqVAeOylufUGIx7BXSneFHD8eI6n0sVwEY2noFENnSE=", + "lastModified": 1742255973, + "narHash": "sha256-XfEGVKatTgEMMOVb4SNp1LYLQOSzzrFTDMVDTZFyMVE=", "owner": "Gerg-L", "repo": "mnw", - "rev": "3fb89e600e26b91d1795cf8a1a34e11e084b4a04", + "rev": "b982dbd5e6d55d4438832b3567c09bc2a129649d", "type": "github" }, "original": { diff --git a/modules/plugins/completion/blink-cmp/blink-cmp.nix b/modules/plugins/completion/blink-cmp/blink-cmp.nix index a2171552..f5e38ed1 100644 --- a/modules/plugins/completion/blink-cmp/blink-cmp.nix +++ b/modules/plugins/completion/blink-cmp/blink-cmp.nix @@ -1,6 +1,6 @@ {lib, ...}: let inherit (lib.options) mkEnableOption mkOption literalMD; - inherit (lib.types) listOf str either attrsOf submodule enum anything int nullOr; + inherit (lib.types) bool listOf str either attrsOf submodule enum anything int nullOr; inherit (lib.generators) mkLuaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline pluginType; inherit (lib.nvim.binds) mkMappingOption; @@ -64,6 +64,12 @@ in { default = []; description = "List of sources to enable for cmdline. Null means use default source list."; }; + + keymap = mkOption { + type = keymapType; + default = {}; + description = "blink.cmp cmdline keymap"; + }; }; completion = { @@ -75,6 +81,16 @@ in { description = "Delay before auto show triggers"; }; }; + + menu.auto_show = mkOption { + type = bool; + default = true; + description = '' + Manages the appearance of the completion menu. You may prevent the menu + from automatically showing by this option to `false` and manually showing + it with the show keymap command. + ''; + }; }; keymap = mkOption { @@ -104,7 +120,25 @@ in { fuzzy = { prebuilt_binaries = { download = mkBool false '' - Auto-downloads prebuilt binaries. Do not enable, it doesn't work on nix + Auto-downloads prebuilt binaries. + + ::: .{warning} + Do not enable this option, as it does **not work** on Nix! + ::: + ''; + }; + + implementation = mkOption { + type = enum ["lua" "prefer_rust" "rust" "prefer_rust_with_warning"]; + default = "prefer_rust"; + description = '' + fuzzy matcher implementation for Blink. + + * `"lua"`: slower, Lua native fuzzy matcher implementation + * `"rust": use the SIMD fuzzy matcher, 'frizbee' + * `"prefer_rust"`: use the rust implementation, but fall back to lua + * `"prefer_rust_with_warning"`: use the rust implementation, and fall back to lua + if it is not available after emitting a warning. ''; }; }; @@ -123,12 +157,14 @@ in { sourcePlugins = let sourcePluginType = submodule { options = { + enable = mkEnableOption "this source"; package = mkOption { type = pluginType; description = '' `blink-cmp` source plugin package. ''; }; + module = mkOption { type = str; description = '' @@ -137,7 +173,6 @@ in { Should be present in the source's documentation. ''; }; - enable = mkEnableOption "this source"; }; }; in diff --git a/modules/plugins/diagnostics/nvim-lint/config.nix b/modules/plugins/diagnostics/nvim-lint/config.nix index dac2c2f4..49517f72 100644 --- a/modules/plugins/diagnostics/nvim-lint/config.nix +++ b/modules/plugins/diagnostics/nvim-lint/config.nix @@ -13,7 +13,7 @@ in { vim = { startPlugins = ["nvim-lint"]; pluginRC.nvim-lint = entryAnywhere '' - require("lint").setup(${toLuaObject cfg.setupOpts}) + require("lint").linters_by_ft(${toLuaObject cfg.linters_by_ft}) ''; }; }; diff --git a/modules/plugins/diagnostics/nvim-lint/nvim-lint.nix b/modules/plugins/diagnostics/nvim-lint/nvim-lint.nix index 2211211e..b08d82be 100644 --- a/modules/plugins/diagnostics/nvim-lint/nvim-lint.nix +++ b/modules/plugins/diagnostics/nvim-lint/nvim-lint.nix @@ -1,27 +1,25 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) attrsOf listOf str; - inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.diagnostics.nvim-lint = { enable = mkEnableOption "asynchronous linter plugin for Neovim [nvim-lint]"; - setupOpts = mkPluginSetupOption "nvim-lint" { - linters_by_ft = mkOption { - type = attrsOf (listOf str); - default = {}; - example = { - text = ["vale"]; - markdown = ["vale"]; - }; - description = '' - Map of filetype to formatters. This option takes a set of - `key = value` format where the `value` will be converted - to its Lua equivalent. You are responsible for passing the - correct Nix data types to generate a correct Lua value that - conform is able to accept. - ''; + # nvim-lint does not have a setup table. + linters_by_ft = mkOption { + type = attrsOf (listOf str); + default = {}; + example = { + text = ["vale"]; + markdown = ["vale"]; }; + description = '' + Map of filetype to formatters. This option takes a set of `key = value` + format where the `value` will be converted to its Lua equivalent + through `toLuaObject. You are responsible for passing the correct Nix + data types to generate a correct Lua value that conform is able to + accept. + ''; }; }; } diff --git a/modules/plugins/lsp/lspsaga/config.nix b/modules/plugins/lsp/lspsaga/config.nix index 3af6b7f1..811d0178 100644 --- a/modules/plugins/lsp/lspsaga/config.nix +++ b/modules/plugins/lsp/lspsaga/config.nix @@ -3,51 +3,24 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.strings) optionalString; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; + inherit (lib.modules) mkIf mkDefault; 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-nvim"]; + lazy.plugins.lspsaga-nvim = { + package = "lspsaga-nvim"; + setupModule = "lspsaga"; + inherit (cfg.lspsaga) setupOpts; - maps = { - visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action"; - 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')") - - (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action") - (mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help")) - ]; + event = ["LspAttach"]; }; - 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}', - ''} - }) - ''; + # Optional dependencies, pretty useful to enhance default functionality of + # Lspsaga. + treesitter.enable = mkDefault true; + visuals.nvim-web-devicons.enable = mkDefault true; }; }; } diff --git a/modules/plugins/lsp/lspsaga/lspsaga.nix b/modules/plugins/lsp/lspsaga/lspsaga.nix index f308aaaa..39ce6298 100644 --- a/modules/plugins/lsp/lspsaga/lspsaga.nix +++ b/modules/plugins/lsp/lspsaga/lspsaga.nix @@ -1,29 +1,32 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; - inherit (lib.nvim.binds) mkMappingOption; +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.nvim.types) borderType mkPluginSetupOption; in { + imports = [ + (mkRemovedOptionModule ["vim" "lsp" "lspsaga" "mappings"] '' + Lspsaga mappings have been removed from nvf, as the original author has made + very drastic changes to the API after taking back ownership, and the fork we + used is now archived. Please refer to Lspsaga documentation to add keybinds + for functionality you have used. + + + '') + ]; + options.vim.lsp.lspsaga = { enable = mkEnableOption "LSP Saga"; - mappings = { - lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "lf"; - renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "lh"; - - smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" ""; - smartScrollDown = mkMappingOption "Smart scroll up [LSPSaga]" ""; - - rename = mkMappingOption "Rename [LSPSaga]" "lr"; - previewDefinition = mkMappingOption "Preview definition [LSPSaga]" "ld"; - - showLineDiagnostics = mkMappingOption "Show line diagnostics [LSPSaga]" "ll"; - showCursorDiagnostics = mkMappingOption "Show cursor diagnostics [LSPSaga]" "lc"; - - nextDiagnostic = mkMappingOption "Next diagnostic [LSPSaga]" "ln"; - previousDiagnostic = mkMappingOption "Previous diagnostic [LSPSaga]" "lp"; - - codeAction = mkMappingOption "Code action [LSPSaga]" "ca"; - - signatureHelp = mkMappingOption "Signature help [LSPSaga]" "ls"; + setupOpts = mkPluginSetupOption "lspsaga" { + border_style = mkOption { + type = borderType; + default = config.vim.ui.borders.globalStyle; + description = "Border type, see {command}`:help nvim_open_win`"; + }; }; }; } diff --git a/modules/plugins/minimap/minimap-vim/config.nix b/modules/plugins/minimap/minimap-vim/config.nix index 5276a426..a39b9590 100644 --- a/modules/plugins/minimap/minimap-vim/config.nix +++ b/modules/plugins/minimap/minimap-vim/config.nix @@ -10,13 +10,13 @@ cfg = config.vim.minimap.minimap-vim; in { config = mkIf cfg.enable { - vim.startPlugins = [ - pkgs.code-minimap - "minimap-vim" - ]; + vim = { + startPlugins = ["minimap-vim"]; + extraPackages = [pkgs.code-minimap]; - vim.binds.whichKey.register = pushDownDefault { - "m" = "+Minimap"; + binds.whichKey.register = pushDownDefault { + "m" = "+Minimap"; + }; }; }; } diff --git a/modules/plugins/utility/default.nix b/modules/plugins/utility/default.nix index a1574b97..cbe776cc 100644 --- a/modules/plugins/utility/default.nix +++ b/modules/plugins/utility/default.nix @@ -17,6 +17,7 @@ ./nix-develop ./outline ./preview + ./snacks-nvim ./surround ./telescope ./wakatime diff --git a/modules/plugins/utility/snacks-nvim/config.nix b/modules/plugins/utility/snacks-nvim/config.nix new file mode 100644 index 00000000..e726e3e2 --- /dev/null +++ b/modules/plugins/utility/snacks-nvim/config.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAnywhere; + + cfg = config.vim.utility.snacks-nvim; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["snacks-nvim"]; + pluginRC.snacks-nvim = entryAnywhere '' + require("snacks").setup(${toLuaObject cfg.setupOpts}); + ''; + }; + }; +} diff --git a/modules/plugins/utility/snacks-nvim/default.nix b/modules/plugins/utility/snacks-nvim/default.nix new file mode 100644 index 00000000..8a712baa --- /dev/null +++ b/modules/plugins/utility/snacks-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./snacks-nvim.nix + ]; +} diff --git a/modules/plugins/utility/snacks-nvim/snacks-nvim.nix b/modules/plugins/utility/snacks-nvim/snacks-nvim.nix new file mode 100644 index 00000000..30fd6f89 --- /dev/null +++ b/modules/plugins/utility/snacks-nvim/snacks-nvim.nix @@ -0,0 +1,12 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.utility.snacks-nvim = { + enable = mkEnableOption '' + collection of QoL plugins for Neovim [snacks-nvim] + ''; + + setupOpts = mkPluginSetupOption "snacks-nvim" {}; + }; +} diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index d145f798..3c778169 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -6,9 +6,8 @@ ... }: let inherit (pkgs) vimPlugins; - inherit (lib.strings) isString; - inherit (lib.lists) filter map; - inherit (builtins) path; + inherit (lib.trivial) flip; + inherit (builtins) path filter isString; getPin = name: ((pkgs.callPackages ../../../npins/sources.nix {}) // config.vim.pluginOverrides).${name}; @@ -76,13 +75,6 @@ buildConfigPlugins config.vim.optPlugins ); - # additional Lua and Python3 packages, mapped to their respective functions - # to conform to the format mnw expects. end user should - # only ever need to pass a list of packages, which are modified - # here - extraLuaPackages = ps: map (x: ps.${x}) config.vim.luaPackages; - extraPython3Packages = ps: map (x: ps.${x}) config.vim.python3Packages; - # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to # generate a wrapped Neovim package. neovim-wrapped = inputs.mnw.lib.wrap pkgs { @@ -92,9 +84,17 @@ extraBinPath = config.vim.extraPackages; initLua = config.vim.builtLuaConfigRC; luaFiles = config.vim.extraLuaFiles; + providers = { + python3 = { + enable = config.vim.withPython3; + extraPackages = ps: map (flip builtins.getAttr ps) config.vim.python3Packages; + }; + ruby.enable = config.vim.withRuby; + nodeJs.enable = config.vim.withNodeJs; + }; + aliases = lib.optional config.vim.viAlias "vi" ++ lib.optional config.vim.vimAlias "vim"; - inherit (config.vim) viAlias vimAlias withRuby withNodeJs withPython3; - inherit extraLuaPackages extraPython3Packages; + extraLuaPackages = ps: map (flip builtins.getAttr ps) config.vim.luaPackages; }; dummyInit = pkgs.writeText "nvf-init.lua" config.vim.builtLuaConfigRC; diff --git a/npins/sources.json b/npins/sources.json index 54256514..91c3f68e 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -717,13 +717,13 @@ "type": "Git", "repository": { "type": "GitHub", - "owner": "tami5", + "owner": "nvimdev", "repo": "lspsaga.nvim" }, "branch": "main", - "revision": "5faeec9f2508d2d49a66c0ac0d191096b4e3fa81", - "url": "https://github.com/tami5/lspsaga.nvim/archive/5faeec9f2508d2d49a66c0ac0d191096b4e3fa81.tar.gz", - "hash": "1bw71db69na2sriv9q167z9bgkir4nwny1bdfv9z606bmng4hhzc" + "revision": "6063935cf68de9aa6dd79f8e1caf5df0a9385de3", + "url": "https://github.com/nvimdev/lspsaga.nvim/archive/6063935cf68de9aa6dd79f8e1caf5df0a9385de3.tar.gz", + "hash": "1pqasjg2f2yd3ci8hyxfqqs7xnkmwdc411dlm6qg1agiv1h8v205" }, "lua-utils-nvim": { "type": "Git", @@ -1989,16 +1989,19 @@ "hash": "0k1xnyvblshn4fhbxgl0i34j22n55xlwr09sdmb23l57br5rb07q" }, "snacks-nvim": { - "type": "Git", + "type": "GitRelease", "repository": { "type": "GitHub", "owner": "folke", "repo": "snacks.nvim" }, - "branch": "main", - "revision": "bc0630e43be5699bb94dadc302c0d21615421d93", - "url": "https://github.com/folke/snacks.nvim/archive/bc0630e43be5699bb94dadc302c0d21615421d93.tar.gz", - "hash": "0a5nw7xa33shag1h12gf930g3vcixbwk8dxv0ji4980ycskh238v" + "pre_releases": false, + "version_upper_bound": null, + "release_prefix": null, + "version": "v2.22.0", + "revision": "5eac729fa290248acfe10916d92a5ed5e5c0f9ed", + "url": "https://api.github.com/repos/folke/snacks.nvim/tarball/v2.22.0", + "hash": "1hbm4fnw51qdp0nz83fcxbvnxjq2k57a37w6dp0wz6wkcx7cwxw9" }, "sqls-nvim": { "type": "Git", @@ -2218,4 +2221,4 @@ } }, "version": 3 -} +} \ No newline at end of file