Skip to content

Commit

Permalink
plugins/cmp-tabnine: move to by-name
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage authored and nix-infra-bot committed Dec 18, 2024
1 parent 79a637d commit 7aed1c4
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 22 deletions.
67 changes: 67 additions & 0 deletions plugins/by-name/cmp-tabnine/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{ lib, ... }:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "cmp-tabnine";

maintainers = [ lib.maintainers.GaetanLepage ];

imports = [
{ cmpSourcePlugins.cmp_tabnine = "cmp-tabnine"; }
];

deprecateExtraOptions = true;

moduleName = "cmp_tabnine.config";
setup = ":setup";

settingsOptions = {
max_lines = defaultNullOpts.mkUnsignedInt 1000 ''
How many lines of buffer context to pass to TabNine.
'';

max_num_results = defaultNullOpts.mkUnsignedInt 20 ''
How many results to return.
'';

sort = defaultNullOpts.mkBool true ''
Sort results by returned priority.
'';

run_on_every_keystroke = defaultNullOpts.mkBool true ''
Generate new completion items on every keystroke.
For more info, check out [#18](https://github.com/tzachar/cmp-tabnine/issues/18).
'';

snippet_placeholder = defaultNullOpts.mkStr ".." ''
Indicates where the cursor will be placed in case a completion item is asnippet.
Any string is accepted.
For this to work properly, you need to setup snippet support for `nvim-cmp`.
'';

ignored_file_types = defaultNullOpts.mkAttrsOf' {
type = types.bool;
pluginDefault = { };
example = {
lua = true;
};
description = ''
Which file types to ignore.
'';
};

min_percent = defaultNullOpts.mkNullable (types.numbers.between 0 100) 0 ''
Eliminate items with a percentage less than `min_percent`.
'';
};

settingsExample = {
max_lines = 600;
max_num_results = 10;
sort = false;
};
}
17 changes: 0 additions & 17 deletions plugins/cmp/sources/cmp-tabnine.nix

This file was deleted.

5 changes: 0 additions & 5 deletions plugins/cmp/sources/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ let
pluginName = "cmp-spell";
sourceName = "spell";
}
{
pluginName = "cmp-tabnine";
sourceName = "cmp_tabnine";
}
{
pluginName = "cmp-tmux";
sourceName = "tmux";
Expand Down Expand Up @@ -194,7 +190,6 @@ in
# For extra cmp plugins
imports = [
./copilot-cmp.nix
./cmp-tabnine.nix
./crates-nvim.nix
] ++ pluginModules;
}
49 changes: 49 additions & 0 deletions tests/test-sources/plugins/by-name/cmp-tabnine/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{ lib, pkgs, ... }:
let
platform = pkgs.stdenv.hostPlatform;

# tabnine is not available on aarch64-linux.
doRun = !(platform.isLinux && platform.isAarch64);
in
lib.optionalAttrs doRun {
empty = {
plugins = {
cmp.enable = true;
cmp-tabnine.enable = true;
};
};

defaults = {
plugins = {
cmp.enable = true;
cmp-tabnine = {
enable = true;

settings = {
max_lines = 1000;
max_num_results = 20;
sort = true;
run_on_every_keystroke = true;
snippet_placeholder = "..";
ignored_file_types = { };
min_percent = 0;
};
};
};
};

example = {
plugins = {
cmp.enable = true;
cmp-tabnine = {
enable = true;

settings = {
max_lines = 600;
max_num_results = 10;
sort = false;
};
};
};
};
}

0 comments on commit 7aed1c4

Please sign in to comment.