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

Commit 1cfb859

Browse files
authored
Merge pull request #250 from nvim-lua/truncate_menu_length
feat: add truncation of menu length and fix variable names
2 parents 857fb1b + a601f88 commit 1cfb859

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lua/completion/util.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ end
3535
function M.addCompletionItems(item_table, item)
3636
-- word cannot be nil
3737
if item.word == nil then return end
38+
local abbr_length = opt.get_option('abbr_length')
3839
local menu_length = opt.get_option('menu_length')
3940
if menu_length ~= 0 then
40-
if string.len(item.abbr) > menu_length then
41-
item.abbr = string.sub(item.abbr, 0, menu_length).."..."
41+
if item.menu ~= nil and string.len(item.menu) > menu_length then
42+
item.menu = string.sub(item.menu, 0, menu_length).."..."
43+
end
44+
end
45+
if item.abbr ~= nil and abbr_length ~= 0 then
46+
if string.len(item.abbr) > abbr_length then
47+
item.abbr = string.sub(item.abbr, 0, abbr_length).."..."
4248
end
4349
end
4450
table.insert(item_table, {

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_abbr_length')
113+
let g:completion_abbr_length = 0
114+
endif
115+
112116
if ! exists('g:completion_menu_length')
113117
let g:completion_menu_length = 0
114118
endif

0 commit comments

Comments
 (0)