diff --git a/README.md b/README.md index 1595507..4aaad69 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,16 @@ You can also enter `:Fittenlogout` to log out. 您还可以输入`:Fittenlogout`登出。 +You can customize the following global variables in your vimrc: + +- `g:fitten_updatetime`: set `updatetime` for auto completion trigger (default: `400`). +- `g:fitten_auto_completion`: enable/disable auto completion (default: `1`). + +您可以在 vimrc 中自定义以下全局变量: + +- `g:fitten_updatetime`: 设置自动补全触发的 `updatetime`(默认值:`400`)。 +- `g:fitten_auto_completion`: 开启/关闭自动补全(默认值:`1`)。 + For more advanced usage, esp. using your own trigger functions, see `:help fitten-advanced`. 有关更高级的用法,特别是使用您自己的触发器函数,请参阅`:help fitten advanced`。 diff --git a/plugin/fittencode.vim b/plugin/fittencode.vim index df6aa76..8d19ff7 100644 --- a/plugin/fittencode.vim +++ b/plugin/fittencode.vim @@ -22,7 +22,9 @@ function! SetSuggestionStyle() abort endif endfunction -let g:fitten_auto_completion = 0 +if !exists('g:fitten_auto_completion') + let g:fitten_auto_completion = 1 +endif function! Fittenlogin(account, password) let l:login_url = 'https://fc.fittenlab.cn/codeuser/login' @@ -263,14 +265,8 @@ function! CodeAutoCompletion() let g:accept_just_now = g:accept_just_now - 1 return "" endif - if col('.') == col('$') - call CodeCompletion() - return "" - endif - if empty(substitute(getline('.')[col('.') - 1:], '\s', '', 'g')) - call CodeCompletion() - return "" - endif + call CodeCompletion() + return "" endfunction function! FittenAcceptMain() @@ -335,6 +331,10 @@ endif if !exists('g:fitten_login_status') let g:fitten_login_status = CheckLoginStatus() endif +if !exists('g:fitten_updatetime') + let g:fitten_updatetime = 400 +endif +execute 'set updatetime=' . g:fitten_updatetime function! FittenMapping() execute "inoremap" keytrans(g:fitten_trigger) 'call CodeCompletion()' if g:fitten_accept_key isnot v:none @@ -354,7 +354,6 @@ augroup fittencode autocmd ColorScheme,VimEnter * call SetSuggestionStyle() " Map tab using vim enter so it occurs after all other sourcing. autocmd VimEnter * call FittenMapping() - set updatetime=1500 autocmd CursorHoldI * if g:fitten_auto_completion == 1 | call CodeAutoCompletion() | endif autocmd TextChangedI * call s:UpdateVirtualTextOnInput() augroup END