mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 09:18:38 +02:00
plugins/codeium-vim: switch to mkVimPlugin
This commit is contained in:
parent
b8815f04a3
commit
5fba5be696
2 changed files with 157 additions and 175 deletions
|
@ -5,22 +5,79 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.codeium-vim;
|
||||
in {
|
||||
meta.maintainers = [maintainers.GaetanLepage];
|
||||
with lib;
|
||||
helpers.vim-plugin.mkVimPlugin config {
|
||||
name = "codeium-vim";
|
||||
originalName = "codeium.vim";
|
||||
defaultPackage = pkgs.vimPlugins.codeium-vim;
|
||||
globalPrefix = "codeium_";
|
||||
|
||||
options.plugins.codeium-vim = {
|
||||
enable = mkEnableOption "codeium.vim";
|
||||
maintainers = [maintainers.GaetanLepage];
|
||||
|
||||
package = helpers.mkPackageOption "codeium-vim" pkgs.vimPlugins.codeium-vim;
|
||||
# TODO introduced 2024-02-19: remove 2024-03-19
|
||||
deprecateExtraConfig = true;
|
||||
optionsRenamedToSettings = [
|
||||
"bin"
|
||||
"filetypes"
|
||||
"manual"
|
||||
"noMapTab"
|
||||
"idleDelay"
|
||||
"render"
|
||||
"tabFallback"
|
||||
"disableBindings"
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
bin = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = "${pkgs.codeium}/bin/codeium_language_server";
|
||||
description = "The path to the codeium language server executable.";
|
||||
};
|
||||
|
||||
filetypes =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.bool
|
||||
''
|
||||
{
|
||||
help = false;
|
||||
gitcommit = false;
|
||||
gitrebase = false;
|
||||
"." = false;
|
||||
}
|
||||
''
|
||||
''
|
||||
A dictionary mapping whether codeium should be enabled or disabled in certain filetypes.
|
||||
This can be used to opt out of completions for certain filetypes.
|
||||
'';
|
||||
|
||||
manual = helpers.defaultNullOpts.mkBool false ''
|
||||
If true, codeium completions will never automatically trigger.
|
||||
'';
|
||||
|
||||
no_map_tab = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to disable the `<Tab>` keybinding.
|
||||
'';
|
||||
|
||||
idle_delay = helpers.defaultNullOpts.mkPositiveInt 75 ''
|
||||
Delay in milliseconds before autocompletions are shown (limited by language server to a
|
||||
minimum of 75).
|
||||
'';
|
||||
|
||||
render = helpers.defaultNullOpts.mkBool true ''
|
||||
A global boolean flag that controls whether codeium renders are enabled or disabled.
|
||||
'';
|
||||
|
||||
tab_fallback = helpers.mkNullOrOption types.str ''
|
||||
The fallback key when there is no suggestion display in `codeium#Accept()`.
|
||||
|
||||
Default: "\<C-N>" when a popup menu is visible, else "\t".
|
||||
'';
|
||||
|
||||
disable_bindings = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to disable default keybindings.
|
||||
'';
|
||||
};
|
||||
|
||||
extraOptions = {
|
||||
keymaps = {
|
||||
clear = helpers.defaultNullOpts.mkStr "<C-]>" ''
|
||||
Keymap for clearing current suggestion.
|
||||
|
@ -47,88 +104,10 @@ in {
|
|||
Command: `codeium#Complete()`
|
||||
'';
|
||||
};
|
||||
|
||||
filetypes =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.bool
|
||||
''
|
||||
{
|
||||
help = false;
|
||||
gitcommit = false;
|
||||
gitrebase = false;
|
||||
"." = false;
|
||||
}
|
||||
''
|
||||
''
|
||||
A dictionary mapping whether codeium should be enabled or disabled in certain filetypes.
|
||||
This can be used to opt out of completions for certain filetypes.
|
||||
'';
|
||||
|
||||
manual = helpers.defaultNullOpts.mkBool false ''
|
||||
If true, codeium completions will never automatically trigger.
|
||||
'';
|
||||
|
||||
noMapTab = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to disable the `<Tab>` keybinding.
|
||||
'';
|
||||
|
||||
idleDelay = helpers.defaultNullOpts.mkPositiveInt 75 ''
|
||||
Delay in milliseconds before autocompletions are shown (limited by language server to a
|
||||
minimum of 75).
|
||||
'';
|
||||
|
||||
render = helpers.defaultNullOpts.mkBool true ''
|
||||
A global boolean flag that controls whether codeium renders are enabled or disabled.
|
||||
'';
|
||||
|
||||
tabFallback = helpers.mkNullOrOption types.str ''
|
||||
The fallback key when there is no suggestion display in `codeium#Accept()`.
|
||||
|
||||
Default: "\<C-N>" when a popup menu is visible, else "\t".
|
||||
'';
|
||||
|
||||
disableBindings = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to disable default keybindings.
|
||||
'';
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.attrs;
|
||||
default = {};
|
||||
description = ''
|
||||
The configuration options for codeium-vim without the 'codeium_' prefix.
|
||||
Example: To set 'codeium_foobar' to 1, write
|
||||
extraConfig = {
|
||||
foobar = true;
|
||||
};
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
# Add the typst compiler to nixvim packages
|
||||
extraPackages = with pkgs; [typst];
|
||||
|
||||
globals =
|
||||
mapAttrs'
|
||||
(name: nameValuePair ("codeium_" + name))
|
||||
(
|
||||
with cfg;
|
||||
{
|
||||
enabled = true;
|
||||
inherit
|
||||
filetypes
|
||||
manual
|
||||
bin
|
||||
;
|
||||
no_map_tab = noMapTab;
|
||||
idle_delay = idleDelay;
|
||||
inherit render;
|
||||
tab_fallback = tabFallback;
|
||||
disable_bindings = disableBindings;
|
||||
}
|
||||
// extraConfig
|
||||
);
|
||||
extraConfig = cfg: {
|
||||
plugins.codeium-vim.settings.enabled = true;
|
||||
|
||||
keymaps = with cfg.keymaps;
|
||||
helpers.keymaps.mkKeymaps
|
||||
|
@ -175,4 +154,4 @@ in {
|
|||
]
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
accept = "<Tab>";
|
||||
complete = "<M-Bslash>";
|
||||
};
|
||||
|
||||
settings = {
|
||||
filetypes = {
|
||||
help = false;
|
||||
gitcommit = false;
|
||||
|
@ -21,11 +23,12 @@
|
|||
"." = false;
|
||||
};
|
||||
manual = false;
|
||||
noMapTab = false;
|
||||
idleDelay = 75;
|
||||
no_map_tab = false;
|
||||
idle_delay = 75;
|
||||
render = true;
|
||||
tabFallback = "\t";
|
||||
disableBindings = true;
|
||||
tab_fallback = "\t";
|
||||
disable_bindings = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue