Skip to content

Accepting selection and executing command with a single return #1803

Closed Answered by cangermueller
cangermueller asked this question in Q&A
Discussion options

You must be logged in to vote

Great, this worked! Just two small typos (replact -> replace; ce -> cr):

mapping = cmp.mapping.preset.cmdline({
  ['<CR>'] = {
    c = function()
      if cmp.visible() then
        cmp.confirm({ select = true })
      end

      local cr = vim.api.nvim_replace_termcodes('<CR>', true, true, true)
      vim.api.nvim_feedkeys(cr, 'n', true)
    end,
  },
})

In the meantime, I found that the desired behavior can also be obtained with <c-j>. <c-y> accepts the selection and does not execute by default.

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@cangermueller
Comment options

@fitrh
Comment options

@cangermueller
Comment options

Answer selected by cangermueller
Comment options

You must be logged in to vote
0 replies
Comment options

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

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