Skip to content

plugins/mini-ai: init #3368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions plugins/by-name/mini-ai/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{ lib, ... }:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts literalLua;
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "mini-ai";
moduleName = "mini.ai";
packPathName = "mini.ai";

maintainers = [ lib.maintainers.HeitorAugustoLN ];

settingsOptions = {
custom_textobjects = defaultNullOpts.mkAttrsOf types.anything (literalLua "nil") ''
Table with textobject id as fields, textobject specification as values.
Also use this to disable builtin textobjects.
'';

mappings =
defaultNullOpts.mkNullableWithRaw
(types.submodule {
freeformType = with types; attrsOf anything;
options = {
around = defaultNullOpts.mkStr "a" ''
Main textobject prefix for "around" textobject
'';

inside = defaultNullOpts.mkStr "i" ''
Main textobject prefix for "inside" textobject
'';

around_next = defaultNullOpts.mkStr "an" ''
Next variant for "around" textobject
'';

inside_next = defaultNullOpts.mkStr "in" ''
Next variant for "inside" textobject
'';

around_last = defaultNullOpts.mkStr "al" ''
Last variant for "around" textobject
'';

inside_last = defaultNullOpts.mkStr "il" ''
Last variant for "inside" textobject
'';

goto_left = defaultNullOpts.mkStr "g[" ''
Move cursor to corresponding left edge of "a" textobject
'';

goto_right = defaultNullOpts.mkStr "g]" ''
Move cursor to corresponding right edge of "a" textobject
'';
};
})
{
around = "a";
inside = "i";
around_next = "an";
inside_next = "in";
around_last = "al";
inside_last = "il";
goto_left = "g[";
goto_right = "g]";
}
''
Module mappings. Use empty string to disable one.
'';

n_lines = defaultNullOpts.mkNum 50 ''
Number of lines within which textobject is searched
'';

search_method =
defaultNullOpts.mkEnum
[
"cover"
"cover_or_next"
"cover_or_prev"
"cover_or_nearest"
"next"
"previous"
"nearest"
]
"cover_or_next"
''
How to search for object (first inside current line, then inside neighborhood).
'';

silent = defaultNullOpts.mkBool false ''
Whether to disable showing non-error feedback.
This also affects (purely informational) helper messages shown after idle time if user input is required.
'';
};

settingsExample = {
n_line = 500;
search_method = "cover_or_nearest";
silent = true;
};
}
17 changes: 17 additions & 0 deletions tests/test-sources/plugins/by-name/mini-ai/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
empty = {
plugins.mini-ai.enable = true;
};

example = {
plugins.mini-ai = {
enable = true;

settings = {
n_lines = 500;
search_method = "cover_or_nearest";
silent = true;
};
};
};
}