supermaven-inc / supermaven-nvim

The official Neovim plugin for Supermaven
https://supermaven.com/
MIT License
279 stars 16 forks source link

When used with nvim-cmp the <Tab> key cannot be used to accept suggestions #29

Closed jonahfang closed 1 month ago

jonahfang commented 1 month ago

My configuration like this with LazyVim:

return {
    "supermaven-inc/supermaven-nvim",
    config = function()
        require("supermaven-nvim").setup({})
    end,
}

-- cmp.lua
cmp.setup {
  ...
  sources = {
    { name = "supermaven" },
  }
  ...
}
kaiiserni commented 1 month ago

Supermaven defaults to listening for tab, and your cmp setup is probably configured to listen for tab as well (but I’m not familiar with lazyvim or the like) . Depending on how you want to configure it, you have to amend one of both keymaps. Considering you added it as a cmp source, I assume you’ll want to disable the built in keymaps of Supermaven by passing it the disable_keymaps property.

jonahfang commented 1 month ago

@kaiiserni Thank you! I changed the supermaven configuration and it worked!

return {
    "supermaven-inc/supermaven-nvim",
    config = function()
        require("supermaven-nvim").setup({
            disable_keymaps = true,
        })

        local completion_preview = require("supermaven-nvim.completion_preview")
        vim.keymap.set('i', '<c-a>', completion_preview.on_accept_suggestion,
            { noremap = true, silent = true })
        vim.keymap.set('i', '<c-j>', completion_preview.on_accept_suggestion_word,
            { noremap = true, silent = true })
        vim.keymap.set('i', '<c-]>', completion_preview.on_accept_suggestion_word,
            { noremap = true, silent = true })
    end,
}
-- EOP