mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 20:30:05 +08:00
Fix autocomplete layer options (#3786)
close https://github.com/SpaceVim/SpaceVim/issues/3783
This commit is contained in:
parent
dd628c0c0e
commit
f41a2df34b
@ -26,6 +26,18 @@
|
||||
" directory is `~/.SpaceVim/snippets/`. If `g:spacevim_force_global_config = 1`,
|
||||
" SpaceVim will not append `./.SpaceVim/snippets` as default snippets directory.
|
||||
|
||||
|
||||
if exists('s:return_key_behavior')
|
||||
finish
|
||||
else
|
||||
let s:return_key_behavior = 'smart'
|
||||
let s:tab_key_behavior = 'smart'
|
||||
let g:_spacevim_key_sequence = 'nil'
|
||||
let s:key_sequence_delay = 1
|
||||
let g:_spacevim_autocomplete_delay = 50
|
||||
let s:timeoutlen = &timeoutlen
|
||||
endif
|
||||
|
||||
function! SpaceVim#layers#autocomplete#plugins() abort
|
||||
let plugins = [
|
||||
\ [g:_spacevim_root_dir . 'bundle/vim-snippets', { 'on_event' : 'InsertEnter', 'loadconf_before' : 1}],
|
||||
@ -116,7 +128,6 @@ function! SpaceVim#layers#autocomplete#plugins() abort
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#autocomplete#config() abort
|
||||
if g:spacevim_autocomplete_parens
|
||||
imap <expr>(
|
||||
@ -183,14 +194,19 @@ function! SpaceVim#layers#autocomplete#config() abort
|
||||
elseif g:spacevim_snippet_engine ==# 'ultisnips'
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['i', 's'], 'Unite ultisnips', 'insert snippets', 1)
|
||||
endif
|
||||
if !empty(g:_spacevim_key_sequence)
|
||||
if g:spacevim_escape_key_binding !=# g:_spacevim_key_sequence
|
||||
augroup spacevim_layer_autocomplete
|
||||
autocmd!
|
||||
autocmd InsertEnter * call s:apply_sequence_delay()
|
||||
autocmd InsertLeave * call s:restore_sequence_delay()
|
||||
augroup END
|
||||
else
|
||||
call SpaceVim#logger#warn('Can not use same value for escape_key_binding and auto_completion_complete_with_key_sequence')
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:return_key_behavior = 'smart'
|
||||
let s:tab_key_behavior = 'smart'
|
||||
let s:key_sequence = 'nil'
|
||||
let s:key_sequence_delay = 0.1
|
||||
let g:_spacevim_autocomplete_delay = 50
|
||||
|
||||
function! SpaceVim#layers#autocomplete#set_variable(var) abort
|
||||
|
||||
let s:return_key_behavior = get(a:var,
|
||||
@ -203,12 +219,12 @@ function! SpaceVim#layers#autocomplete#set_variable(var) abort
|
||||
\ get(a:var,
|
||||
\ 'auto-completion-tab-key-behavior',
|
||||
\ s:tab_key_behavior))
|
||||
let s:key_sequence = get(a:var,
|
||||
let g:_spacevim_key_sequence = get(a:var,
|
||||
\ 'auto_completion_complete_with_key_sequence',
|
||||
\ get(a:var,
|
||||
\ 'auto-completion-complete-with-key-sequence',
|
||||
\ s:key_sequence))
|
||||
let s:key_sequence_delay = get(a:var,
|
||||
\ g:_spacevim_key_sequence))
|
||||
let g:_spacevim_key_sequence_delay = get(a:var,
|
||||
\ 'auto_completion_complete_with_key_sequence_delay',
|
||||
\ get(a:var,
|
||||
\ 'auto-completion-complete-with-key-sequence-delay',
|
||||
@ -233,6 +249,14 @@ function! SpaceVim#layers#autocomplete#getprfile() abort
|
||||
|
||||
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:apply_sequence_delay() abort
|
||||
let &timeoutlen = s:key_sequence_delay * 1000
|
||||
endfunction
|
||||
|
||||
function! s:restore_sequence_delay() abort
|
||||
let &timeoutlen = s:timeoutlen
|
||||
endfunction
|
||||
|
||||
" vim:set et sw=2 cc=80:
|
||||
|
@ -125,6 +125,9 @@ call deoplete#custom#option('sources', {'cs': ['omnisharp']})
|
||||
" public settings
|
||||
call deoplete#custom#source('_', 'matchers', ['matcher_full_fuzzy'])
|
||||
call deoplete#custom#source('file/include', 'matchers', ['matcher_head'])
|
||||
if !empty(g:_spacevim_key_sequence) && g:spacevim_escape_key_binding !=# g:_spacevim_key_sequence
|
||||
exe printf('inoremap <silent><expr>%s deoplete#manual_complete()', g:_spacevim_key_sequence)
|
||||
endif
|
||||
|
||||
if g:spacevim_autocomplete_parens && exists('g:loaded_delimitMate')
|
||||
imap <expr><C-h> deoplete#smart_close_popup()."<Plug>delimitMateBS"
|
||||
|
@ -68,3 +68,7 @@ inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
|
||||
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
|
||||
inoremap <expr><C-y> neocomplete#close_popup()
|
||||
inoremap <expr><C-e> neocomplete#cancel_popup()
|
||||
|
||||
if !empty(g:_spacevim_key_sequence) && g:spacevim_escape_key_binding !=# g:_spacevim_key_sequence
|
||||
exe printf('imap <silent>%s <Plug>(neocomplete_auto_refresh)', g:_spacevim_key_sequence)
|
||||
endif
|
||||
|
@ -136,8 +136,10 @@ SpaceVim 选项 `snippet_engine` 设置为 `ultisnips`,将使用 [UltiSnips](h
|
||||
- `cycle` 循环模式,自动再补全列表之间循环
|
||||
- `nil` 当设为 nil 时,该行为和 `Tab` 的默认行为一致
|
||||
3. `auto_completion_delay` 设置自动补全延迟时间,默认 50 毫秒
|
||||
4. `auto_completion_complete_with_key_sequence` 设置一个手动补全的由两个字符构成的按键序列,如果你按下这个序列足够快,将会启动补全;如果这一选项的值是 `nil` ,这一特性将被禁用。
|
||||
5. `auto_completion_complete_with_key_sequence_delay` 设置手动补全按键序列延迟时间,默认是 0.1
|
||||
4. `auto_completion_complete_with_key_sequence` 设置一个手动补全的由两个字符构成的按键序列,
|
||||
如果你按下这个序列足够快,将会启动补全;如果这一选项的值是 `nil` ,这一特性将被禁用。
|
||||
**NOTE:** 该选项不可以与全局选项 `escape_key_binding` 使用同一个值。
|
||||
5. `auto_completion_complete_with_key_sequence_delay` 设置手动补全按键序列延迟时间,默认是 1 秒。
|
||||
|
||||
自动补全模块默认载入状态如下:
|
||||
|
||||
|
@ -118,21 +118,23 @@ You can customize the user experience of autocompletion with the following layer
|
||||
- `complete` completes with the current selection
|
||||
- `smart` completes with current selection and expand snippet or argvs
|
||||
- `nil`
|
||||
By default it is `complete`.
|
||||
By default it is `complete`.
|
||||
2. `auto_completion_tab_key_behavior` set the action to
|
||||
perform when the `TAB` key is pressed, the possible values are:
|
||||
- `smart` cycle candidates, expand snippets, jump parameters
|
||||
- `complete` completes with the current selection
|
||||
- `cycle` completes the common prefix and cycle between candidates
|
||||
- `nil` insert a carriage return
|
||||
By default it is `complete`.
|
||||
By default it is `complete`.
|
||||
3. `auto_completion_delay` is a number to delay the completion after input in milliseconds,
|
||||
by default it is 50 ms.
|
||||
4. `auto_completion_complete_with_key_sequence` is a string of two characters denoting
|
||||
a key sequence that will perform a `complete` action if the sequence as been entered
|
||||
quickly enough. If its value is `nil` then the feature is disabled.
|
||||
**NOTE:** This option should not has same value as `escape_key_binding`
|
||||
5. `auto_completion_complete_with_key_sequence_delay` is the number of seconds to wait for
|
||||
the autocompletion key sequence to be entered. The default value is 0.1 seconds.
|
||||
the autocompletion key sequence to be entered. The default value is 1 seconds.
|
||||
This option is used for vim's `timeoutlen` option in insert mode.
|
||||
|
||||
The default configuration of the layer is:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user