smartim
smartim copied to clipboard
插件执行很慢, 有办法改善吗?
表现
每次切换 insert mode/normal mode 都要卡顿 1+ 秒钟
os version
10.13.6 (17G65)
neovim version
NVIM v0.3.1
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GE
NERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20180721-48604-1emkq4l/neovim-0.3.1/build/config -I/tmp/neovim-20180721-48604-1emkq4l/neovim-0.3.1/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20180721-48604-1emkq4l/neovim-
0.3.1/build/src/nvim/auto -I/tmp/neovim-20180721-48604-1emkq4l/neovim-0.3.1/build/include
Compiled by [email protected]
Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/0.3.1/share/nvim"
profile
FUNCTION Smartim_debug_print()
Called 35 times
Total time: 0.000201
Self time: 0.000201
count total (s) self (s)
35 0.000112 if g:smartim_debug == 0
35 0.000035 return
endif
let l:debug_msg = strftime("[%Y-%m-%d_%H:%M:%S]") . ' ' . a:msg
silent call writefile([l:debug_msg], s:smartim_debug_output, "a")
FUNCTION Smartim_SelectSaved()
Called 6 times
Total time: 0.998683
Self time: 0.998595
count total (s) self (s)
6 0.000046 0.000030 call Smartim_debug_print('>>> Smartim_SelectSaved')
6 0.000007 if g:smartim_disable == 1
return
endif
6 0.000016 if exists("b:saved_im")
5 0.998179 silent call system(s:imselect_path . b:saved_im)
5 0.000253 0.000199 call Smartim_debug_print('b:saved_im = ' . b:saved_im)
5 0.000049 0.000035 call Smartim_debug_print('<<< Smartim_SelectSaved returned ' . v:shell_error)
5 0.000006 else
1 0.000006 0.000004 call Smartim_debug_print('<<< Smartim_SelectSaved returned')
1 0.000001 endif
FUNCTION Smartim_SelectDefault()
Called 6 times
Total time: 2.451158
Self time: 2.451045
count total (s) self (s)
6 0.000072 0.000045 call Smartim_debug_print('>>> Smartim_SelectDefault')
6 0.000011 if g:smartim_disable == 1
return
endif
6 1.240610 silent let b:saved_im = system(s:imselect_path)
6 1.209991 silent call system(s:imselect_path . g:smartim_default)
6 0.000295 0.000227 call Smartim_debug_print('b:saved_im = ' . b:saved_im)
6 0.000060 0.000042 call Smartim_debug_print('<<< Smartim_SelectDefault returned ' . v:shell_error)
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
6 2.451158 2.451045 Smartim_SelectDefault()
3 1.810957 0.001447 vimwiki#lst#kbd_o()
2 1.121454 UpdateWiki()
6 0.998683 0.998595 Smartim_SelectSaved()
68 0.325549 0.159666 provider#python3#Call()
22 0.230005 0.045087 airline#highlighter#highlight()
1160 0.199446 0.091035 airline#highlighter#exec()
300 0.193879 0.030343 airline#check_mode()
4 0.167758 0.000608 <SNR>52_airline_refresh()
1 0.165883 0.000090 remote#host#Require()
1 0.165793 0.000084 provider#pythonx#Require()
1 0.165696 provider#Poll()
4 0.137285 0.000617 airline#load_theme()
34 0.123401 0.002495 <SNR>165_completion_begin()
42 0.113324 0.089302 deoplete#init#_context()
56 0.111573 UltiSnips#TrackChange()
2 0.094433 0.000098 <SNR>105_ale_refresh()
2 0.073487 0.000065 <SNR>106_ws_refresh()
19 0.072139 0.001674 <SNR>165_completion_async()
4 0.070579 0.000471 airline#highlighter#load_theme()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
6 2.451158 2.451045 Smartim_SelectDefault()
2 1.121454 UpdateWiki()
6 0.998683 0.998595 Smartim_SelectSaved()
1 0.165696 provider#Poll()
68 0.325549 0.159666 provider#python3#Call()
56 0.111573 UltiSnips#TrackChange()
1160 0.199446 0.091035 airline#highlighter#exec()
42 0.113324 0.089302 deoplete#init#_context()
22 0.230005 0.045087 airline#highlighter#highlight()
305 0.041138 0.036056 airline#extensions#whitespace#check()
1794 0.059424 0.032311 airline#highlighter#get_highlight()
1160 0.031644 <SNR>114_CheckDefined()
578 0.031445 <SNR>114_get_syn()
300 0.193879 0.030343 airline#check_mode()
10 0.029943 UltiSnips#SnippetsInCurrentScope()
1 0.029852 <SNR>157_try_cmd()
2100 0.023175 airline#util#append()
85 0.027792 0.018117 <SNR>161_vimoption2python()
656 0.028307 0.017360 deoplete#custom#_get_option()
313 0.028048 0.016803 airline#extensions#ale#get()
找到 ~/.vim/bundle/smartim/plugin//smartim.vim 这个文件,
在augroup smartim中添加一行:set timeoutlen=0
延迟问题解决!
augroup smartim autocmd! set timeoutlen=0 autocmd VimLeavePre * call Smartim_SelectDefault() autocmd InsertLeave * call Smartim_SelectDefault() "autocmd InsertLeave * call system(s:/Users/apple/.vim/bundle/smartim/plugin/im-select com.apple.keylayout.ABC)
我在Smartim_SelectDefault和Smartim_SelectSaved进行timeoutlen设置, 否则会出现和其他map兼容的问题.
function! Smartim_SelectDefault()
...
set timeoutlen=1000
endfunction
function! Smartim_SelectSaved()
...
"end
set timeoutlen=0
endfunction
找到 ~/.vim/bundle/smartim/plugin//smartim.vim 这个文件,
在augroup smartim中添加一行:set timeoutlen=0 延迟问题解决! augroup smartim autocmd! set timeoutlen=0 autocmd VimLeavePre * call Smartim_SelectDefault() autocmd InsertLeave * call Smartim_SelectDefault() "autocmd InsertLeave * call system(s:/Users/apple/.vim/bundle/smartim/plugin/im-select com.apple.keylayout.ABC)
大神厉害