Skip to content

Commit d0992e2

Browse files
gpandershaze
authored andcommitted
Allow user to specify std dir
Running 'zig env' adds a considerable amount of time to startup, and the relevant result (the std directory) doesn't typically change often. Allow users to manually specify the std dir through the g:zig_std_dir global variable and fallback to calling 'zig env' only if this variable doesn't exist.
1 parent b30e6f8 commit d0992e2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ftplugin/zig.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ endif
3535

3636
let &l:define='\v(<fn>|<const>|<var>|^\s*\#\s*define)'
3737

38-
if exists("*json_decode") && executable('zig')
38+
if !exists('g:zig_std_dir') && exists('*json_decode') && executable('zig')
3939
silent let s:env = system('zig env')
4040
if v:shell_error == 0
41-
let &l:path=json_decode(s:env)['std_dir'] . ',' . &l:path
41+
let g:zig_std_dir = json_decode(s:env)['std_dir']
4242
endif
4343
unlet! s:env
4444
endif
4545

46+
if exists('g:zig_std_dir')
47+
let &l:path = g:zig_std_dir . ',' . &l:path
48+
endif
49+
4650
let b:undo_ftplugin =
4751
\ 'setl isk< et< ts< sts< sw< fo< sua< mp< com< cms< inex< inc< pa<'
4852

0 commit comments

Comments
 (0)