diff --git a/README.md b/README.md index 4722e68..bf16ca9 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,14 @@ Global configurations: | `g:easycomplete_diagnostics_hover` | 1 | Gives a diagnostic prompt when the cursor holds | | `g:easycomplete_pum_format` | `["abbr", "kind", "menu"]`| Pmenu format | +For most of vim's default configurations, noselect is not included in completeopt, which will result in the first item of the matching menu being selected by default. To avoid this, it can add this command in your vimrc `setlocal completeopt+=noselect`. Or add this code to your `init.lua` file: + +```lua +vim.cmd([[ + setlocal completeopt+=noselect +]]) +``` + Typing `:h easycomplete` for help. ## Language Support diff --git a/autoload/easycomplete/sources/buf.vim b/autoload/easycomplete/sources/buf.vim index fccf990..61497c7 100644 --- a/autoload/easycomplete/sources/buf.vim +++ b/autoload/easycomplete/sources/buf.vim @@ -26,7 +26,7 @@ endfunction " 读取缓冲区词表和字典词表,两者合并输出大词表 function! s:GetKeywords(typing) - " 性能测试,3万个单词两级 + " 性能测试,3万个单词量级 " lua: 0.0644 " vim: 0.2573 let bufkeyword_list = s:GetBufKeywordsList(a:typing) @@ -112,10 +112,20 @@ function! s:GetBufKeywordsList(typing) endfor " call easycomplete#util#StartRecord() if easycomplete#util#HasLua() + " 匹配首字符 " 58424 → 3623 0.010739 + " 匹配前三个起始字符 + " 53378 → 4781 0.006533 + " 53378 → 4781 0.006361 + " lua 的实现选择匹配前三个字符 let keyword_list = s:lua_toolkit.filter(tmpkeywords, a:typing) else + " 匹配首字符 " 58424 → 3623 0.082437 + " 匹配前三个起始字符 + " 53378 → 4781 0.102643 + " 53378 → 4781 0.101672 + " vim 的实现还是应该性能优先,只匹配首字符 call filter(tmpkeywords, 'v:val =~ "^' . a:typing . '" && v:val !=# "' . a:typing . '"') let keyword_list = tmpkeywords endif