Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:jayli/vim-easycomplete into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jayli committed Sep 14, 2024
2 parents 2a740bb + 6fe60bd commit 227445c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion autoload/easycomplete/sources/buf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ endfunction

" 读取缓冲区词表和字典词表,两者合并输出大词表
function! s:GetKeywords(typing)
" 性能测试,3万个单词两级
" 性能测试,3万个单词量级
" lua: 0.0644
" vim: 0.2573
let bufkeyword_list = s:GetBufKeywordsList(a:typing)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 227445c

Please sign in to comment.