-
-
Notifications
You must be signed in to change notification settings - Fork 213
/
better-escape.nix
64 lines (55 loc) · 1.63 KB
/
better-escape.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
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.better-escape;
in
{
options.plugins.better-escape = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "better-escape.nvim";
package = helpers.mkPluginPackageOption "better-escape.nvim" pkgs.vimPlugins.better-escape-nvim;
mapping = helpers.mkNullOrOption (with types; listOf str) ''
List of mappings to use to enter escape mode.
'';
timeout = helpers.defaultNullOpts.mkStrLuaOr types.ints.unsigned "vim.o.timeoutlen" ''
The time in which the keys must be hit in ms.
Uses the value of `vim.o.timeoutlen` (`options.timeoutlen` in nixvim) by default.
'';
clearEmptyLines = helpers.defaultNullOpts.mkBool false ''
Clear line after escaping if there is only whitespace.
'';
keys =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua) "<ESC>"
''
Keys used for escaping, if it is a function will use the result everytime.
Example (recommended):
keys.__raw = \'\'
function()
return vim.api.nvim_win_get_cursor(0)[2] > 1 and '<esc>l' or '<esc>'
end
\'\';
'';
};
config =
let
setupOptions =
with cfg;
{
inherit mapping timeout;
clear_empty_lines = clearEmptyLines;
inherit keys;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('better_escape').setup(${helpers.toLuaObject setupOptions})
'';
};
}