mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 12:44:27 +08:00
Store internal values in s:options. Close #79.
This commit is contained in:
@@ -11,22 +11,42 @@
|
|||||||
"let delimitMate_loaded = 1
|
"let delimitMate_loaded = 1
|
||||||
|
|
||||||
if !exists('s:options')
|
if !exists('s:options')
|
||||||
let options = {}
|
let s:options = {}
|
||||||
endif
|
endif
|
||||||
function! s:s(name, value, ...) "{{{
|
function! s:s(name, value, ...) "{{{
|
||||||
let scope = (a:0 ? a:1 : 'b') . ':'
|
let scope = a:0 ? a:1 : 's'
|
||||||
let prefix = (!a:0 || a:0 && a:1 == 's' ? '_l_' : '') . 'delimitMate_'
|
let bufnr = bufnr('%')
|
||||||
exec 'let ' . scope . prefix . a:name . ' = a:value'
|
if !exists('s:options[bufnr]')
|
||||||
|
let s:options[bufnr] = {}
|
||||||
|
endif
|
||||||
|
if scope == 's'
|
||||||
|
let name = 'options.' . bufnr . '.' . a:name
|
||||||
|
else
|
||||||
|
let name = 'delimitMate_' . a:name
|
||||||
|
endif
|
||||||
|
exec 'let ' . scope . ':' . name . ' = a:value'
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:g(name, ...) "{{{
|
function! s:g(name, ...) "{{{
|
||||||
let scope = (a:0 ? a:1 : 'b') . ':'
|
let scope = a:0 ? a:1 : 's'
|
||||||
let prefix = (!a:0 || a:0 && a:1 == 's' ? '_l_' : '') . 'delimitMate_'
|
if scope == 's'
|
||||||
return eval(scope . prefix . a:name)
|
let bufnr = bufnr('%')
|
||||||
|
let name = 'options.' . bufnr . '.' . a:name
|
||||||
|
else
|
||||||
|
let name = 'delimitMate_' . a:name
|
||||||
|
endif
|
||||||
|
return eval(scope . ':' . name)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:exists(name, ...) "{{{
|
function! s:exists(name, ...) "{{{
|
||||||
return exists((a:0 ? a:1 : 's') . ':' . a:name)
|
let scope = a:0 ? a:1 : 's'
|
||||||
|
if scope == 's'
|
||||||
|
let bufnr = bufnr('%')
|
||||||
|
let name = 'options.' . bufnr . '.' . a:name
|
||||||
|
else
|
||||||
|
let name = 'delimitMate_' . a:name
|
||||||
|
endif
|
||||||
|
return exists(scope . ':' . name)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#Set(...) "{{{
|
function! delimitMate#Set(...) "{{{
|
||||||
@@ -576,10 +596,9 @@ function! delimitMate#TestMappings() "{{{
|
|||||||
let optoutput = ['delimitMate Report', '==================', '',
|
let optoutput = ['delimitMate Report', '==================', '',
|
||||||
\ '* Options: ( ) default, (g) global, (b) buffer','']
|
\ '* Options: ( ) default, (g) global, (b) buffer','']
|
||||||
for option in options
|
for option in options
|
||||||
exec 'call add(optoutput, ''('.(exists('b:delimitMate_'.option) ? 'b'
|
let scope = s:exists(option, 'b') ? 'b'
|
||||||
\ : exists('g:delimitMate_'.option) ? 'g' : ' ')
|
\ : s:exists(option, 'g') ? 'g' : ' '
|
||||||
\ .') delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'
|
call add(optoutput, '(' . scope . ')' . ' delimitMate_' . option . ' = ' . string(s:g(option)))
|
||||||
\ .option.'))'
|
|
||||||
endfor
|
endfor
|
||||||
call append(line('$'), optoutput + ['--------------------',''])
|
call append(line('$'), optoutput + ['--------------------',''])
|
||||||
|
|
||||||
@@ -724,11 +743,10 @@ function! delimitMate#OptionsList() "{{{
|
|||||||
\ 'expand_space' : 0,
|
\ 'expand_space' : 0,
|
||||||
\ 'matchpairs' : &matchpairs,
|
\ 'matchpairs' : &matchpairs,
|
||||||
\ 'nesting_quotes' : [],
|
\ 'nesting_quotes' : [],
|
||||||
\ 'offByDefault' : 0
|
|
||||||
\ 'quotes' : '" '' `',
|
\ 'quotes' : '" '' `',
|
||||||
\ 'smart_matchpairs' : '\w',
|
\ 'smart_matchpairs' : '\w',
|
||||||
\ 'smart_quotes' : 1,
|
\ 'smart_quotes' : 1,
|
||||||
}
|
\}
|
||||||
endfunction " delimitMate#OptionsList }}}
|
endfunction " delimitMate#OptionsList }}}
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user