Conditional mapping
#1571
-
I want to customize the mapping for mapping = cmp.mapping.preset.insert {
-- <option-shift-P/N>
['<C-S-p>'] = cmp.mapping.scroll_docs(-4),
['<C-S-n>'] = cmp.mapping.scroll_docs(4),
['<C-o>'] = function () -- <------------------------here
if vim.fn.pumvisible() == 1 then
cmp.mapping.close()
else
cmp.mapping.complete()
end
end,
['<C-y>'] = cmp.mapping(
cmp.mapping.confirm {
behaviour = cmp.ConfirmBehavior.Insert,
select = true
}, { 'i', 'c' }
), |
Beta Was this translation helpful? Give feedback.
Answered by
nyngwang
May 12, 2023
Replies: 1 comment
-
I'm noob, this can be done for sure: ['<C-o>'] = cmp.mapping {
-- toggle completion menu.
i = function ()
if cmp.visible()
then cmp.close()
else cmp.complete() end
end,
}, credit: Our glorious master TJ sir's dotfiles. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nyngwang
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm noob, this can be done for sure:
credit: Our glorious master TJ sir's dotfiles.