-
-
Notifications
You must be signed in to change notification settings - Fork 213
/
nvim-bqf.nix
165 lines (142 loc) · 4.67 KB
/
nvim-bqf.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.nvim-bqf;
in
{
options.plugins.nvim-bqf = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-bqf";
package = helpers.mkPluginPackageOption "nvim-bqf" pkgs.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).
'';
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 = "<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(${helpers.toLuaObject options})
'';
};
}