From 28ab7f7d05db70acd88b06bb5830ec40805d8d7c Mon Sep 17 00:00:00 2001 From: hrsh7th <629908+hrsh7th@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:40:03 +0900 Subject: [PATCH] use only the specified field's width for the window width --- lua/cmp/view/custom_entries_view.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/cmp/view/custom_entries_view.lua b/lua/cmp/view/custom_entries_view.lua index aadcfea..9b22f6f 100644 --- a/lua/cmp/view/custom_entries_view.lua +++ b/lua/cmp/view/custom_entries_view.lua @@ -140,6 +140,7 @@ custom_entries_view.open = function(self, offset, entries) self.column_width = { abbr = 0, kind = 0, menu = 0 } local entries_buf = self.entries_win:get_buffer() + local fields = config.get().formatting.fields local lines = {} local dedup = {} local preselect_index = 0 @@ -147,9 +148,9 @@ custom_entries_view.open = function(self, offset, entries) local view = e:get_view(offset, entries_buf) if view.dup == 1 or not dedup[e.completion_item.label] then dedup[e.completion_item.label] = true - self.column_width.abbr = math.max(self.column_width.abbr, view.abbr.width) - self.column_width.kind = math.max(self.column_width.kind, view.kind.width) - self.column_width.menu = math.max(self.column_width.menu, view.menu.width) + for _, field in ipairs(fields) do + self.column_width[field] = math.max(self.column_width[field], view[field].width) + end table.insert(self.entries, e) table.insert(lines, ' ') if preselect_index == 0 and e.completion_item.preselect then