Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit 97e3bcb

Browse files
authored
Merge pull request #209 from nvim-lua/truncate_complete_menu
feat: add ability to truncate completion menus
2 parents 3cffa5b + 15c3b96 commit 97e3bcb

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lua/completion/util.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ end
3535
function M.addCompletionItems(item_table, item)
3636
-- word cannot be nil
3737
if item.word == nil then return end
38+
local menu_length = opt.get_option('menu_length')
39+
if menu_length ~= 0 then
40+
if string.len(item.abbr) > menu_length then
41+
item.abbr = string.sub(item.abbr, 0, opt.get_option('menu_length')).."..."
42+
end
43+
end
3844
table.insert(item_table, {
3945
word = item.word,
4046
abbr = item.abbr or '',

plugin/completion.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ if ! exists('g:completion_items_priority')
109109
let g:completion_items_priority = {}
110110
endif
111111

112+
if ! exists('g:completion_menu_length')
113+
let g:completion_menu_length = 0
114+
endif
115+
112116
inoremap <silent> <Plug>(completion_confirm_completion)
113117
\ <cmd>call completion#wrap_completion()<CR>
114118

0 commit comments

Comments
 (0)