From 57a7ff6943065170b482cf5a62d8fe6f7207006e Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Mon, 5 Sep 2022 04:02:51 -0500 Subject: [PATCH] fix(nvim): limit max cmp word len --- .../primary/config/lua/plugins/configs/_cmp.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dots/.nvim-environments/primary/config/lua/plugins/configs/_cmp.lua b/dots/.nvim-environments/primary/config/lua/plugins/configs/_cmp.lua index beaa2809..2fe31d3e 100755 --- a/dots/.nvim-environments/primary/config/lua/plugins/configs/_cmp.lua +++ b/dots/.nvim-environments/primary/config/lua/plugins/configs/_cmp.lua @@ -148,8 +148,21 @@ cmp.setup({ vim_item.menu = strings[1] .. " " .. strings[2] return kind else + local word = entry:get_insert_text() + if entry.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then + word = vim.lsp.util.parse_snippet(word) + end + word = str.oneline(word) + + -- concatenates the string + local max = 50 + if string.len(word) >= max then + local before = string.sub(word, 1, math.floor((max - 3) / 2)) + word = before .. "..." + end vim_item.kind = " " .. selection.symbol vim_item.menu = selection.symbol .. selection.name + vim_item.abbr = word return vim_item end end,