neovim-flake/modules/plugins/completion/blink-cmp/blink-cmp.nix

65 lines
2 KiB
Nix
Raw Normal View History

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 03:59:57 +01:00
inherit (lib.types) listOf str either attrsOf submodule enum;
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;
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 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;
description = "Default list of sources to enable for completion.";
default = ["lsp" "path" "snippets" "buffer"];
};
};
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
};
}