nix-community.nixvim/plugins/completion/cmp/sources/codeium-nvim.nix

84 lines
2.4 KiB
Nix
Raw Normal View History

2024-01-01 21:50:06 +01:00
{
lib,
helpers,
config,
pkgs,
...
}:
2024-05-05 19:39:35 +02:00
with lib;
let
2024-01-01 21:50:06 +01:00
cfg = config.plugins.codeium-nvim;
2024-05-05 19:39:35 +02:00
in
{
meta.maintainers = [ maintainers.GaetanLepage ];
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
options.plugins.codeium-nvim = helpers.neovim-plugin.extraOptionsOptions // {
package = helpers.mkPluginPackageOption "codeium.nvim" pkgs.vimPlugins.codeium-nvim;
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
configPath = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";}'' "The path to the config file, used to store the API key.";
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
binPath = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('cache') .. '/codeium/bin'";}'' "The path to the directory where the Codeium server will be downloaded to.";
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
api = {
host = helpers.defaultNullOpts.mkStr "server.codeium.com" ''
The hostname of the API server to use.
'';
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
port = helpers.defaultNullOpts.mkPositiveInt 443 ''
The port of the API server to use.
'';
};
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
tools = {
uname = helpers.mkNullOrOption types.str "The path to the `uname` binary.";
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
uuidgen = helpers.mkNullOrOption types.str "The path to the `uuidgen` binary.";
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
curl = helpers.mkNullOrOption types.str "The path to the `curl` binary.";
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
gzip = helpers.mkNullOrOption types.str "The path to the `gzip` binary.";
2024-01-01 21:50:06 +01:00
2024-05-05 19:39:35 +02:00
languageServer = helpers.mkNullOrOption types.str ''
The path to the language server downloaded from the official source.
2024-01-01 21:50:06 +01:00
'';
};
2024-05-05 19:39:35 +02:00
wrapper = helpers.mkNullOrOption types.str ''
The path to a wrapper script/binary that is used to execute any binaries not listed under
tools.
This is primarily useful for NixOS, where a FHS wrapper can be used for the downloaded
codeium server.
2024-01-01 21:50:06 +01:00
'';
};
2024-05-05 19:39:35 +02:00
config = mkIf cfg.enable {
extraConfigLua =
let
setupOptions =
with cfg;
{
config_path = configPath;
bin_path = binPath;
api = with api; {
inherit host;
port = if isInt port then toString port else port;
};
tools = with tools; {
inherit
uname
uuidgen
curl
gzip
;
language_server = languageServer;
};
inherit wrapper;
}
// cfg.extraOptions;
in
''
require('codeium').setup(${helpers.toLuaObject setupOptions})
'';
};
2024-01-01 21:50:06 +01:00
}