From 3cd56fced459934a67905a4712e6ea7f92569593 Mon Sep 17 00:00:00 2001 From: saygo-png Date: Sun, 28 Sep 2025 00:31:25 +0200 Subject: [PATCH] plugins/nvim-bqf: migrate to mkNeovimPlugin Signed-off-by: saygo-png --- plugins/by-name/nvim-bqf/default.nix | 173 ++---------------- plugins/by-name/nvim-bqf/deprecations.nix | 24 +++ .../plugins/by-name/nvim-bqf/default.nix | 84 +++++++++ 3 files changed, 120 insertions(+), 161 deletions(-) create mode 100644 plugins/by-name/nvim-bqf/deprecations.nix diff --git a/plugins/by-name/nvim-bqf/default.nix b/plugins/by-name/nvim-bqf/default.nix index a6921b8e..5d8e5ac3 100644 --- a/plugins/by-name/nvim-bqf/default.nix +++ b/plugins/by-name/nvim-bqf/default.nix @@ -1,171 +1,22 @@ { lib, - helpers, - config, - pkgs, ... }: -with lib; -let - cfg = config.plugins.nvim-bqf; -in -{ - options.plugins.nvim-bqf = lib.nixvim.plugins.neovim.extraOptionsOptions // { - enable = mkEnableOption "nvim-bqf"; +lib.nixvim.plugins.mkNeovimPlugin { + name = "nvim-bqf"; + description = "Better quickfix window in Neovim, polish old quickfix window."; + moduleName = "bqf"; + maintainers = [ ]; - package = lib.mkPackageOption pkgs "nvim-bqf" { - default = [ - "vimPlugins" - "nvim-bqf" - ]; - }; - - autoEnable = helpers.defaultNullOpts.mkBool true '' - Enable nvim-bqf in quickfix window automatically. - ''; - - magicWindow = helpers.defaultNullOpts.mkBool true '' - Give the window magic, when the window is split horizontally, keep the distance between the - current line and the top/bottom border of neovim unchanged. - It's a bit like a floating window, but the window is indeed a normal window, without any - floating attributes. - ''; - - autoResizeHeight = helpers.defaultNullOpts.mkBool false '' - Resize quickfix window height automatically. - Shrink higher height to size of list in quickfix window, otherwise extend height to size of - list or to default height (10). - ''; + # TODO: introduced 2025-09-27: remove after 26.05 + inherit (import ./deprecations.nix lib) deprecateExtraOptions optionsRenamedToSettings; + settingsExample = { preview = { - autoPreview = helpers.defaultNullOpts.mkBool true '' - Enable preview in quickfix window automatically. - ''; - - borderChars = - helpers.defaultNullOpts.mkListOf types.str - [ - "│" - "│" - "─" - "─" - "╭" - "╮" - "╰" - "╯" - "█" - ] - '' - Border and scroll bar chars, they respectively represent: - vline, vline, hline, hline, ulcorner, urcorner, blcorner, brcorner, sbar - ''; - - showTitle = helpers.defaultNullOpts.mkBool true '' - Show the window title. - ''; - - delaySyntax = helpers.defaultNullOpts.mkInt 50 '' - Delay time, to do syntax for previewed buffer, unit is millisecond. - ''; - - winHeight = helpers.defaultNullOpts.mkInt 15 '' - The height of preview window for horizontal layout. - Large value (like 999) perform preview window as a "full" mode. - ''; - - winVheight = helpers.defaultNullOpts.mkInt 15 '' - The height of preview window for vertical layout. - ''; - - wrap = helpers.defaultNullOpts.mkBool false '' - Wrap the line, `:h wrap` for detail. - ''; - - bufLabel = helpers.defaultNullOpts.mkBool true '' - Add label of current item buffer at the end of the item line. - ''; - - shouldPreviewCb = helpers.defaultNullOpts.mkLuaFn "nil" '' - A callback function to decide whether to preview while switching buffer, with - (bufnr: number, qwinid: number) parameters. - ''; - }; - - funcMap = helpers.mkNullOrOption (types.attrsOf types.str) '' - The table for {function = key}. - - Example (some default values): - funcMap = { - open = ""; - tab = "t"; - sclear = "z"; - }; - ''; - - filter = { - fzf = { - actionFor = { - "ctrl-t" = helpers.defaultNullOpts.mkStr "tabedit" '' - Press ctrl-t to open up the item in a new tab. - ''; - - "ctrl-v" = helpers.defaultNullOpts.mkStr "vsplit" '' - Press ctrl-v to open up the item in a new vertical split. - ''; - - "ctrl-x" = helpers.defaultNullOpts.mkStr "split" '' - Press ctrl-x to open up the item in a new horizontal split. - ''; - - "ctrl-q" = helpers.defaultNullOpts.mkStr "signtoggle" '' - Press ctrl-q to toggle sign for the selected items. - ''; - - "ctrl-c" = helpers.defaultNullOpts.mkStr "closeall" '' - Press ctrl-c to close quickfix window and abort fzf. - ''; - }; - - extraOpts = helpers.defaultNullOpts.mkListOf types.str [ - "--bind" - "ctrl-o:toggle-all" - ] "Extra options for fzf."; - }; + winblend = 0; + show_title = false; + border = "double"; + show_scroll_bar = false; }; }; - - config = - let - options = { - auto_enable = cfg.autoEnable; - magic_window = cfg.magicWindow; - auto_resize_height = cfg.autoResizeHeight; - preview = with cfg.preview; { - auto_preview = autoPreview; - border_chars = borderChars; - show_title = showTitle; - delay_syntax = delaySyntax; - win_height = winHeight; - win_vheight = winVheight; - inherit wrap; - buf_label = bufLabel; - should_preview_cb = shouldPreviewCb; - }; - func_map = cfg.funcMap; - filter = { - fzf = with cfg.filter.fzf; { - action_for = actionFor; - extra_opts = extraOpts; - }; - }; - } - // cfg.extraOptions; - in - mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - - extraConfigLua = '' - require('bqf').setup(${lib.nixvim.toLuaObject options}) - ''; - }; } diff --git a/plugins/by-name/nvim-bqf/deprecations.nix b/plugins/by-name/nvim-bqf/deprecations.nix new file mode 100644 index 00000000..907dd409 --- /dev/null +++ b/plugins/by-name/nvim-bqf/deprecations.nix @@ -0,0 +1,24 @@ +lib: { + deprecateExtraOptions = true; + + optionsRenamedToSettings = map (lib.splitString ".") [ + "autoEnable" + "magicWindow" + "autoResizeHeight" + + "preview.autoPreview" + "preview.borderChars" + "preview.showTitle" + "preview.delaySyntax" + "preview.winHeight" + "preview.winVheight" + "preview.wrap" + "preview.bufLabel" + "preview.shouldPreviewCb" + + "funcMap" + + "filter.fzf.actionFor" + "filter.fzf.extraOpts" + ]; +} diff --git a/tests/test-sources/plugins/by-name/nvim-bqf/default.nix b/tests/test-sources/plugins/by-name/nvim-bqf/default.nix index 3ade56d3..60048ab4 100644 --- a/tests/test-sources/plugins/by-name/nvim-bqf/default.nix +++ b/tests/test-sources/plugins/by-name/nvim-bqf/default.nix @@ -2,4 +2,88 @@ empty = { plugins.nvim-bqf.enable = true; }; + + example = { + plugins.nvim-bqf = { + enable = true; + settings = { + preview = { + winblend = 0; + show_title = false; + border = "double"; + show_scroll_bar = false; + }; + }; + }; + }; + + defaults = { + plugins.nvim-bqf = { + enable = true; + settings = { + auto_enable = true; + magic_window = true; + auto_resize_height = false; + previous_winid_ft_skip.__empty = { }; + preview = { + auto_preview = true; + border = "rounded"; + show_title = true; + show_scroll_bar = true; + delay_syntax = 50; + winblend = 12; + win_height = 15; + win_vheight = 15; + wrap = false; + buf_label = true; + should_preview_cb.__raw = "nil"; + }; + func_map = { + open = ""; + openc = "o"; + drop = "O"; + split = ""; + vsplit = ""; + tab = "t"; + tabb = "T"; + tabc = ""; + tabdrop = ""; + ptogglemode = "zp"; + ptoggleitem = "p"; + ptoggleauto = "P"; + pscrollup = ""; + pscrolldown = ""; + pscrollorig = "zo"; + prevfile = ""; + nextfile = ""; + prevhist = "<"; + nexthist = ">"; + lastleave = "'\""; + stoggleup = ""; + stoggledown = ""; + stogglevm = ""; + stogglebuf = "'"; + sclear = "z"; + filter = "zn"; + filterr = "zN"; + fzffilter = "zf"; + }; + filter = { + fzf = { + action_for = { + "ctrl-t" = "tabedit"; + "ctrl-v" = "vsplit"; + "ctrl-x" = "split"; + "ctrl-q" = "signtoggle"; + "ctrl-c" = "closeall"; + }; + extra_opts = [ + "--bind" + "ctrl-o:toggle-all" + ]; + }; + }; + }; + }; + }; }