Open LimbicSys opened 2 years ago
The option cindent
is default on when the filetype is c or cpp. So the indent is controlled by the cinkeys
instead of the indentkeys
.
So setting cinkeys
to an empty string temporarily should fix the problem.
local cmp = require("cmp")
local keymap = require("cmp.utils.keymap")
local feedkeys = require("cmp.utils.feedkeys")
local keymap_cinkeys = function(expr)
return string.format(keymap.t("<Cmd>set cinkeys=%s<CR>"), expr and vim.fn.escape(expr, "| \t\\") or "")
end
local confirm = function(fallback)
if cmp.visible() then
feedkeys.call(keymap_cinkeys(), "n")
cmp.confirm({ select = true })
feedkeys.call(keymap_cinkeys(vim.bo.cinkeys), "n")
else
fallback()
end
end
cmp.setup({
mapping = {
["<CR>"] = cmp.mapping(confirm, { "i" })
}
})
same issue
FAQ
Announcement
Minimal reproducible full config
Description
Like #640, when the completion item is
private:
(orpublic:
,protected:
) in C++, the inserted text is not correct.clangd --version Homebrew clangd version 13.0.1 Features: mac+xpc Platform: arm64-apple-darwin21.5.0
Steps to reproduce
Type
pri
at the end of class A to trigger the completion, then selectprivate:
and confirm.Expected behavior
Code like blow:
Actual behavior
Additional context
No response