diff --git a/README.md b/README.md
index 28c9d3f9..c6dcdb33 100644
--- a/README.md
+++ b/README.md
@@ -1,22 +1,22 @@
# Vim-EasyComplete
-> A Fast & Minimalism Style Code Completion Plugin for vim/nvim.
+> A Fast and Minimalism Style Completion Plugin for vim/nvim.
![](https://img.shields.io/badge/VimScript-Only-orange.svg) ![](https://img.shields.io/badge/MacOS-available-brightgreen.svg) ![](https://img.shields.io/badge/license-MIT-blue.svg) ![](https://img.shields.io/github/workflow/status/jayli/vim-easycomplete/easycomplete.CI)
### Why
-There are many excellent vim auto-completion plugins such as [nvim-cmp](https://github.com/hrsh7th/nvim-cmp), [vim-lsp](https://github.com/prabirshrestha/vim-lsp), [YouCompleteMe](https://github.com/ycm-core/YouCompleteMe) and [coc.nvim](https://github.com/neoclide/coc.nvim) etc. However I want a more conncise style plugin without any uneccessary configurations. What's more, it would be a good idea to incorporate the capabilities of an AI coding assistant as well.
+There are many excellent vim auto-completion plugins such as [nvim-cmp](https://github.com/hrsh7th/nvim-cmp), [vim-lsp](https://github.com/prabirshrestha/vim-lsp), [YouCompleteMe](https://github.com/ycm-core/YouCompleteMe) and [coc.nvim](https://github.com/neoclide/coc.nvim) etc. However I still want a simpler plugin without any redundant configurations. And it's a good idea to incorporate the capabilities of an AI coding assistant as well.
### What
-Vim-easycomplete is a fast and minimalism style completion plugin for vim/nvim. The goal is to work everywhere out of the box with high-speed performance. It requires pure vim script. You don’t need to configure anything uneccessary. Especially, You don’t have to install Node and a bunch of Node modules unless you’re a javascript/typescript programmer.
+Vim-easycomplete is a fast and minimalism style completion plugin for vim/nvim. The goal is to work everywhere out of the box. It requires pure VimScript. It's also super simple to configure. Especially, You don’t have to install Node and a bunch of Node modules unless you’re a js/ts programmer.
-It is easy to install and use. It contains these features:
+It contains these features:
-- AI coding assistant via tabnine(#TabNine-Support). (Highly Recommend!)
+- AI coding assistant via [tabnine](#TabNine-Support). (Highly Recommend!)
- Buffer Keywords/Directory support
- LSP([language-server-protocol](https://github.com/microsoft/language-server-protocol)) support
- Easy to install LSP Server with one command
@@ -24,7 +24,7 @@ It is easy to install and use. It contains these features:
- Snippet support with ultisnips.
- Fast performance
-The reason I decided to use pure vim script instead of lua or python is that I want a wider range of compatibility. And I made a lot of async handling with vim script to avoid the block of vim.
+The reason I decided to use pure vim script instead of lua or python is that I want a wider range of compatibility. And I made a lot of async handling with vim script to avoid the block of rendering.
### Installation
@@ -123,6 +123,8 @@ let g:easycomplete_diagnostics_prev = ""
- Set `let g:easycomplete_diagnostics_enable = 0` to disable lsp diagnostics.
- Set `let g:easycomplete_lsp_checking = 0` to disable lsp checking for installation.
- Set `let g:easycomplete_signature_enable = 0` to disable lsp signature checking.
+- Set `let g:easycomplete_tabnine_suggestion = 0` to disable tabnine inline suggestions.
+- Set `let g:easycomplete_directory_enable = 0` to disable directory complete.
Typing `:h easycomplete` for help.
@@ -322,7 +324,6 @@ let g:easycomplete_colorful = 1
→ [add custom completion plugin](add-custom-plugin.md)
-
### Issues
[WIP] If you have bug reports or feature suggestions, please use the [issue tracker](https://github.com/jayli/vim-easycomplete/issues/new). In the meantime feel free to read some of my thoughts at , , [https://medium.com/@lijing00333/vim-easycomplete](https://dev.to/jayli/how-to-improve-your-vimnvim-coding-experience-with-vim-easycomplete-29o0)
diff --git a/autoload/easycomplete.vim b/autoload/easycomplete.vim
index 37f43b47..b4ab9236 100644
--- a/autoload/easycomplete.vim
+++ b/autoload/easycomplete.vim
@@ -1329,7 +1329,11 @@ endfunction
function! easycomplete#StoreCompleteSourceItems(plugin_name, result)
let norm_menu_list = s:NormalizeMenulist(a:result, a:plugin_name)
- let sort_menu_list = s:NormalizeSort(norm_menu_list)
+ if a:plugin_name == "tn"
+ let sort_menu_list = norm_menu_list
+ else
+ let sort_menu_list = s:NormalizeSort(norm_menu_list)
+ endif
let g:easycomplete_source[a:plugin_name].complete_result = deepcopy(sort_menu_list)
endfunction
diff --git a/autoload/easycomplete/sources/tn.vim b/autoload/easycomplete/sources/tn.vim
index 0e3c9b9d..2a141057 100644
--- a/autoload/easycomplete/sources/tn.vim
+++ b/autoload/easycomplete/sources/tn.vim
@@ -387,16 +387,34 @@ function! s:NormalizeCompleteResult(data)
else
let l:word['menu'] = '[TN]'
endif
+ let percent_str = ""
if get(l:result, 'detail')
- let l:word['menu'] .= ' ' . l:result['detail']
+ let percent_str = s:fullfill(l:result['detail'])
endif
+ let tmp_detail = easycomplete#util#get(l:result, 'completion_metadata', 'detail')
+ if !empty(tmp_detail)
+ let percent_str = s:fullfill(tmp_detail)
+ endif
+ let l:word["menu"] .= percent_str
+ let l:word["sort_number"] = matchstr(percent_str, "\\d\\+","g")
let l:word['abbr'] = l:word['word']
let l:word['word'] = tn_prefix . l:word['word']
call add(l:words, l:word)
endfor
+ call sort(l:words, {a, b -> str2nr(a["sort_number"]) < str2nr(b["sort_number"])})
return l:words
endfunction
+" ' 4%' -> ' 4%'
+" '22%' -> ' 22%'
+function! s:fullfill(percent)
+ if a:percent[0] == " "
+ return a:percent
+ else
+ return " " . a:percent
+ endif
+endfunction
+
function! s:log(...)
return call('easycomplete#util#log', a:000)
endfunction
diff --git a/lua/easycomplete/util.lua b/lua/easycomplete/util.lua
index f1db9d39..39f3a817 100644
--- a/lua/easycomplete/util.lua
+++ b/lua/easycomplete/util.lua
@@ -41,6 +41,15 @@ function Util.get_word(a)
return k
end
+function Util.isTN(item)
+ local plugin_name = Util.get_item_plugin_name(item)
+ if plugin_name == "tn" then
+ return true
+ else
+ return false
+ end
+end
+
function Util.curr_lsp_constructor_calling()
Util.constructor_calling_by_name(Util.current_plugin_name())
end
@@ -80,6 +89,10 @@ function Util.log(...)
return vim.fn['easycomplete#util#info'](...)
end
+function Util.get_item_plugin_name(...)
+ return vim.fn['easycomplete#util#GetPluginNameFromUserData'](...)
+end
+
function Util.current_plugin_ctx()
return vim.fn['easycomplete#GetCurrentLspContext']()
end