File tree Expand file tree Collapse file tree 2 files changed +51
-18
lines changed
tests/test-sources/modules Expand file tree Collapse file tree 2 files changed +51
-18
lines changed Original file line number Diff line number Diff line change 3636 } ;
3737in
3838{
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+ } ;
4862
4963 # Added 2024-03-29 (do not remove)
5064 imports = lib . mapAttrsToList ( old : new : lib . mkRenamedOptionModule [ old ] [ new ] ) {
6882 let
6983 varName = "nixvim_${ luaVariableName } " ;
7084 optionDefinitions = helpers . toLuaObject config . ${ optionName } ;
85+ ifGlobals = lib . optionalString ( optionName == "globals" ) ;
7186 in
72- lib . optionalString ( optionDefinitions != "{ }" ) ''
73- -- Set up ${ prettyName } {{{
74- do
75- local ${ varName } = ${ optionDefinitions }
87+ lib . optionalString ( optionDefinitions != "{ }" ) (
88+ ''
89+ -- Set up ${ prettyName } {{{
90+ ''
91+ + ( ifGlobals config . globalsPre )
92+ + ''
93+ do
94+ local ${ varName } = ${ optionDefinitions }
7695
77- for k,v in pairs(${ varName } ) do
78- vim.${ luaApi } [k] = v
96+ for k,v in pairs(${ varName } ) do
97+ vim.${ luaApi } [k] = v
98+ end
7999 end
80- end
81- -- }}}
82- ''
100+ ''
101+ + ( ifGlobals config . globalsPost )
102+ + ''
103+ -- }}}
104+ ''
105+ )
83106 ) optionsAttrs
84107 ) ;
85108 in
Original file line number Diff line number Diff line change 2323 } ;
2424
2525 globals = {
26+ globalsPre = ''
27+ dummy = 45
28+ '' ;
2629 globals = {
30+ with_pre . __raw = "dummy" ;
2731 loaded_ruby_provider = 0 ;
2832 loaded_perl_provider = 0 ;
2933 loaded_python_provider = 0 ;
3034 } ;
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+ '' ;
3141 } ;
3242}
You can’t perform that action at this time.
0 commit comments