2024-12-23 01:24:06 +01:00
|
|
|
{lib, ...}: let
|
2024-12-23 02:51:21 +01:00
|
|
|
inherit (lib.options) mkEnableOption mkOption literalMD;
|
2024-12-23 20:45:17 +01:00
|
|
|
inherit (lib.types) listOf str either attrsOf submodule enum anything int;
|
2024-12-23 02:51:21 +01:00
|
|
|
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
2024-12-23 03:59:57 +01:00
|
|
|
inherit (lib.nvim.binds) mkMappingOption;
|
2024-12-23 20:45:17 +01:00
|
|
|
inherit (lib.nvim.config) mkBool;
|
2024-12-23 03:59:57 +01:00
|
|
|
|
|
|
|
keymapType = submodule {
|
|
|
|
freeformType = attrsOf (listOf (either str luaInline));
|
|
|
|
options = {
|
|
|
|
preset = mkOption {
|
|
|
|
type = enum ["default" "none" "super-tab" "enter"];
|
|
|
|
default = "none";
|
|
|
|
description = "keymap presets";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-12-23 20:27:03 +01:00
|
|
|
|
|
|
|
providerType = submodule {
|
|
|
|
freeformType = anything;
|
|
|
|
options = {
|
|
|
|
module = mkOption {
|
|
|
|
type = str;
|
|
|
|
description = "module of the provider";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-12-23 01:24:06 +01:00
|
|
|
in {
|
|
|
|
options.vim.autocomplete.blink-cmp = {
|
|
|
|
enable = mkEnableOption "blink.cmp";
|
|
|
|
setupOpts = mkPluginSetupOption "blink.cmp" {
|
2024-12-23 02:51:21 +01:00
|
|
|
sources = {
|
|
|
|
default = mkOption {
|
|
|
|
type = listOf str;
|
|
|
|
default = ["lsp" "path" "snippets" "buffer"];
|
2024-12-23 20:45:17 +01:00
|
|
|
description = "Default list of sources to enable for completion.";
|
2024-12-23 02:51:21 +01:00
|
|
|
};
|
2024-12-23 20:27:03 +01:00
|
|
|
|
2024-12-26 05:38:31 +01:00
|
|
|
cmdline = mkOption {
|
|
|
|
type = listOf str;
|
|
|
|
default = [];
|
|
|
|
description = "List of sources to enable for cmdline";
|
|
|
|
};
|
|
|
|
|
2024-12-23 20:27:03 +01:00
|
|
|
providers = mkOption {
|
|
|
|
type = attrsOf providerType;
|
|
|
|
default = {};
|
2024-12-23 20:45:17 +01:00
|
|
|
description = "Providers";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
completion = {
|
|
|
|
documentation = {
|
|
|
|
auto_show = mkBool true "Show documentation whenever an item is selected";
|
|
|
|
auto_show_delay_ms = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 200;
|
|
|
|
description = "Delay before auto show triggers";
|
|
|
|
};
|
2024-12-23 20:27:03 +01:00
|
|
|
};
|
2024-12-23 02:51:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
keymap = mkOption {
|
2024-12-23 03:59:57 +01:00
|
|
|
type = keymapType;
|
2024-12-23 02:51:21 +01:00
|
|
|
default = {};
|
|
|
|
description = "blink.cmp keymap";
|
|
|
|
example = literalMD ''
|
|
|
|
```nix
|
2024-12-23 03:59:57 +01:00
|
|
|
vim.autocomplete.blink-cmp.setupOpts.keymap = {
|
|
|
|
preset = "none";
|
|
|
|
|
|
|
|
"<Up>" = ["select_prev" "fallback"];
|
|
|
|
"<C-n>" = [
|
|
|
|
(lib.generators.mkLuaInline ''''
|
|
|
|
function(cmp)
|
|
|
|
if some_condition then return end -- runs the next command
|
|
|
|
return true -- doesn't run the next command
|
|
|
|
end,
|
|
|
|
'''')
|
|
|
|
"select_next"
|
|
|
|
];
|
|
|
|
};
|
2024-12-23 02:51:21 +01:00
|
|
|
```
|
|
|
|
'';
|
2024-12-23 01:24:06 +01:00
|
|
|
};
|
|
|
|
};
|
2024-12-23 03:59:57 +01:00
|
|
|
|
|
|
|
mappings = {
|
|
|
|
complete = mkMappingOption "Complete [blink.cmp]" "<C-Space>";
|
|
|
|
confirm = mkMappingOption "Confirm [blink.cmp]" "<CR>";
|
|
|
|
next = mkMappingOption "Next item [blink.cmp]" "<Tab>";
|
|
|
|
previous = mkMappingOption "Previous item [blink.cmp]" "<S-Tab>";
|
|
|
|
close = mkMappingOption "Close [blink.cmp]" "<C-e>";
|
|
|
|
scrollDocsUp = mkMappingOption "Scroll docs up [blink.cmp]" "<C-d>";
|
|
|
|
scrollDocsDown = mkMappingOption "Scroll docs down [blink.cmp]" "<C-f>";
|
|
|
|
};
|
2024-12-23 01:24:06 +01:00
|
|
|
};
|
|
|
|
}
|