Skip to content

fix(lsp): prevent duplicate trailing punctuation in clangd #2003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lua/blink/cmp/sources/lsp/hacks/clangd.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Loading