File tree Expand file tree Collapse file tree 2 files changed +40
-9
lines changed
tests/test-sources/modules Expand file tree Collapse file tree 2 files changed +40
-9
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
7287 lib . optionalString ( optionDefinitions != "{ }" ) ''
7388 -- Set up ${ prettyName } {{{
89+ ''
90+ + ( ifGlobals config . globalsPre )
91+ + ''
7492 do
7593 local ${ varName } = ${ optionDefinitions }
7694
7795 for k,v in pairs(${ varName } ) do
7896 vim.${ luaApi } [k] = v
7997 end
8098 end
99+ ''
100+ + ( ifGlobals config . globalsPost )
101+ + ''
81102 -- }}}
82103 ''
83104 ) optionsAttrs
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