diff options
-rw-r--r-- | autoload/deoplete/custom.vim | 17 | ||||
-rw-r--r-- | doc/deoplete.txt | 7 | ||||
-rw-r--r-- | test/autoload/deoplete/custom.vim | 10 |
3 files changed, 21 insertions, 13 deletions
diff --git a/autoload/deoplete/custom.vim b/autoload/deoplete/custom.vim index f327068..2b77188 100644 --- a/autoload/deoplete/custom.vim +++ b/autoload/deoplete/custom.vim @@ -64,34 +64,29 @@ function! deoplete#custom#_get_source_vars(name) abort return extend(copy(global_vars), buffer_vars) endfunction -function! deoplete#custom#source(source_name, option_name, value) abort - let value = index([ - \ 'converters', 'disabled_syntaxes', - \ 'filetypes', 'matchers', 'sorters', - \ ], a:option_name) < 0 ? a:value : - \ deoplete#util#convert2list(a:value) +function! deoplete#custom#source(source_name, name_or_dict, ...) abort for key in deoplete#util#split(a:source_name) let custom_source = deoplete#custom#_get_source(key) - let custom_source[a:option_name] = value + call s:set_custom(custom_source, a:name_or_dict, get(a:000, 0, '')) endfor endfunction -function! deoplete#custom#var(source_name, var_name, value) abort +function! deoplete#custom#var(source_name, name_or_dict, ...) abort for key in deoplete#util#split(a:source_name) let custom_source = deoplete#custom#_get_source(key) let vars = get(custom_source, 'vars', {}) - call s:set_value(vars, a:var_name, a:value) + call s:set_custom(vars, a:name_or_dict, get(a:000, 0, '')) call deoplete#custom#source(key, 'vars', vars) endfor endfunction -function! deoplete#custom#buffer_var(source_name, var_name, value) abort +function! deoplete#custom#buffer_var(source_name, name_or_dict, ...) abort let custom = deoplete#custom#_get_buffer().source_vars for key in deoplete#util#split(a:source_name) if !has_key(custom, key) let custom[key] = {} endif let vars = custom[key] - call s:set_value(vars, a:var_name, a:value) + call s:set_custom(vars, a:name_or_dict, get(a:000, 0, '')) endfor endfunction diff --git a/doc/deoplete.txt b/doc/deoplete.txt index e14a1c8..02b64ae 100644 --- a/doc/deoplete.txt +++ b/doc/deoplete.txt @@ -361,6 +361,7 @@ deoplete#custom#buffer_option({dict}) *deoplete#custom#buffer_var()* deoplete#custom#buffer_var({source-name}, {var-name}, {value}) +deoplete#custom#buffer_var({source-name}, {dict}) The buffer local version of |deoplete#custom#var()|. *deoplete#custom#option()* @@ -372,11 +373,14 @@ deoplete#custom#option({dict}) *deoplete#custom#source()* deoplete#custom#source({source-name}, {option-name}, {value}) +deoplete#custom#source({source-name}, {dict}) Set {source-name} source specialized {option-name} to {value}. You may specify multiple sources with separating "," in {source-name}. If {source-name} is "_", sources default option will be change. + If {dict} is available, the key is {option-name} and the value + is {value}. Note: You must call it before using deoplete. > " Examples: @@ -427,9 +431,12 @@ deoplete#custom#source({source-name}, {option-name}, {value}) < *deoplete#custom#var()* deoplete#custom#var({source-name}, {var-name}, {value}) +deoplete#custom#var({source-name}, {dict}) Set {source-name} source specialized variable {variable-name} to {value}. You may specify multiple sources with the separator "," in {source-name}. + If {dict} is available, the key is {option-name} and the value + is {value}. ------------------------------------------------------------------------------ KEY MAPPINGS *deoplete-key-mappings* diff --git a/test/autoload/deoplete/custom.vim b/test/autoload/deoplete/custom.vim index 9155c9a..4306e0c 100644 --- a/test/autoload/deoplete/custom.vim +++ b/test/autoload/deoplete/custom.vim @@ -21,15 +21,21 @@ function! s:suite.custom_source() abort call deoplete#custom#source('buffer', \ 'min_pattern_length', 9999) call deoplete#custom#source('buffer', 'rank', 9999) + call deoplete#custom#source('buffer', {'filetypes': []}) + call s:assert.equals( + \ deoplete#custom#_get_source('buffer').filetypes, []) + call s:assert.equals( + \ deoplete#custom#_get_source('buffer').rank, 9999) call deoplete#custom#var('file', 'force_completion_length', 2) + call deoplete#custom#var('file', {'foo': -1, 'bar': 1}) call s:assert.equals( \ deoplete#custom#_get_source_vars('file'), - \ {'force_completion_length' : 2}) + \ {'force_completion_length' : 2, 'foo': -1, 'bar': 1}) call deoplete#custom#buffer_var('file', 'force_completion_length', 0) call s:assert.equals( \ deoplete#custom#_get_source_vars('file'), - \ {'force_completion_length' : 0}) + \ {'force_completion_length' : 0, 'foo': -1, 'bar': 1}) endfunction function! s:suite.custom_option() abort |