Skip to content

Commit 563ea55

Browse files
committed
plugins/blink-cmp: add rawLua support more provider options
1 parent e77af9f commit 563ea55

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

plugins/by-name/blink-cmp/provider-config.nix

+24-29
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
lib:
22
let
33
inherit (lib) types;
4-
inherit (lib.nixvim)
5-
mkNullOrOption
6-
mkNullOrStr'
7-
mkNullOrOption'
8-
;
4+
inherit (lib.nixvim) defaultNullOpts;
95
in
106
types.submodule {
117
freeformType = with types; attrsOf anything;
128
options = {
13-
name = mkNullOrStr' {
9+
name = defaultNullOpts.mkStr' {
10+
pluginDefault = null;
1411
description = ''
1512
The name of the source.
1613
'';
1714
example = "LSP";
1815
};
1916

20-
module = mkNullOrStr' {
17+
module = defaultNullOpts.mkStr' {
18+
pluginDefault = null;
2119
description = ''
2220
The module name to load.
2321
'';
2422
example = "blink.cmp.sources.lsp";
2523
};
2624

27-
enabled = mkNullOrOption' {
28-
type = with types; maybeRaw bool;
25+
enabled = defaultNullOpts.mkBool' {
26+
pluginDefault = true;
2927
description = ''
3028
Whether or not to enable the provider.
3129
'';
@@ -36,25 +34,21 @@ types.submodule {
3634
'';
3735
};
3836

39-
opts = mkNullOrOption' {
40-
type = with types; attrsOf anything;
41-
description = ''
42-
Options for this provider.
43-
'';
44-
example = { };
45-
};
37+
opts = defaultNullOpts.mkAttrsOf types.anything null ''
38+
Options for this provider.
39+
'';
4640

47-
async = mkNullOrOption types.bool ''
41+
async = defaultNullOpts.mkBool false ''
4842
Whether blink should wait for the source to return before showing the completions.
4943
'';
5044

51-
timeout_ms = mkNullOrOption types.ints.unsigned ''
45+
timeout_ms = defaultNullOpts.mkUnsignedInt 2000 ''
5246
How long to wait for the provider to return before showing completions and treating it as
5347
asynchronous.
5448
'';
5549

56-
transform_items = mkNullOrOption' {
57-
type = types.rawLua;
50+
transform_items = defaultNullOpts.mkRaw' {
51+
pluginDefault = ''function(_, items) return items end'';
5852
description = ''
5953
Function to transform the items before they're returned.
6054
'';
@@ -76,40 +70,41 @@ types.submodule {
7670
'';
7771
};
7872

79-
should_show_items = mkNullOrOption types.bool ''
73+
should_show_items = defaultNullOpts.mkBool true ''
8074
Whether or not to show the items.
8175
'';
8276

83-
max_items = mkNullOrOption types.ints.unsigned ''
77+
max_items = defaultNullOpts.mkUnsignedInt null ''
8478
Maximum number of items to display in the menu.
8579
'';
8680

87-
min_keyword_length = mkNullOrOption types.ints.unsigned ''
81+
min_keyword_length = defaultNullOpts.mkUnsignedInt 0 ''
8882
Minimum number of characters in the keyword to trigger the provider.
8983
'';
9084

91-
fallbacks = mkNullOrOption' {
92-
type = with types; listOf str;
85+
fallbacks = defaultNullOpts.mkListOf' {
86+
type = types.str;
87+
pluginDefault = [ ];
9388
description = ''
9489
If this provider returns `0` items, it will fallback to these providers.
9590
'';
9691
example = [ "buffer" ];
9792
};
9893

99-
score_offset = mkNullOrOption' {
100-
type = types.int;
94+
score_offset = defaultNullOpts.mkInt' {
95+
pluginDefault = 0;
10196
description = ''
10297
Boost/penalize the score of the items.
10398
'';
10499
example = 3;
105100
};
106101

107-
deduplicate = mkNullOrOption types.anything ''
102+
deduplicate = defaultNullOpts.mkNullableWithRaw types.anything null ''
108103
Warning: not yet implemented.
109104
'';
110105

111106
# https://github.com/Saghen/blink.cmp/blob/main/lua/blink/cmp/sources/lib/types.lua#L22
112-
override = mkNullOrOption (with types; attrsOf anything) ''
107+
override = defaultNullOpts.mkAttrsOf types.anything null ''
113108
Override source options.
114109
'';
115110
};

0 commit comments

Comments
 (0)