1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:20:04 +08:00
SpaceVim/bundle/splitjoin.vim/autoload/sj/settings.vim

38 lines
935 B
VimL
Raw Permalink Normal View History

2024-06-27 18:10:36 +08:00
" This function accepts multiple option names and returns the value of the
" first one that is set. It respects buffer-local values before global ones,
" so:
"
" sj#settings#Read('option_foo', 'option_bar')
"
" would read the values of, in sequence:
"
" - b:splitjoin_option_foo
" - g:splitjoin_option_foo
" - b:splitjoin_option_bar
" - g:splitjoin_option_bar
"
" and return the first one that exists. If none exist, it reads the default
" value, if one is set in `g:splitjoin_default_settings`
"
function! sj#settings#Read(...)
let options = a:000
for option in options
if exists('b:splitjoin_'.option)
return b:['splitjoin_'.option]
endif
if exists('g:splitjoin_'.option)
return g:['splitjoin_'.option]
endif
endfor
for option in options
if has_key(g:splitjoin_default_settings, option)
return g:splitjoin_default_settings[option]
endif
endfor
return 0
endfunction