nix-community.nixvim/plugins/utils/autoclose.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

88 lines
2.5 KiB
Nix
Raw Normal View History

2024-02-03 05:33:10 -06:00
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.autoclose;
in
{
2024-02-03 12:45:00 +01:00
meta.maintainers = [ maintainers.GaetanLepage ];
2024-02-03 05:33:10 -06:00
options.plugins.autoclose = {
2024-02-03 12:45:00 +01:00
enable = mkEnableOption "autoclose.nvim";
2024-02-03 05:33:10 -06:00
package = helpers.mkPluginPackageOption "autoclose.nvim" pkgs.vimPlugins.autoclose-nvim;
2024-02-03 12:45:00 +01:00
keys = helpers.mkNullOrOption (with types; attrsOf anything) ''
Configures various options, such as shortcuts for pairs, what pair of characters to use in the
shortcut, etc.
See the plugin's [README](https://github.com/m4xshen/autoclose.nvim?tab=readme-ov-file#-configuration) for more info.";
Example:
```nix
{
"(" = { escape = false; close = true; pair = "()"; };
"[" = { escape = false; close = true; pair = "[]"; };
"{" = { escape = false; close = true; pair = "{}"; };
}
```
'';
2024-02-03 05:33:10 -06:00
options = {
disabledFiletypes = helpers.defaultNullOpts.mkListOf types.str [ "text" ] ''
2024-02-03 05:33:10 -06:00
The plugin will be disabled under the filetypes in this table.
'';
2024-02-03 12:45:00 +01:00
disableWhenTouch = helpers.defaultNullOpts.mkBool false ''
Set this to true will disable the auto-close function when the cursor touches character that
matches touch_regex.
'';
2024-02-03 05:33:10 -06:00
2024-02-03 12:45:00 +01:00
touchRegex = helpers.defaultNullOpts.mkStr "[%w(%[{]" ''
See [README](https://github.com/m4xshen/autoclose.nvim?tab=readme-ov-file#options).
'';
2024-02-03 05:33:10 -06:00
2024-02-03 12:45:00 +01:00
pairSpaces = helpers.defaultNullOpts.mkBool false ''
Pair the spaces when cursor is inside a pair of keys.
See [README](https://github.com/m4xshen/autoclose.nvim?tab=readme-ov-file#options)
'';
2024-02-03 05:33:10 -06:00
2024-02-03 12:45:00 +01:00
autoIndent = helpers.defaultNullOpts.mkBool true ''
Enable auto-indent feature.
'';
2024-02-03 05:33:10 -06:00
2024-02-03 12:45:00 +01:00
disableCommandMode = helpers.defaultNullOpts.mkBool false ''
Disable autoclose for command mode globally.
'';
2024-02-03 05:33:10 -06:00
};
};
2024-02-03 12:45:00 +01:00
config = mkIf cfg.enable {
2024-02-03 05:33:10 -06:00
extraPlugins = [ cfg.package ];
2024-02-03 12:45:00 +01:00
extraConfigLua =
let
setupOptions = with cfg; {
inherit keys;
options = with options; {
disabled_filetypes = disabledFiletypes;
disable_when_touch = disableWhenTouch;
touch_regex = touchRegex;
pair_spaces = pairSpaces;
auto_indent = autoIndent;
disable_command_mode = disableCommandMode;
2024-05-05 19:39:35 +02:00
};
2024-02-03 12:45:00 +01:00
};
in
''
require('autoclose').setup(${helpers.toLuaObject setupOptions})
2024-02-03 05:33:10 -06:00
'';
};
}