mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-25 02:08:40 +02:00
plugins/autoclose: init + tests (#994)
This commit is contained in:
parent
9d3ff56ed8
commit
7eefcfa5ee
3 changed files with 148 additions and 4 deletions
|
@ -108,6 +108,7 @@
|
||||||
./utils/alpha.nix
|
./utils/alpha.nix
|
||||||
./utils/auto-save.nix
|
./utils/auto-save.nix
|
||||||
./utils/auto-session.nix
|
./utils/auto-session.nix
|
||||||
|
./utils/autoclose.nix
|
||||||
./utils/better-escape.nix
|
./utils/better-escape.nix
|
||||||
./utils/clipboard-image.nix
|
./utils/clipboard-image.nix
|
||||||
./utils/comment-nvim.nix
|
./utils/comment-nvim.nix
|
||||||
|
@ -138,11 +139,11 @@
|
||||||
./utils/molten.nix
|
./utils/molten.nix
|
||||||
./utils/multicursors.nix
|
./utils/multicursors.nix
|
||||||
./utils/navbuddy.nix
|
./utils/navbuddy.nix
|
||||||
./utils/neorg.nix
|
|
||||||
./utils/neogen.nix
|
./utils/neogen.nix
|
||||||
./utils/notify.nix
|
./utils/neorg.nix
|
||||||
./utils/netman.nix
|
./utils/netman.nix
|
||||||
./utils/nix-develop.nix
|
./utils/nix-develop.nix
|
||||||
|
./utils/notify.nix
|
||||||
./utils/nvim-autopairs.nix
|
./utils/nvim-autopairs.nix
|
||||||
./utils/nvim-bqf.nix
|
./utils/nvim-bqf.nix
|
||||||
./utils/nvim-colorizer.nix
|
./utils/nvim-colorizer.nix
|
||||||
|
@ -152,11 +153,11 @@
|
||||||
./utils/oil.nix
|
./utils/oil.nix
|
||||||
./utils/ollama.nix
|
./utils/ollama.nix
|
||||||
./utils/persistence.nix
|
./utils/persistence.nix
|
||||||
|
./utils/presence-nvim.nix
|
||||||
./utils/project-nvim.nix
|
./utils/project-nvim.nix
|
||||||
|
./utils/quickmath.nix
|
||||||
./utils/refactoring.nix
|
./utils/refactoring.nix
|
||||||
./utils/rest.nix
|
./utils/rest.nix
|
||||||
./utils/presence-nvim.nix
|
|
||||||
./utils/quickmath.nix
|
|
||||||
./utils/specs.nix
|
./utils/specs.nix
|
||||||
./utils/spider.nix
|
./utils/spider.nix
|
||||||
./utils/startify.nix
|
./utils/startify.nix
|
||||||
|
|
72
plugins/utils/autoclose.nix
Normal file
72
plugins/utils/autoclose.nix
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
helpers,
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib; let
|
||||||
|
cfg = config.plugins.autoclose;
|
||||||
|
in {
|
||||||
|
options.plugins.autoclose = {
|
||||||
|
enable = mkEnableOption "autoclose";
|
||||||
|
package = helpers.mkPackageOption "autoclose" pkgs.vimPlugins.autoclose-nvim;
|
||||||
|
|
||||||
|
keys = mkOption {
|
||||||
|
type = with types; nullOr (attrsOf anything);
|
||||||
|
default = null;
|
||||||
|
description = "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 = ''
|
||||||
|
keys = {
|
||||||
|
"(" = { escape = false, close = true, pair = "()" },
|
||||||
|
"[" = { escape = false, close = true, pair = "[]" },
|
||||||
|
"{" = { escape = false, close = true, pair = "{}" },
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
options = {
|
||||||
|
disabledFiletypes = helpers.defaultNullOpts.mkListOf types.str ''["text"]'' ''
|
||||||
|
The plugin will be disabled under the filetypes in this table.
|
||||||
|
'';
|
||||||
|
|
||||||
|
disableWhenTouch =
|
||||||
|
helpers.defaultNullOpts.mkBool false
|
||||||
|
"Set this to true will disable the auto-close function when the cursor touches character that matches touch_regex.";
|
||||||
|
|
||||||
|
touchRegex =
|
||||||
|
helpers.defaultNullOpts.mkStr "[%w(%[{]"
|
||||||
|
"See [README](https://github.com/m4xshen/autoclose.nvim?tab=readme-ov-file#options)";
|
||||||
|
|
||||||
|
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)";
|
||||||
|
|
||||||
|
autoIndent =
|
||||||
|
helpers.defaultNullOpts.mkBool true "Enable auto-indent feature";
|
||||||
|
|
||||||
|
disableCommandMode =
|
||||||
|
helpers.defaultNullOpts.mkBool false
|
||||||
|
"Disable autoclose for command mode globally";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = with cfg; let
|
||||||
|
options' = {
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
extraPlugins = [cfg.package];
|
||||||
|
extraConfigLua = ''
|
||||||
|
require('autoclose').setup(${helpers.toLuaObject options'})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
71
tests/test-sources/plugins/utils/autoclose-nvim.nix
Normal file
71
tests/test-sources/plugins/utils/autoclose-nvim.nix
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
empty = {plugins.autoclose.enable = true;};
|
||||||
|
|
||||||
|
defaults = {
|
||||||
|
plugins.autoclose.enable = true;
|
||||||
|
plugins.autoclose = {
|
||||||
|
keys = {
|
||||||
|
"(" = {
|
||||||
|
escape = false;
|
||||||
|
close = true;
|
||||||
|
pair = "()";
|
||||||
|
};
|
||||||
|
"[" = {
|
||||||
|
escape = false;
|
||||||
|
close = true;
|
||||||
|
pair = "[]";
|
||||||
|
};
|
||||||
|
"{" = {
|
||||||
|
escape = false;
|
||||||
|
close = true;
|
||||||
|
pair = "{}";
|
||||||
|
};
|
||||||
|
|
||||||
|
">" = {
|
||||||
|
escape = true;
|
||||||
|
close = false;
|
||||||
|
pair = "<>";
|
||||||
|
};
|
||||||
|
")" = {
|
||||||
|
escape = true;
|
||||||
|
close = false;
|
||||||
|
pair = "()";
|
||||||
|
};
|
||||||
|
"]" = {
|
||||||
|
escape = true;
|
||||||
|
close = false;
|
||||||
|
pair = "[]";
|
||||||
|
};
|
||||||
|
"}" = {
|
||||||
|
escape = true;
|
||||||
|
close = false;
|
||||||
|
pair = "{}";
|
||||||
|
};
|
||||||
|
"\"" = {
|
||||||
|
escape = true;
|
||||||
|
close = true;
|
||||||
|
pair = ''""'';
|
||||||
|
};
|
||||||
|
"'" = {
|
||||||
|
escape = true;
|
||||||
|
close = true;
|
||||||
|
pair = "''";
|
||||||
|
};
|
||||||
|
"`" = {
|
||||||
|
escape = true;
|
||||||
|
close = true;
|
||||||
|
pair = "``";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
options = {
|
||||||
|
disabledFiletypes = ["text"];
|
||||||
|
disableWhenTouch = false;
|
||||||
|
touchRegex = "[%w(%[{]";
|
||||||
|
pairSpaces = false;
|
||||||
|
autoIndent = true;
|
||||||
|
disableCommandMode = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue