Skip to content

Disable nvim-cmp when vsnip snippet is available #655

Answered by dmitmel
ilhamfu asked this question in Q&A
Discussion options

You must be logged in to vote

You should remove the vsnip mappings and move that logic into the nvim-cmp configuration, like this:

local function replace_keys(str)
  return vim.api.nvim_replace_termcodes(str, true, true, true)
end

cmp.setup({
  -- ...

  mapping = {
    ['<Tab>'] = cmp.mapping(function(fallback)
      if vim.call('vsnip#available', 1) ~= 0 then
        vim.fn.feedkeys(replace_keys('<Plug>(vsnip-jump-next)'), '')
      elseif cmp.visible() then
        cmp.select_next_item()
      else
        fallback()
      end
    end, { 'i', 's' }),

    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if vim.call('vsnip#available', -1) ~= 0 then
        vim.fn.feedkeys(replace_keys('<Plug>(vsnip-jump-prev)'), ''

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ilhamfu
Comment options

Answer selected by ilhamfu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants