mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/autoclose: migrate to mkNeovimPlugin
This commit is contained in:
parent
8f8f50243e
commit
ccd0092988
4 changed files with 136 additions and 139 deletions
|
@ -1,92 +1,61 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
cfg = config.plugins.autoclose;
|
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
|
||||||
|
inherit (lib) types;
|
||||||
in
|
in
|
||||||
{
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
meta.maintainers = [ maintainers.GaetanLepage ];
|
name = "autoclose";
|
||||||
|
packPathName = "autoclose.nvim";
|
||||||
|
package = "autoclose-nvim";
|
||||||
|
|
||||||
options.plugins.autoclose = {
|
maintainers = [ lib.maintainers.GaetanLepage ];
|
||||||
enable = mkEnableOption "autoclose.nvim";
|
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "autoclose.nvim" {
|
description = ''
|
||||||
default = [
|
Automatically close pairs in Neovim.
|
||||||
"vimPlugins"
|
'';
|
||||||
"autoclose-nvim"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
keys = helpers.mkNullOrOption (with types; attrsOf anything) ''
|
settingsOptions = {
|
||||||
Configures various options, such as shortcuts for pairs, what pair of characters to use in the
|
keys = mkNullOrOption (types.attrsOf types.anything) ''
|
||||||
shortcut, etc.
|
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 = "{}"; };
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
disabledFiletypes = helpers.defaultNullOpts.mkListOf types.str [ "text" ] ''
|
disabled_filetypes = defaultNullOpts.mkListOf types.str [ "text" ] ''
|
||||||
The plugin will be disabled under the filetypes in this table.
|
The plugin will be disabled under the filetypes in this table.
|
||||||
'';
|
'';
|
||||||
|
disable_when_touch = defaultNullOpts.mkBool false ''
|
||||||
disableWhenTouch = helpers.defaultNullOpts.mkBool false ''
|
Set this to true will disable the auto-close function when the cursor touches character that matches touch_regex.
|
||||||
Set this to true will disable the auto-close function when the cursor touches character that
|
|
||||||
matches touch_regex.
|
|
||||||
'';
|
'';
|
||||||
|
touch_regex = defaultNullOpts.mkStr "[%w(%[{]" ''
|
||||||
touchRegex = helpers.defaultNullOpts.mkStr "[%w(%[{]" ''
|
Regex to use in combination with `disable_when_touch`.
|
||||||
See [README](https://github.com/m4xshen/autoclose.nvim?tab=readme-ov-file#options).
|
|
||||||
'';
|
'';
|
||||||
|
pair_spaces = defaultNullOpts.mkBool false ''
|
||||||
pairSpaces = helpers.defaultNullOpts.mkBool false ''
|
|
||||||
Pair the spaces when cursor is inside a pair of keys.
|
Pair the spaces when cursor is inside a pair of keys.
|
||||||
See [README](https://github.com/m4xshen/autoclose.nvim?tab=readme-ov-file#options)
|
|
||||||
'';
|
'';
|
||||||
|
auto_indent = defaultNullOpts.mkBool true ''
|
||||||
autoIndent = helpers.defaultNullOpts.mkBool true ''
|
|
||||||
Enable auto-indent feature.
|
Enable auto-indent feature.
|
||||||
'';
|
'';
|
||||||
|
disable_command_mode = defaultNullOpts.mkBool false ''
|
||||||
disableCommandMode = helpers.defaultNullOpts.mkBool false ''
|
|
||||||
Disable autoclose for command mode globally.
|
Disable autoclose for command mode globally.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
settingsExample = {
|
||||||
extraPlugins = [ cfg.package ];
|
settings = {
|
||||||
|
options = {
|
||||||
extraConfigLua =
|
disabled_filetypes = [ "text" ];
|
||||||
let
|
disable_when_touch = false;
|
||||||
setupOptions = with cfg; {
|
touch_regex = "[%w(%[{]";
|
||||||
inherit keys;
|
pair_spaces = false;
|
||||||
options = with options; {
|
auto_indent = true;
|
||||||
disabled_filetypes = disabledFiletypes;
|
disable_command_mode = false;
|
||||||
disable_when_touch = disableWhenTouch;
|
};
|
||||||
touch_regex = touchRegex;
|
};
|
||||||
pair_spaces = pairSpaces;
|
|
||||||
auto_indent = autoIndent;
|
|
||||||
disable_command_mode = disableCommandMode;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
''
|
|
||||||
require('autoclose').setup(${lib.nixvim.toLuaObject setupOptions})
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# TODO: Deprecated in 2025-01-31
|
||||||
|
inherit (import ./deprecations.nix) deprecateExtraOptions optionsRenamedToSettings;
|
||||||
}
|
}
|
||||||
|
|
30
plugins/by-name/autoclose/deprecations.nix
Normal file
30
plugins/by-name/autoclose/deprecations.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"keys"
|
||||||
|
[
|
||||||
|
"options"
|
||||||
|
"disabledFiletypes"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"options"
|
||||||
|
"disableWhenTouch"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"options"
|
||||||
|
"touchRegex"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"options"
|
||||||
|
"pairSpaces"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"options"
|
||||||
|
"autoIndent"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"options"
|
||||||
|
"disableCommandMode"
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,73 +0,0 @@
|
||||||
{
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -2,4 +2,75 @@
|
||||||
empty = {
|
empty = {
|
||||||
plugins.autoclose.enable = true;
|
plugins.autoclose.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaults = {
|
||||||
|
plugins.autoclose = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
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 = {
|
||||||
|
disabled_filetypes = [ "text" ];
|
||||||
|
disable_when_touch = false;
|
||||||
|
touch_regex = "[%w(%[{]";
|
||||||
|
pair_spaces = false;
|
||||||
|
auto_indent = true;
|
||||||
|
disable_command_mode = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue