diff --git a/lua/blink/cmp/sources/lsp/hacks/clangd.lua b/lua/blink/cmp/sources/lsp/hacks/clangd.lua index 7fe95be6b..6cfc58fe6 100644 --- a/lua/blink/cmp/sources/lsp/hacks/clangd.lua +++ b/lua/blink/cmp/sources/lsp/hacks/clangd.lua @@ -1,4 +1,13 @@ local clangd = {} +local completion_item_kind = require('blink.cmp.types').CompletionItemKind + +--- @param text string +--- @return string +local function strip_ending_punctuation(text) + local last_char = text:sub(-1) + if last_char == '>' or last_char == '"' then text = text:sub(1, -2) end + return text +end --- @param response blink.cmp.CompletionResponse | nil --- @return blink.cmp.CompletionResponse | nil @@ -9,6 +18,10 @@ function clangd.process_response(response) if not items then return response end for _, item in ipairs(items) do + if item.kind == completion_item_kind.File then + item.textEdit.newText = strip_ending_punctuation(item.textEdit.newText) + item.label = strip_ending_punctuation(item.label) + end item.lsp_score = item.score end return response