Skip to content

Commit b072a4a

Browse files
committed
plugins/codeium-nvim: migrate to mkNeovimPlugin
1 parent c8328e6 commit b072a4a

File tree

3 files changed

+103
-66
lines changed

3 files changed

+103
-66
lines changed
Lines changed: 86 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,122 @@
11
{
22
lib,
3-
helpers,
4-
config,
5-
pkgs,
63
...
74
}:
8-
with lib;
95
let
10-
cfg = config.plugins.codeium-nvim;
6+
inherit (lib.nixvim) defaultNullOpts;
117
in
12-
{
13-
meta.maintainers = [ maintainers.GaetanLepage ];
8+
lib.nixvim.neovim-plugin.mkNeovimPlugin {
9+
name = "codeium-nvim";
10+
originalName = "codeium.nvim";
11+
luaName = "codeium";
12+
13+
maintainers = with lib.maintainers; [
14+
GaetanLepage
15+
khaneliman
16+
];
17+
18+
# TODO: added 2024-09-03 remove after 24.11
19+
deprecateExtraOptions = true;
20+
optionsRenamedToSettings = [
21+
"configPath"
22+
"binPath"
23+
[
24+
"api"
25+
"host"
26+
]
27+
[
28+
"api"
29+
"port"
30+
]
31+
[
32+
"tools"
33+
"uname"
34+
]
35+
[
36+
"tools"
37+
"uuidgen"
38+
]
39+
[
40+
"tools"
41+
"curl"
42+
]
43+
[
44+
"tools"
45+
"gzip"
46+
]
47+
[
48+
"tools"
49+
"languageServer"
50+
]
51+
"wrapper"
52+
];
1453

15-
options.plugins.codeium-nvim = helpers.neovim-plugin.extraOptionsOptions // {
16-
configPath = helpers.defaultNullOpts.mkStr {
54+
# Register nvim-cmp association
55+
imports = [
56+
{ cmpSourcePlugins.codeium = "codeium-nvim"; }
57+
];
58+
59+
settingsOptions = {
60+
config_path = defaultNullOpts.mkStr {
1761
__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";
1862
} "The path to the config file, used to store the API key.";
1963

20-
binPath = helpers.defaultNullOpts.mkStr {
64+
bin_path = defaultNullOpts.mkStr {
2165
__raw = "vim.fn.stdpath('cache') .. '/codeium/bin'";
2266
} "The path to the directory where the Codeium server will be downloaded to.";
2367

2468
api = {
25-
host = helpers.defaultNullOpts.mkStr "server.codeium.com" ''
69+
host = defaultNullOpts.mkStr "server.codeium.com" ''
2670
The hostname of the API server to use.
2771
'';
2872

29-
port = helpers.defaultNullOpts.mkPositiveInt 443 ''
30-
The port of the API server to use.
31-
'';
73+
port = defaultNullOpts.mkNullableWithRaw' {
74+
# TODO: Added 2024-09-05; remove after 24.11
75+
type = with lib.types; lib.nixvim.transitionType ints.positive toString (strMatching "[0-9]+");
76+
pluginDefault = "443";
77+
description = ''
78+
The port of the API server to use.
79+
'';
80+
};
3281
};
3382

3483
tools = {
35-
uname = helpers.mkNullOrOption types.str "The path to the `uname` binary.";
84+
uname = defaultNullOpts.mkStr null "The path to the `uname` binary.";
3685

37-
uuidgen = helpers.mkNullOrOption types.str "The path to the `uuidgen` binary.";
86+
uuidgen = defaultNullOpts.mkStr null "The path to the `uuidgen` binary.";
3887

39-
curl = helpers.mkNullOrOption types.str "The path to the `curl` binary.";
88+
curl = defaultNullOpts.mkStr null "The path to the `curl` binary.";
4089

41-
gzip = helpers.mkNullOrOption types.str "The path to the `gzip` binary.";
90+
gzip = defaultNullOpts.mkStr null "The path to the `gzip` binary.";
4291

43-
languageServer = helpers.mkNullOrOption types.str ''
92+
language_server = defaultNullOpts.mkStr null ''
4493
The path to the language server downloaded from the official source.
4594
'';
4695
};
4796

48-
wrapper = helpers.mkNullOrOption types.str ''
97+
wrapper = defaultNullOpts.mkStr null ''
4998
The path to a wrapper script/binary that is used to execute any binaries not listed under
5099
tools.
51100
This is primarily useful for NixOS, where a FHS wrapper can be used for the downloaded
52101
codeium server.
53102
'';
54-
};
55103

56-
config = mkIf cfg.enable {
57-
extraConfigLua =
58-
let
59-
setupOptions =
60-
with cfg;
61-
{
62-
config_path = configPath;
63-
bin_path = binPath;
64-
api = with api; {
65-
inherit host;
66-
port = if isInt port then toString port else port;
67-
};
68-
tools = with tools; {
69-
inherit
70-
uname
71-
uuidgen
72-
curl
73-
gzip
74-
;
75-
language_server = languageServer;
76-
};
77-
inherit wrapper;
78-
}
79-
// cfg.extraOptions;
80-
in
81-
''
82-
require('codeium').setup(${helpers.toLuaObject setupOptions})
83-
'';
104+
detect_proxy = defaultNullOpts.mkBool false "Whether to enable the proxy detection.";
105+
106+
enable_chat = defaultNullOpts.mkBool false "Whether to enable the chat functionality.";
107+
108+
enterprise_mode = defaultNullOpts.mkBool false "Whether to enable the enterprise mode.";
84109
};
110+
111+
settingsExample = lib.literalExpression ''
112+
{
113+
enable_chat = true;
114+
tools = {
115+
curl = lib.getExe pkgs.curl;
116+
gzip = lib.getExe pkgs.gzip;
117+
uname = lib.getExe' pkgs.coreutils "uname";
118+
uuidgen = lib.getExe' pkgs.util-linux "uuidgen";
119+
};
120+
}
121+
'';
85122
}

plugins/completion/cmp/sources/default.nix

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ let
5353
pluginName = "cmp-tabnine";
5454
sourceName = "cmp_tabnine";
5555
}
56-
{
57-
pluginName = "codeium-nvim";
58-
sourceName = "codeium";
59-
}
6056
{
6157
pluginName = "cmp-conventionalcommits";
6258
sourceName = "conventionalcommits";

tests/test-sources/plugins/completion/codeium-nvim.nix

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@
1515
plugins.codeium-nvim = {
1616
enable = true;
1717

18-
configPath.__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";
19-
binPath.__raw = "vim.fn.stdpath('cache') .. '/codeium/bin'";
20-
api = {
21-
host = "server.codeium.com";
22-
port = 443;
18+
settings = {
19+
manager_path = null;
20+
bin_path.__raw = "vim.fn.stdpath('cache') .. '/codeium/bin'";
21+
config_path.__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";
22+
language_server_download_url = "https://github.com";
23+
api = {
24+
host = "server.codeium.com";
25+
port = "443";
26+
};
27+
enterprise_mode = null;
28+
detect_proxy = null;
29+
tools = { };
30+
wrapper = null;
31+
enable_chat = false;
32+
enable_local_search = false;
33+
enable_index_service = false;
34+
search_max_workspace_file_count = 5000;
2335
};
24-
tools = {
25-
uname = null;
26-
uuidgen = null;
27-
curl = null;
28-
gzip = null;
29-
languageServer = null;
30-
};
31-
wrapper = null;
3236
};
3337
};
3438
}

0 commit comments

Comments
 (0)