plugins/cmp-tabby: switch to RFC-42 style

This commit is contained in:
Gaetan Lepage 2024-06-18 16:40:46 +02:00 committed by Gaétan Lepage
parent bf109a3e59
commit 9ed3538685
2 changed files with 51 additions and 29 deletions

View file

@ -11,37 +11,59 @@ in
{
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.cmp-tabby = helpers.neovim-plugin.extraOptionsOptions // {
host = helpers.defaultNullOpts.mkStr "http://localhost:5000" ''
The address of the tabby host server.
'';
# TODO: introduced 24-06-18, remove after 24.11
imports =
let
basePluginPath = [
"plugins"
"cmp-tabby"
];
settingsPath = basePluginPath ++ [ "settings" ];
in
[
(mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) settingsPath)
(mkRenamedOptionModule (basePluginPath ++ [ "host" ]) (settingsPath ++ [ "host" ]))
(mkRenamedOptionModule (basePluginPath ++ [ "maxLines" ]) (settingsPath ++ [ "max_lines" ]))
(mkRenamedOptionModule (basePluginPath ++ [ "runOnEveryKeyStroke" ]) (
settingsPath ++ [ "run_on_every_keystroke" ]
))
(mkRenamedOptionModule (basePluginPath ++ [ "stop" ]) (settingsPath ++ [ "stop" ]))
];
maxLines = helpers.defaultNullOpts.mkUnsignedInt 100 ''
The max number of lines to complete.
'';
options.plugins.cmp-tabby = {
settings = helpers.mkSettingsOption {
description = "Options provided to the `require('cmp_ai.config'):setup` function.";
runOnEveryKeyStroke = helpers.defaultNullOpts.mkBool true ''
Whether to run the completion on every keystroke.
'';
options = {
host = helpers.defaultNullOpts.mkStr "http://localhost:5000" ''
The address of the tabby host server.
'';
stop = helpers.defaultNullOpts.mkListOf types.str ''["\n"]'' "";
max_lines = helpers.defaultNullOpts.mkUnsignedInt 100 ''
The max number of lines to complete.
'';
run_on_every_keystroke = helpers.defaultNullOpts.mkBool true ''
Whether to run the completion on every keystroke.
'';
stop = helpers.defaultNullOpts.mkListOf types.str [ "\n" ] ''
Stop character.
'';
};
example = {
host = "http://localhost:5000";
max_lines = 100;
run_on_every_keystroke = true;
stop = [ "\n" ];
};
};
};
config = mkIf cfg.enable {
extraConfigLua =
let
setupOptions =
with cfg;
{
inherit host;
max_lines = maxLines;
run_on_every_keystroke = runOnEveryKeyStroke;
inherit stop;
}
// cfg.extraOptions;
in
''
require('cmp_tabby.config'):setup(${helpers.toLuaObject setupOptions})
'';
extraConfigLua = ''
require('cmp_tabby.config'):setup(${helpers.toLuaObject cfg.settings})
'';
};
}

View file

@ -12,10 +12,10 @@
enable = true;
settings.sources = [ { name = "cmp_tabby"; } ];
};
cmp-tabby = {
cmp-tabby.settings = {
host = "http://localhost:5000";
maxLines = 100;
runOnEveryKeyStroke = true;
max_lines = 100;
run_on_every_keystroke = true;
stop = [ "\n" ];
};
};