@@ -5,9 +5,10 @@ source shared.vim
55
66func s: get_rcs ()
77 let rcs = {
8- \ ' file1' : { ' path' : ' ~/.vimrc' },
9- \ ' file2' : { ' path' : ' ~/.vim/vimrc' },
10- \ ' xdg' : { ' path' : exists (' $XDG_CONFIG_HOME' ) ? ' $XDG_CONFIG_HOME' : " ~/.config" },
8+ \ ' file1' : { ' path' : ' ~/.vimrc' , ' dir' : expand (' ~/.vim/' ) },
9+ \ ' file2' : { ' path' : ' ~/.vim/vimrc' , ' dir' : expand (' ~/.vim/' ) },
10+ \ ' xdg' : { ' path' : exists (' $XDG_CONFIG_HOME' ) ? ' $XDG_CONFIG_HOME' : " ~/.config" ,
11+ \ ' dir' : exists (' $XDG_CONFIG_HOME' ) ? expand (" $XDG_CONFIG_HOME/vim" ) : ' ~/.config/vim/' },
1112 \}
1213 for v in values (rcs)
1314 let v .exists = filereadable (expand (v .path ))
@@ -20,18 +21,24 @@ func Test_xdg_rc_detection()
2021 let rc = s: get_rcs ()
2122 let before = << trim CODE
2223 call writefile ([expand (' $MYVIMRC' )], " XMY_VIMRC" )
24+ call writefile ([expand (' $MYVIMRCDIR' )], " XMY_VIMDIR" )
2325 quit !
2426 CODE
2527 call RunVim (before, [], " " )
2628 let my_rc = readfile (" XMY_VIMRC" )
29+ let my_rcdir = readfile (" XMY_VIMDIR" )
2730 if rc.file1.exists
2831 call assert_equal (rc.file1.path , my_rc)
32+ call assert_equal (rc.file1.dir , my_rcdir)
2933 elseif ! rc.file1.exists && rc.file2.exists
3034 call assert_equal (rc.file2.path , my_rc)
35+ call assert_equal (rc.file2.dir , my_rcdir)
3136 elseif ! rc.file1.exists && ! rc.file2.exists && rc.xdg.exists
3237 call assert_equal (rc.xdg.path , my_rc)
38+ call assert_equal (rc.xdg.dir , my_rcdir)
3339 endif
3440 call delete (" XMY_VIMRC" )
41+ call delete (" XMY_VIMDIR" )
3542endfunc
3643
3744func Test_xdg_runtime_files ()
@@ -78,6 +85,7 @@ func Test_xdg_runtime_files()
7885 " Test for ~/.vimrc
7986 let lines = << trim END
8087 call assert_match (' XfakeHOME/\.vimrc' , $MYVIMRC )
88+ call assert_match (' XfakeHOME/.vim/' , $MYVIMDIR )
8189 call filter (g: , {idx, _ - > idx = ~ ' ^rc' })
8290 call assert_equal (#{rc_one: ' one' , rc: ' .vimrc' }, g: )
8391 call assert_match (' XfakeHOME/\.vim/view' , &viewdir )
@@ -93,6 +101,7 @@ func Test_xdg_runtime_files()
93101 " Test for ~/.vim/vimrc
94102 let lines = << trim END
95103 call assert_match (' XfakeHOME/\.vim/vimrc' , $MYVIMRC )
104+ call assert_match (' XfakeHOME/\.vim/' , $MYVIMDIR )
96105 call filter (g: , {idx, _ - > idx = ~ ' ^rc' })
97106 call assert_equal (#{rc_two: ' two' , rc: ' .vim/vimrc' }, g: )
98107 call assert_match (' XfakeHOME/\.vim/view' , &viewdir )
@@ -112,6 +121,7 @@ func Test_xdg_runtime_files()
112121 let lines = << trim END
113122 let msg = $ ' HOME="{$HOME}", ~="{expand("~")}"'
114123 call assert_match (' XfakeHOME/\.config/vim/vimrc' , $MYVIMRC , msg)
124+ call assert_match (' XfakeHOME/\.config/vim/' , $MYVIMDIR , msg)
115125 call filter (g: , {idx, _ - > idx = ~ ' ^rc' })
116126 call assert_equal (#{rc_three: ' three' , rc: ' .config/vim/vimrc' }, g: )
117127 call assert_match (' XfakeHOME/\.config/vim/view' , &viewdir )
@@ -129,6 +139,7 @@ func Test_xdg_runtime_files()
129139 let lines = << trim END
130140 let msg = $ ' HOME="{$HOME}", XDG_CONFIG_HOME="{$XDG_CONFIG_HOME}"'
131141 call assert_match (' XfakeHOME/xdg/vim/vimrc' , $MYVIMRC , msg)
142+ call assert_match (' XfakeHOME/xdg/vim/' , $MYVIMDIR , msg)
132143 call filter (g: , {idx, _ - > idx = ~ ' ^rc' })
133144 call assert_equal (#{rc_four: ' four' , rc: ' xdg/vim/vimrc' }, g: )
134145 call assert_match ('XfakeHOME/xdg/ vim /view , &viewdir )
@@ -225,6 +236,7 @@ func Test_zzz_xdg_runtime_files()
225236 call test_ignore_error (' E285' )
226237 gui - f
227238 call assert_match (' Xhome/\.gvimrc' , $MYGVIMRC )
239+ call assert_match (' Xhome/\.vim/' , $MYVIMDIR )
228240 call filter (g: , {idx, _ - > idx = ~ ' ^rc' })
229241 call assert_equal (#{rc_one: ' one' , rc: ' .gvimrc' }, g: )
230242 call writefile (v: errors , ' Xresult' )
@@ -242,6 +254,7 @@ func Test_zzz_xdg_runtime_files()
242254 call test_ignore_error (' E285' )
243255 gui - f
244256 call assert_match (' Xhome/\.vim/gvimrc' , $MYGVIMRC )
257+ call assert_match (' Xhome/\.vim/' , $MYVIMDIR )
245258 call filter (g: , {idx, _ - > idx = ~ ' ^rc' })
246259 call assert_equal (#{rc_two: ' two' , rc: ' .vim/gvimrc' }, g: )
247260 call writefile (v: errors , ' Xresult' )
@@ -260,6 +273,7 @@ func Test_zzz_xdg_runtime_files()
260273 gui - f
261274 let msg = $ ' HOME="{$HOME}", ~="{expand("~")}"'
262275 call assert_match (' Xhome/\.config/vim/gvimrc' , $MYGVIMRC , msg)
276+ call assert_match (' Xhome/\.config/vim/' , $MYVIMDIR , msg)
263277 call filter (g: , {idx, _ - > idx = ~ ' ^rc' })
264278 call assert_equal (#{rc_three: ' three' , rc: ' .config/vim/gvimrc' }, g: )
265279 call writefile (v: errors , ' Xresult' )
@@ -279,6 +293,7 @@ func Test_zzz_xdg_runtime_files()
279293 gui - f
280294 let msg = $ ' HOME="{$HOME}", XDG_CONFIG_HOME="{$XDG_CONFIG_HOME}"'
281295 call assert_match (' Xhome/xdg/vim/gvimrc' , $MYGVIMRC , msg)
296+ call assert_match (' Xhome/xdg/vim/' , $MYVIMDIR , msg)
282297 call filter (g: , {idx, _ - > idx = ~ ' ^rc' })
283298 call assert_equal (#{rc_four: ' four' , rc: ' xdg/vim/gvimrc' }, g: )
284299 call writefile (v: errors , ' Xresult' )
0 commit comments