Skip to content

Conditionally execute fallback (e.g. for specific mode) #833

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

You must be logged in to vote

Not sure I'm understanding correctly, but you can run the fallback by returning a non truthy value from the previous command, see: https://cmp.saghen.dev/configuration/keymap.html#example

['<C-n>'] = { 
  function(cmp)
    if (vim.api.nvim_get_mode().mode == 'c') then
      return cmp.show() -- returns true if it shows, otherwise nil
    end
    -- runs next command because we return nil
  end,
  "fallback"
}

Replies: 1 comment 1 reply

Comment options

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

Answer selected by ovk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
feature New feature or request
2 participants
Converted from issue

This discussion was converted from issue #832 on December 31, 2024 15:46.