1
1
lib :
2
2
let
3
3
inherit ( lib ) types ;
4
- inherit ( lib . nixvim )
5
- mkNullOrOption
6
- mkNullOrStr'
7
- mkNullOrOption'
8
- ;
4
+ inherit ( lib . nixvim ) defaultNullOpts ;
9
5
in
10
6
types . submodule {
11
7
freeformType = with types ; attrsOf anything ;
12
8
options = {
13
- name = mkNullOrStr' {
9
+ name = defaultNullOpts . mkStr' {
10
+ pluginDefault = null ;
14
11
description = ''
15
12
The name of the source.
16
13
'' ;
17
14
example = "LSP" ;
18
15
} ;
19
16
20
- module = mkNullOrStr' {
17
+ module = defaultNullOpts . mkStr' {
18
+ pluginDefault = null ;
21
19
description = ''
22
20
The module name to load.
23
21
'' ;
24
22
example = "blink.cmp.sources.lsp" ;
25
23
} ;
26
24
27
- enabled = mkNullOrOption ' {
28
- type = with types ; maybeRaw bool ;
25
+ enabled = defaultNullOpts . mkBool ' {
26
+ pluginDefault = true ;
29
27
description = ''
30
28
Whether or not to enable the provider.
31
29
'' ;
@@ -36,25 +34,21 @@ types.submodule {
36
34
'' ;
37
35
} ;
38
36
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
+ '' ;
46
40
47
- async = mkNullOrOption types . bool ''
41
+ async = defaultNullOpts . mkBool false ''
48
42
Whether blink should wait for the source to return before showing the completions.
49
43
'' ;
50
44
51
- timeout_ms = mkNullOrOption types . ints . unsigned ''
45
+ timeout_ms = defaultNullOpts . mkUnsignedInt 2000 ''
52
46
How long to wait for the provider to return before showing completions and treating it as
53
47
asynchronous.
54
48
'' ;
55
49
56
- transform_items = mkNullOrOption ' {
57
- type = types . rawLua ;
50
+ transform_items = defaultNullOpts . mkRaw ' {
51
+ pluginDefault = ''function(_, items) return items end'' ;
58
52
description = ''
59
53
Function to transform the items before they're returned.
60
54
'' ;
@@ -76,40 +70,41 @@ types.submodule {
76
70
'' ;
77
71
} ;
78
72
79
- should_show_items = mkNullOrOption types . bool ''
73
+ should_show_items = defaultNullOpts . mkBool true ''
80
74
Whether or not to show the items.
81
75
'' ;
82
76
83
- max_items = mkNullOrOption types . ints . unsigned ''
77
+ max_items = defaultNullOpts . mkUnsignedInt null ''
84
78
Maximum number of items to display in the menu.
85
79
'' ;
86
80
87
- min_keyword_length = mkNullOrOption types . ints . unsigned ''
81
+ min_keyword_length = defaultNullOpts . mkUnsignedInt 0 ''
88
82
Minimum number of characters in the keyword to trigger the provider.
89
83
'' ;
90
84
91
- fallbacks = mkNullOrOption' {
92
- type = with types ; listOf str ;
85
+ fallbacks = defaultNullOpts . mkListOf' {
86
+ type = types . str ;
87
+ pluginDefault = [ ] ;
93
88
description = ''
94
89
If this provider returns `0` items, it will fallback to these providers.
95
90
'' ;
96
91
example = [ "buffer" ] ;
97
92
} ;
98
93
99
- score_offset = mkNullOrOption ' {
100
- type = types . int ;
94
+ score_offset = defaultNullOpts . mkInt ' {
95
+ pluginDefault = 0 ;
101
96
description = ''
102
97
Boost/penalize the score of the items.
103
98
'' ;
104
99
example = 3 ;
105
100
} ;
106
101
107
- deduplicate = mkNullOrOption types . anything ''
102
+ deduplicate = defaultNullOpts . mkNullableWithRaw types . anything null ''
108
103
Warning: not yet implemented.
109
104
'' ;
110
105
111
106
# 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 ''
113
108
Override source options.
114
109
'' ;
115
110
} ;
0 commit comments