Skip to content

Commit 9d3528d

Browse files
committed
query all MaySet() options at once
1 parent 71538f6 commit 9d3528d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

plugin/sensible.vim

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,23 @@ else
2626
endfunction
2727
endif
2828

29+
" initially gathered using: g/MaySet('/"AY
30+
let s:mayset_checks = #{ backspace: 1, smarttab: 1, incsearch: 1, laststatus: 1, ruler: 1, wildmenu: 1, scrolloff: 1, sidescroll: 1, sidescrolloff: 1, listchars: 1, autoread: 1, history: 1, tabpagemax: 1, langremap: 1 }
31+
call filter(s:mayset_checks, { k -> exists('&' . k) })
32+
let s:mayset_check_str = join(values(map(copy(s:mayset_checks), { k -> k . '?' })), ' ')
33+
let s:global_settings = s:Execute('verbose setglobal all lines? ' . s:mayset_check_str)
34+
" 'lines=' delimits the start of the answer
35+
let s:global_settings = substitute(s:global_settings, '.*lines=[^\n]*', '', '') . "\n"
36+
" ^ begins and ends in newline
37+
2938
" Check if an option was set from a file in $HOME. This lets us avoid
3039
" overriding options in the user's vimrc, but still override options in the
3140
" system vimrc.
3241
function! s:MaySet(option) abort
33-
let out = s:Execute('verbose setglobal all ' . a:option . '?')
34-
return out !~# " \\(\\~[\\/][^\n]*\\|Lua\\)$"
42+
"let _ = ! has('&' . a:option) || s:mayset_checks[a:option] " debug: make sure setting was queried
43+
let homerx = " \\(\\~[\\/][^\n]*\\|Lua\\)\n"
44+
"return s:Execute('verbose setglobal all ' . a:option . '?') . "\n" !~# homerx " previous version
45+
return s:global_settings !~# ('\n\(\s\+\|no\)\?' . a:option . '\(=[^\n]*\n\|\n\)' . '[^\n]*' . homerx)
3546
endfunction
3647

3748
if s:MaySet('backspace')

0 commit comments

Comments
 (0)