plugins/blink-cmp: add rawLua support more provider options

This commit is contained in:
Austin Horstman 2025-02-03 13:45:18 -06:00
parent e77af9f81b
commit 563ea5586d
No known key found for this signature in database

View file

@ -1,31 +1,29 @@
lib: lib:
let let
inherit (lib) types; inherit (lib) types;
inherit (lib.nixvim) inherit (lib.nixvim) defaultNullOpts;
mkNullOrOption
mkNullOrStr'
mkNullOrOption'
;
in in
types.submodule { types.submodule {
freeformType = with types; attrsOf anything; freeformType = with types; attrsOf anything;
options = { options = {
name = mkNullOrStr' { name = defaultNullOpts.mkStr' {
pluginDefault = null;
description = '' description = ''
The name of the source. The name of the source.
''; '';
example = "LSP"; example = "LSP";
}; };
module = mkNullOrStr' { module = defaultNullOpts.mkStr' {
pluginDefault = null;
description = '' description = ''
The module name to load. The module name to load.
''; '';
example = "blink.cmp.sources.lsp"; example = "blink.cmp.sources.lsp";
}; };
enabled = mkNullOrOption' { enabled = defaultNullOpts.mkBool' {
type = with types; maybeRaw bool; pluginDefault = true;
description = '' description = ''
Whether or not to enable the provider. Whether or not to enable the provider.
''; '';
@ -36,25 +34,21 @@ types.submodule {
''; '';
}; };
opts = mkNullOrOption' { opts = defaultNullOpts.mkAttrsOf types.anything null ''
type = with types; attrsOf anything; Options for this provider.
description = '' '';
Options for this provider.
'';
example = { };
};
async = mkNullOrOption types.bool '' async = defaultNullOpts.mkBool false ''
Whether blink should wait for the source to return before showing the completions. Whether blink should wait for the source to return before showing the completions.
''; '';
timeout_ms = mkNullOrOption types.ints.unsigned '' timeout_ms = defaultNullOpts.mkUnsignedInt 2000 ''
How long to wait for the provider to return before showing completions and treating it as How long to wait for the provider to return before showing completions and treating it as
asynchronous. asynchronous.
''; '';
transform_items = mkNullOrOption' { transform_items = defaultNullOpts.mkRaw' {
type = types.rawLua; pluginDefault = ''function(_, items) return items end'';
description = '' description = ''
Function to transform the items before they're returned. Function to transform the items before they're returned.
''; '';
@ -76,40 +70,41 @@ types.submodule {
''; '';
}; };
should_show_items = mkNullOrOption types.bool '' should_show_items = defaultNullOpts.mkBool true ''
Whether or not to show the items. Whether or not to show the items.
''; '';
max_items = mkNullOrOption types.ints.unsigned '' max_items = defaultNullOpts.mkUnsignedInt null ''
Maximum number of items to display in the menu. Maximum number of items to display in the menu.
''; '';
min_keyword_length = mkNullOrOption types.ints.unsigned '' min_keyword_length = defaultNullOpts.mkUnsignedInt 0 ''
Minimum number of characters in the keyword to trigger the provider. Minimum number of characters in the keyword to trigger the provider.
''; '';
fallbacks = mkNullOrOption' { fallbacks = defaultNullOpts.mkListOf' {
type = with types; listOf str; type = types.str;
pluginDefault = [ ];
description = '' description = ''
If this provider returns `0` items, it will fallback to these providers. If this provider returns `0` items, it will fallback to these providers.
''; '';
example = [ "buffer" ]; example = [ "buffer" ];
}; };
score_offset = mkNullOrOption' { score_offset = defaultNullOpts.mkInt' {
type = types.int; pluginDefault = 0;
description = '' description = ''
Boost/penalize the score of the items. Boost/penalize the score of the items.
''; '';
example = 3; example = 3;
}; };
deduplicate = mkNullOrOption types.anything '' deduplicate = defaultNullOpts.mkNullableWithRaw types.anything null ''
Warning: not yet implemented. Warning: not yet implemented.
''; '';
# https://github.com/Saghen/blink.cmp/blob/main/lua/blink/cmp/sources/lib/types.lua#L22 # https://github.com/Saghen/blink.cmp/blob/main/lua/blink/cmp/sources/lib/types.lua#L22
override = mkNullOrOption (with types; attrsOf anything) '' override = defaultNullOpts.mkAttrsOf types.anything null ''
Override source options. Override source options.
''; '';
}; };