|
1 | 1 | { |
2 | 2 | lib, |
3 | | - helpers, |
4 | | - config, |
5 | | - pkgs, |
6 | 3 | ... |
7 | 4 | }: |
8 | | -with lib; |
9 | 5 | let |
10 | | - cfg = config.plugins.codeium-nvim; |
| 6 | + inherit (lib.nixvim) defaultNullOpts; |
11 | 7 | 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 | + ]; |
14 | 53 |
|
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 { |
17 | 61 | __raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'"; |
18 | 62 | } "The path to the config file, used to store the API key."; |
19 | 63 |
|
20 | | - binPath = helpers.defaultNullOpts.mkStr { |
| 64 | + bin_path = defaultNullOpts.mkStr { |
21 | 65 | __raw = "vim.fn.stdpath('cache') .. '/codeium/bin'"; |
22 | 66 | } "The path to the directory where the Codeium server will be downloaded to."; |
23 | 67 |
|
24 | 68 | api = { |
25 | | - host = helpers.defaultNullOpts.mkStr "server.codeium.com" '' |
| 69 | + host = defaultNullOpts.mkStr "server.codeium.com" '' |
26 | 70 | The hostname of the API server to use. |
27 | 71 | ''; |
28 | 72 |
|
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 | + }; |
32 | 81 | }; |
33 | 82 |
|
34 | 83 | tools = { |
35 | | - uname = helpers.mkNullOrOption types.str "The path to the `uname` binary."; |
| 84 | + uname = defaultNullOpts.mkStr null "The path to the `uname` binary."; |
36 | 85 |
|
37 | | - uuidgen = helpers.mkNullOrOption types.str "The path to the `uuidgen` binary."; |
| 86 | + uuidgen = defaultNullOpts.mkStr null "The path to the `uuidgen` binary."; |
38 | 87 |
|
39 | | - curl = helpers.mkNullOrOption types.str "The path to the `curl` binary."; |
| 88 | + curl = defaultNullOpts.mkStr null "The path to the `curl` binary."; |
40 | 89 |
|
41 | | - gzip = helpers.mkNullOrOption types.str "The path to the `gzip` binary."; |
| 90 | + gzip = defaultNullOpts.mkStr null "The path to the `gzip` binary."; |
42 | 91 |
|
43 | | - languageServer = helpers.mkNullOrOption types.str '' |
| 92 | + language_server = defaultNullOpts.mkStr null '' |
44 | 93 | The path to the language server downloaded from the official source. |
45 | 94 | ''; |
46 | 95 | }; |
47 | 96 |
|
48 | | - wrapper = helpers.mkNullOrOption types.str '' |
| 97 | + wrapper = defaultNullOpts.mkStr null '' |
49 | 98 | The path to a wrapper script/binary that is used to execute any binaries not listed under |
50 | 99 | tools. |
51 | 100 | This is primarily useful for NixOS, where a FHS wrapper can be used for the downloaded |
52 | 101 | codeium server. |
53 | 102 | ''; |
54 | | - }; |
55 | 103 |
|
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."; |
84 | 109 | }; |
| 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 | + ''; |
85 | 122 | } |
0 commit comments