Skip to content

Commit

Permalink
sensible.vim: compute setcmd in DefaultSet()
Browse files Browse the repository at this point in the history
Eliminates TranslateDefault()
  • Loading branch information
mralusw committed Mar 21, 2024
1 parent 1a4e74f commit 6550d9c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions plugin/sensible.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ let s:defaultval_no = ['set no', '']
let s:defaultval_checked = ['" ', ''] " translates to comment -> no :set
let s:default_opts = []
let s:default_vals = {}
function! s:DefaultSet(option, value) abort
function! s:DefaultSet(option, setcmd) abort
if exists('&' . a:option)
call add(s:default_opts, a:option)
let s:default_vals[a:option] = a:value
let s:default_vals[a:option] = a:setcmd[0] . a:option . a:setcmd[1]
endif
endfunction
function! s:Default(option, value) abort
Expand Down Expand Up @@ -146,15 +146,9 @@ function! s:MaySet(option) abort
return s:global_settings !~# ('\n\(\s\+\|no\)\?' . a:option . '\(=[^\n]*\n\|\n\)' . '[^\n]*' . s:homerx)
endfunction

function! s:TranslateDefault(opt) abort
if ! s:MaySet(a:opt)
return ''
endif
let val = s:default_vals[a:opt]
return val[0] . a:opt . val[1]
endfunction
function! s:ComputeSettings() abort
return join(map(copy(s:default_opts), 's:TranslateDefault(v:val)'), "\n")
call filter(s:default_opts, 's:MaySet(v:val)')
return join(map(s:default_opts, 's:default_vals[v:val]'), "\n")
endfunction

call s:CheckDefaults()
Expand Down

0 comments on commit 6550d9c

Please sign in to comment.