Skip to content

Commit

Permalink
plugins/blink-cmp: update configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Balssh authored and nix-infra-bot committed Nov 7, 2024
1 parent 898246c commit 77b4958
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 60 deletions.
122 changes: 77 additions & 45 deletions plugins/by-name/blink-cmp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,64 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
'';

settingsOptions = {
keymap =
defaultNullOpts.mkNullableWithRaw (with types; either (attrsOf anything) (enum [ false ]))
{
show = "<C-space>";
hide = "<C-e>";
accept = "<Tab>";
select_prev = [
"<Up>"
"<C-p>"
];
select_next = [
"<Down>"
"<C-n>"
];
show_documentation = "<C-space>";
hide_documentation = "<C-space>";
scroll_documentation_up = "<C-b>";
scroll_documentation_down = "<C-f>";
snippet_forward = "<Tab>";
snippet_backward = "<S-Tab>";
}
''
Customize the keymaps for blink.
'';
keymap = defaultNullOpts.mkNullableWithRaw' {
type = with types; either (attrsOf anything) (enum [ false ]);
pluginDefault = {
preset = "default";
};
example = {
"<C-space>" = [
"show"
"show_documentation"
"hide_documentation"
];
"<C-e>" = [ "hide" ];
"<C-y>" = [ "select_and_accept" ];

"<Up>" = [
"select_prev"
"fallback"
];
"<Down>" = [
"select_next"
"fallback"
];
"<C-p>" = [
"select_prev"
"fallback"
];
"<C-n>" = [
"select_next"
"fallback"
];

"<C-b>" = [
"scroll_documentation_up"
"fallback"
];
"<C-f>" = [
"scroll_documentation_down"
"fallback"
];

"<Tab>" = [
"snippet_forward"
"fallback"
];
"<S-Tab>" = [
"snippet_backward"
"fallback"
];

};
description = ''
The keymap can be:
- A preset (`'default'` | `'super-tab'` | `'enter'`)
- A table of `keys => command[]` (optionally with a "preset" key to merge with a preset)
When specifying 'preset' in the keymap table, the custom key mappings are merged with the preset,
and any conflicting keys will overwrite the preset mappings.
'';
};

highlight = {
use_nvim_cmp_as_default = defaultNullOpts.mkBool false ''
Expand All @@ -61,16 +95,18 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
'';
};

documentation = {
auto_show = defaultNullOpts.mkBool false ''
Enables automatically showing documentation when typing.
'';
auto_show_delay_ms = defaultNullOpts.mkUnsignedInt 500 ''
Delay, in milliseconds, after which documentation is shown.
'';
update_delay_ms = defaultNullOpts.mkUnsignedInt 50 ''
Delay, in milliseconds, after which documentation is updated.
'';
windows = {
documentation = {
auto_show = defaultNullOpts.mkBool false ''
Enables automatically showing documentation when typing.
'';
auto_show_delay_ms = defaultNullOpts.mkUnsignedInt 500 ''
Delay, in milliseconds, after which documentation is shown.
'';
update_delay_ms = defaultNullOpts.mkUnsignedInt 50 ''
Delay, in milliseconds, after which documentation is updated.
'';
};
};

nerd_font_variant =
Expand Down Expand Up @@ -102,17 +138,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {

settingsExample = {
keymap = {
show = "<C-space>";
hide = "<C-e>";
accept = "<C-y>";
select_prev = "<C-p>";
select_next = "<C-n>";
show_documentation = "<C-space>";
hide_documentation = "<C-space>";
scroll_documentation_up = "<C-b>";
scroll_documentation_down = "<C-f>";
snippet_forward = "<Tab>";
snippet_backward = "<S-Tab>";
preset = "default";
};
highlight = {
use_nvim_cmp_as_default = true;
Expand All @@ -131,4 +157,10 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
};
};
};

extraConfig = cfg: {
warnings = lib.optional (cfg.settings ? documentation) ''
Nixvim(plugins.blink): `settings.documentation` does not correspond to a known setting, use `settings.windows.documentation` instead.
'';
};
}
98 changes: 83 additions & 15 deletions tests/test-sources/plugins/by-name/blink-cmp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,18 @@
enable = true;
settings = {
keymap = {
show = "<C-space>";
hide = "<C-e>";
accept = "<Tab>";
select_prev = "<C-p>";
select_next = "<C-n>";
show_documentation = "<C-space>";
hide_documentation = "<C-space>";
scroll_documentation_up = "<C-b>";
scroll_documentation_down = "<C-f>";
snippet_forward = "<Tab>";
snippet_backward = "<S-Tab>";
preset = "default";
};
highlight = {
use_nvim_cmp_as_default = false;
};
nerd_font_variant = "normal";
documentation = {
auto_show = false;
auto_show_delay_ms = 500;
update_delay_ms = 50;
windows = {
documentation = {
auto_show = false;
auto_show_delay_ms = 500;
update_delay_ms = 50;
};
};
accept = {
auto_brackets = {
Expand Down Expand Up @@ -63,4 +55,80 @@
};
};
};

example = {
plugins.blink-cmp = {
enable = true;
settings = {
fuzzy = {
prebuilt_binaries = {
download = false;
};
};
keymap = {
"<C-space>" = [
"show"
"show_documentation"
"hide_documentation"
];
"<C-e>" = [ "hide" ];
"<C-y>" = [ "select_and_accept" ];

"<Up>" = [
"select_prev"
"fallback"
];
"<Down>" = [
"select_next"
"fallback"
];
"<C-p>" = [
"select_prev"
"fallback"
];
"<C-n>" = [
"select_next"
"fallback"
];

"<C-b>" = [
"scroll_documentation_up"
"fallback"
];
"<C-f>" = [
"scroll_documentation_down"
"fallback"
];

"<Tab>" = [
"snippet_forward"
"fallback"
];
"<S-Tab>" = [
"snippet_backward"
"fallback"
];
};
highlight = {
use_nvim_cmp_as_default = true;
};
windows = {
documentation = {
auto_show = true;
};
};
accept = {
auto_brackets = {
enabled = true;
};
};
trigger = {
signature_help = {
enabled = true;
};
};
};

};
};
}

0 comments on commit 77b4958

Please sign in to comment.