mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-08 19:46:06 +01:00
plugins/nvim-bqf: migrate to mkNeovimPlugin
Signed-off-by: saygo-png <saygo.mail@proton.me>
This commit is contained in:
parent
efa43aa866
commit
3cd56fced4
3 changed files with 120 additions and 161 deletions
|
|
@ -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.
|
||||
'';
|
||||
winblend = 0;
|
||||
show_title = false;
|
||||
border = "double";
|
||||
show_scroll_bar = false;
|
||||
};
|
||||
|
||||
funcMap = helpers.mkNullOrOption (types.attrsOf types.str) ''
|
||||
The table for {function = key}.
|
||||
|
||||
Example (some default values):
|
||||
funcMap = {
|
||||
open = "<CR>";
|
||||
tab = "t";
|
||||
sclear = "z<Tab>";
|
||||
};
|
||||
'';
|
||||
|
||||
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.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
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})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
24
plugins/by-name/nvim-bqf/deprecations.nix
Normal file
24
plugins/by-name/nvim-bqf/deprecations.nix
Normal file
|
|
@ -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"
|
||||
];
|
||||
}
|
||||
|
|
@ -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 = "<CR>";
|
||||
openc = "o";
|
||||
drop = "O";
|
||||
split = "<C-x>";
|
||||
vsplit = "<C-v>";
|
||||
tab = "t";
|
||||
tabb = "T";
|
||||
tabc = "<C-t>";
|
||||
tabdrop = "";
|
||||
ptogglemode = "zp";
|
||||
ptoggleitem = "p";
|
||||
ptoggleauto = "P";
|
||||
pscrollup = "<C-b>";
|
||||
pscrolldown = "<C-f>";
|
||||
pscrollorig = "zo";
|
||||
prevfile = "<C-p>";
|
||||
nextfile = "<C-n>";
|
||||
prevhist = "<";
|
||||
nexthist = ">";
|
||||
lastleave = "'\"";
|
||||
stoggleup = "<S-Tab>";
|
||||
stoggledown = "<Tab>";
|
||||
stogglevm = "<Tab>";
|
||||
stogglebuf = "'<Tab>";
|
||||
sclear = "z<Tab>";
|
||||
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"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue