Replies: 2 comments
-
|
In my setup, snippet and completion have separate keymaps. That said, maybe this could help you get started. local opts = { noremap = true, expr = true, silent = true }
-- because or opts.expr we gotta return something
vim.keymap.set("i", "<Tab>", function()
if vim.fn["coc#pum#visible"]() == 1 then
return vim.fn["coc#pum#next"](1)
elseif vim.fn["coc#expandableOrJumpable"]() then
return "<Plug>(coc-snippets-expand-jump)"
else
return "<C-i>"
end
end, opts)
vim.keymap.set("i", "<S-Tab>", function()
if vim.fn["coc#pum#visible"]() == 1 then
return vim.fn["coc#pum#prev"](1)
elseif vim.fn["coc#jumpable"]() then
return vim.fn["coc#snippet#prev"]() --> this turns into <Ignore> when the keymap runs
elseif vim.fn.indent(vim.fn.line(".")) == vim.fn.col(".") - 1 then
return "<C-d>"
else
return "<C-w>"
end
end, opts)
vim.keymap.set("i", "<CR>", function()
if vim.fn["coc#pum#visible"]() == 1 then
vim.fn["coc#pum#close"]("confirm")
else
vim.api.nvim_feedkeys(vim.keycode("<C-m>"), "n", false)
vim.fn["coc#on_enter"]()
end
end, { noremap = true, silent = true })
-- This might be useful since some snippets sometimes add text before the
-- cursor and that might influence completion
vim.keymap.set("i", "<C-Space>", function()
if vim.fn["coc#pum#visible"]() == 1 then
vim.fn["coc#pum#close"]()
else
vim.fn["coc#start"]()
end
end, { noremap = true, silent = true }) |
Beta Was this translation helpful? Give feedback.
0 replies
-
You need to map Map your |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I expect the following functionality when pressing the Tab key:
Trigger completion, navigate to the next completion item, and select it by pressing Enter.
After selecting a completion, pressing Tab should navigate to the next placeholder.
I have the following references:
The content of coc-snippets' README
The content of coc.nvim's README
However, I am not sure how to combine these two configurations to achieve my goal. Thank you.
Vim verison:
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 1 2021 16:57:56)
The following is my current configuration for cocnvim:
Beta Was this translation helpful? Give feedback.
All reactions