File tree 2 files changed +40
-9
lines changed
tests/test-sources/modules
2 files changed +40
-9
lines changed Original file line number Diff line number Diff line change 36
36
} ;
37
37
in
38
38
{
39
- options = lib . mapAttrs (
40
- _ :
41
- { description , ... } :
42
- lib . mkOption {
43
- type = with lib . types ; attrsOf anything ;
44
- default = { } ;
45
- inherit description ;
46
- }
47
- ) optionsAttrs ;
39
+ options =
40
+ ( lib . mapAttrs (
41
+ _ :
42
+ { description , ... } :
43
+ lib . mkOption {
44
+ type = with lib . types ; attrsOf anything ;
45
+ default = { } ;
46
+ inherit description ;
47
+ }
48
+ ) optionsAttrs )
49
+ // {
50
+ globalsPre = lib . mkOption {
51
+ type = lib . types . lines ;
52
+ default = "" ;
53
+ internal = true ;
54
+ } ;
55
+
56
+ globalsPost = lib . mkOption {
57
+ type = lib . types . lines ;
58
+ default = "" ;
59
+ internal = true ;
60
+ } ;
61
+ } ;
48
62
49
63
# Added 2024-03-29 (do not remove)
50
64
imports = lib . mapAttrsToList ( old : new : lib . mkRenamedOptionModule [ old ] [ new ] ) {
68
82
let
69
83
varName = "nixvim_${ luaVariableName } " ;
70
84
optionDefinitions = helpers . toLuaObject config . ${ optionName } ;
85
+ ifGlobals = lib . optionalString ( optionName == "globals" ) ;
71
86
in
72
87
lib . optionalString ( optionDefinitions != "{ }" ) ''
73
88
-- Set up ${ prettyName } {{{
89
+ ''
90
+ + ( ifGlobals config . globalsPre )
91
+ + ''
74
92
do
75
93
local ${ varName } = ${ optionDefinitions }
76
94
77
95
for k,v in pairs(${ varName } ) do
78
96
vim.${ luaApi } [k] = v
79
97
end
80
98
end
99
+ ''
100
+ + ( ifGlobals config . globalsPost )
101
+ + ''
81
102
-- }}}
82
103
''
83
104
) optionsAttrs
Original file line number Diff line number Diff line change 23
23
} ;
24
24
25
25
globals = {
26
+ globalsPre = ''
27
+ dummy = 45
28
+ '' ;
26
29
globals = {
30
+ with_pre . __raw = "dummy" ;
27
31
loaded_ruby_provider = 0 ;
28
32
loaded_perl_provider = 0 ;
29
33
loaded_python_provider = 0 ;
30
34
} ;
35
+ globalsPost = # lua
36
+ ''
37
+ if vim.g.with_pre ~= dummy then
38
+ print("Mismatch for vim.g.with_pre, expected " .. dummy .. " got " .. vim.g.with_pre)
39
+ end
40
+ '' ;
31
41
} ;
32
42
}
You can’t perform that action at this time.
0 commit comments