Skip to content

Commit

Permalink
firenvim#install: capture $XDG env vars
Browse files Browse the repository at this point in the history
Fixes an issue Dundar encountered with ubuntu's login manager not
sourcing his shell configuration.
  • Loading branch information
glacambre committed Jan 12, 2022
1 parent 31befdf commit f17b672
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions autoload/firenvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 533,17 @@ function! s:get_progpath() abort
return l:result
endfunction

function! s:capture_env_var(var) abort
let l:value = eval('$' . a:var)
if l:value == ''
return ''
endif
return 'if [ ! -n "$' . a:var . '" ]; then' . "\n" .
\' ' . a:var . "='" . l:value . "'\n" .
\' export ' . a:var . "\n" .
\"fi\n"
endfunction

function! s:get_executable_content(data_dir, prolog) abort
if has('win32') || s:is_wsl
let l:wsl_prefix = ''
Expand All @@ -558,6 569,13 @@ function! s:get_executable_content(data_dir, prolog) abort
\ 'if [ -n "$VIMRUNTIME" ] && [ ! -d "$VIMRUNTIME" ]; then' . "\n" .
\ " unset VIMRUNTIME\n" .
\ "fi\n" .
\ s:capture_env_var('XDG_DATA_HOME') .
\ s:capture_env_var('XDG_CONFIG_HOME') .
\ s:capture_env_var('XDG_STATE_HOME') .
\ s:capture_env_var('XDG_DATA_DIRS') .
\ s:capture_env_var('XDG_CONFIG_DIRS') .
\ s:capture_env_var('XDG_CACHE_HOME') .
\ s:capture_env_var('XDG_RUNTIME_DIR') .
\ a:prolog . "\n" .
\ "exec '" . s:get_progpath() . "' --headless --cmd 'let g:started_by_firenvim = v:true' -c 'call firenvim#run()'\n"
endfunction
Expand Down

0 comments on commit f17b672

Please sign in to comment.