plugins/cmp-tabby: move to by-name

This commit is contained in:
Gaetan Lepage 2024-12-18 18:42:03 +01:00
parent 6e52e32d40
commit 5abe382c54
4 changed files with 51 additions and 75 deletions

View file

@ -0,0 +1,50 @@
{ lib, ... }:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "cmp-tabby";
maintainers = [ lib.maintainers.GaetanLepage ];
imports = [
{ cmpSourcePlugins.cmp_tabby = "cmp-tabby"; }
];
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"host"
"maxLines"
"runOnEveryKeyStroke"
"stop"
];
moduleName = "cmp_tabby.config";
setup = ":setup";
settingsOptions = {
host = defaultNullOpts.mkStr "http://localhost:5000" ''
The address of the tabby host server.
'';
max_lines = defaultNullOpts.mkUnsignedInt 100 ''
The max number of lines to complete.
'';
run_on_every_keystroke = defaultNullOpts.mkBool true ''
Whether to run the completion on every keystroke.
'';
stop = defaultNullOpts.mkListOf types.str [ "\n" ] ''
Stop character.
'';
};
settingsExample = {
host = "http://localhost:5000";
max_lines = 100;
run_on_every_keystroke = true;
stop = [ "\n" ];
};
}

View file

@ -1,70 +0,0 @@
{
lib,
config,
...
}:
let
inherit (lib) mkRenamedOptionModule types;
inherit (lib.nixvim) defaultNullOpts;
cfg = config.plugins.cmp-tabby;
in
{
meta.maintainers = [ lib.maintainers.GaetanLepage ];
# 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" ]))
];
options.plugins.cmp-tabby = {
settings = lib.nixvim.mkSettingsOption {
description = "Options provided to the `require('cmp_ai.config'):setup` function.";
options = {
host = defaultNullOpts.mkStr "http://localhost:5000" ''
The address of the tabby host server.
'';
max_lines = defaultNullOpts.mkUnsignedInt 100 ''
The max number of lines to complete.
'';
run_on_every_keystroke = defaultNullOpts.mkBool true ''
Whether to run the completion on every keystroke.
'';
stop = defaultNullOpts.mkListOf types.str [ "\n" ] ''
Stop character.
'';
};
example = {
host = "http://localhost:5000";
max_lines = 100;
run_on_every_keystroke = true;
stop = [ "\n" ];
};
};
};
config = lib.mkIf cfg.enable {
extraConfigLua = ''
require('cmp_tabby.config'):setup(${lib.nixvim.toLuaObject cfg.settings})
'';
};
}

View file

@ -5,6 +5,7 @@
...
}@args:
let
# A list of most cmp source plugins, passed to mkCmpSourcePlugin.
# More complex cmp sources can instead be defined as their own plugin
# and register their source-name association using the `cmpSourcePlugins` option.
@ -145,10 +146,6 @@ let
pluginName = "cmp-spell";
sourceName = "spell";
}
{
pluginName = "cmp-tabby";
sourceName = "cmp_tabby";
}
{
pluginName = "cmp-tabnine";
sourceName = "cmp_tabnine";
@ -205,7 +202,6 @@ in
./cmp-ai.nix
./cmp-fish.nix
./cmp-git.nix
./cmp-tabby.nix
./cmp-tabnine.nix
./crates-nvim.nix
] ++ pluginModules;