-
-
Notifications
You must be signed in to change notification settings - Fork 203
/
nvim-autopairs.nix
208 lines (175 loc) · 5.32 KB
/
nvim-autopairs.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "nvim-autopairs";
defaultPackage = pkgs.vimPlugins.nvim-autopairs;
maintainers = [ maintainers.GaetanLepage ];
# TODO: introduced 2024-03-27, remove on 2024-05-27
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"disableInMacro"
"disableInVisualblock"
"disableInReplaceMode"
"ignoredNextChar"
"enableMoveright"
"enableCheckBracketLine"
"enableBracketInQuote"
"enableAbbr"
"breakUndo"
"checkTs"
"tsConfig"
"mapCr"
"mapBs"
"mapCH"
"mapCW"
];
imports =
let
basePluginPaths = [
"plugins"
"nvim-autopairs"
];
settingsPath = basePluginPaths ++ [ "settings" ];
in
[
(mkRenamedOptionModule (basePluginPaths ++ [ "disabledFiletypes" ]) (
settingsPath ++ [ "disable_filetype" ]
))
(mkRenamedOptionModule (basePluginPaths ++ [ "enableAfterQuote" ]) (
settingsPath ++ [ "enable_afterquote" ]
))
(mkRemovedOptionModule (basePluginPaths ++ [ "pairs" ]) ''
This option was having no effect.
If you want to customize pairs, please use `extraConfigLua` to define them as described in the plugin documentation.
'')
];
settingsOptions = {
disable_filetype = helpers.defaultNullOpts.mkListOf types.str [
"TelescopePrompt"
"spectre_panel"
] "Disabled filetypes.";
disable_in_macro = helpers.defaultNullOpts.mkBool false ''
Disable when recording or executing a macro.
'';
disable_in_visualblock = helpers.defaultNullOpts.mkBool false ''
Disable when insert after visual block mode.
'';
disable_in_replace_mode = helpers.defaultNullOpts.mkBool true ''
Disable in replace mode.
'';
ignored_next_char = helpers.defaultNullOpts.mkLua "[=[[%w%%%'%[%\"%.%`%$]]=]" ''
Regexp to ignore if it matches the next character.
'';
enable_moveright = helpers.defaultNullOpts.mkBool true ''
Enable moveright.
'';
enable_afterquote = helpers.defaultNullOpts.mkBool true ''
Add bracket pairs after quote.
'';
enable_check_bracket_line = helpers.defaultNullOpts.mkBool true ''
Check bracket in same line.
'';
enable_bracket_in_quote = helpers.defaultNullOpts.mkBool true ''
Enable bracket in quote.
'';
enable_abbr = helpers.defaultNullOpts.mkBool false ''
Trigger abbreviation.
'';
break_undo = helpers.defaultNullOpts.mkBool true ''
Switch for basic rule break undo sequence.
'';
check_ts = helpers.defaultNullOpts.mkBool false ''
Use treesitter to check for a pair.
'';
ts_config = helpers.defaultNullOpts.mkAttrsOf types.anything {
lua = [
"string"
"source"
"string_content"
];
javascript = [
"string"
"template_string"
];
} "Configuration for TreeSitter.";
map_cr = helpers.defaultNullOpts.mkBool true ''
Map the `<CR>` key to confirm the completion.
'';
map_bs = helpers.defaultNullOpts.mkBool true ''
Map the `<BS>` key to delete the pair.
'';
map_c_h = helpers.defaultNullOpts.mkBool false ''
Map the `<C-h>` key to delete a pair.
'';
map_c_w = helpers.defaultNullOpts.mkBool false ''
Map the `<C-w>` key to delete a pair if possible.
'';
fast_wrap = {
map = helpers.defaultNullOpts.mkStr "<M-e>" ''
The key to trigger fast_wrap.
'';
chars =
helpers.defaultNullOpts.mkListOf types.str
[
"{"
"["
"("
"\""
"'"
]
''
Characters for which to enable fast wrap.
'';
pattern = helpers.defaultNullOpts.mkLua ''[=[[%'%"%>%]%)%}%,%`]]=]'' ''
The pattern to match against.
'';
end_key = helpers.defaultNullOpts.mkStr "$" ''
End key.
'';
before_key = helpers.defaultNullOpts.mkStr "h" ''
Before key.
'';
after_key = helpers.defaultNullOpts.mkStr "l" ''
After key.
'';
cursor_pos_before = helpers.defaultNullOpts.mkBool true ''
Whether the cursor should be placed before or after the substitution.
'';
keys = helpers.defaultNullOpts.mkStr "qwertyuiopzxcvbnmasdfghjkl" '''';
highlight = helpers.defaultNullOpts.mkStr "Search" ''
Which highlight group to use for the match.
'';
highlight_grey = helpers.defaultNullOpts.mkStr "Comment" ''
Which highlight group to use for the grey part.
'';
manual_position = helpers.defaultNullOpts.mkBool true ''
Whether to enable manual position.
'';
use_virt_lines = helpers.defaultNullOpts.mkBool true ''
Whether to use `virt_lines`.
'';
};
};
settingsExample = {
disable_filetype = [ "TelescopePrompt" ];
fast_wrap = {
map = "<M-e>";
end_key = "$";
};
};
extraConfig = cfg: {
warnings =
optional
((isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable)
''
Nixvim (plugins.nvim-autopairs): You have set `settings.check_ts` to `true` but have not enabled the treesitter plugin.
We suggest you to set `plugins.treesitter.enable` to `true`.
'';
};
}