Skip to content

How should the custom mapping function look like for mapping a key onto two different cmp.functions? #1707

Answered by fitrh
zijian-x asked this question in Q&A
Discussion options

You must be logged in to vote

See :h cmp-mapping, at the end of section, it says

Built-in mapping helpers are only available as a configuration option.
If you want to call nvim-cmp features directly, please use |cmp-function| instead.

It means that cmp.mapping is used in the form of key = cmp.mapping.*, using custom callback means you have to write it in the followinhg form

function(_)
  if cmp.visible() then
    cmp.confirm({ select = true })
  else
    cmp.complete()
  end
end

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zijian-x
Comment options

Answer selected by zijian-x
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