Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get key binding to work (almost certainly user error) #270

Open
nexxai opened this issue Dec 17, 2024 · 4 comments
Open

Can't get key binding to work (almost certainly user error) #270

nexxai opened this issue Dec 17, 2024 · 4 comments

Comments

@nexxai
Copy link

nexxai commented Dec 17, 2024

I'm moving over from codeium.vim to codeium.nvim and for some reason, I can't figure out how to migrate my old manual keybinding to the new plugin.

Specifically, I have the nvim-cmp setup disabled, and I would like to be able to press CTRL+SPACE to accept the virtual text suggestion.

The old way:

...
    vim.keymap.set("i", "<C-Space>", function()
      return vim.fn["codeium#Accept"]()
    end, { expr = true, silent = true })
...

What I believe (obviously incorrectly) should work:

return {
  "Exafunction/codeium.nvim",
  dependencies = {
    "nvim-lua/plenary.nvim",
    "hrsh7th/nvim-cmp",
  },
  config = function()
    require("codeium").setup({
      enable_cmp_source = false,
      virtual_text = {
        enabled = true,
        key_bindings = {
          accept = "<C-Space>",
        },
      },
    })
  end,
}

Based on the README, this reads like it should work, but I can't seem to get it to take.

When I run :map, it doesn't even show as being a registered key binding for anything:

n  <C-Space>   *@<Lua 597: ~/.local/share/nvim/lazy/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua:15>
                 Start selecting nodes with nvim-treesitter
x  <C-Space>   *@<Lua 863: ~/.local/share/nvim/lazy/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua:58>
                 Increment selection to named node

What am I doing wrong here? If I leave the key_bindings list off, <Tab> does work as the accept key, but I would prefer not to use that if I don't have to. Defining my own key binding obviously prevents the TAB key from accepting the completion.

@dimfeld
Copy link
Contributor

dimfeld commented Dec 23, 2024

Hmm, this works for me and your config looks similar to mine. I think you need to use :imap (or even :imap <c-space>) to show the insert-mode keybindings though, that might help in figuring out what's wrong here. My first guess would be that some other plugin is maybe overwriting the keybinding.

@nexxai
Copy link
Author

nexxai commented Dec 23, 2024

If I do :imap, I see this:

16:53:43 msg_show   imap i  <C-S-Down>  * mmyyp`mj
i  <C-Up>      * <Esc>:m .-2<CR>==gi
i  <C-Down>    * <Esc>:m .+1<CR>==gi
i  <Right>     * <Nop>
i  <Left>      * <Nop>
i  <Down>      * <Nop>
i  <Up>        * <Nop>
i  <S-Tab>     * <Lua 566: ~/.local/share/nvim/lazy/LazyVim/lua/lazyvim/config/keymaps.lua:206>
                 Jump Previous
i  <C-S>       * <Cmd>w<CR><Esc>
                 Save File
i  <M-k>       * <Esc><Cmd>m .-2<CR>==gi
                 Move Up
i  <M-j>       * <Esc><Cmd>m .+1<CR>==gi
                 Move Down
i  <C-B>       * <Lua 199: ~/.local/share/nvim/lazy/LazyVim/lua/lazyvim/plugins/ui.lua:230>
                 Scroll Backward
i  <C-F>       * <Lua 194: ~/.local/share/nvim/lazy/LazyVim/lua/lazyvim/plugins/ui.lua:229>
                 Scroll Forward
i  <BS>        * v:lua.MiniPairs.bs()
                 MiniPairs <BS>
i  <C-W>       * <C-G>u<C-W>
                 :help i_CTRL-W-default
i  <C-U>       * <C-G>u<C-U>
                 :help i_CTRL-U-default
i  <CR>        * v:lua.MiniPairs.cr()
                 MiniPairs <CR>
i  <Esc>       * <Lua 520: ~/.local/share/nvim/lazy/LazyVim/lua/lazyvim/config/keymaps.lua:49>
                 Escape and Clear hlsearch
i  "           * v:lua.MiniPairs.closeopen('""', "[^\\].")
                 Closeopen action for '""' pair
i  '           * v:lua.MiniPairs.closeopen("''", "[^%a\\].")
                 Closeopen action for "''" pair
i  (           * v:lua.MiniPairs.open("()", "[^\\].")
                 Open action for "()" pair
i  )           * v:lua.MiniPairs.close("()", "[^\\].")
                 Close action for "()" pair
i  ,,          * <Esc>A,
i  ,           * ,<C-G>u
i  .           * .<C-G>u
i  ;;          * <Esc>A;
i  ;           * ;<C-G>u
i  [           * v:lua.MiniPairs.open("[]", "[^\\].")
                 Open action for "[]" pair
i  ]           * v:lua.MiniPairs.close("[]", "[^\\].")
                 Close action for "[]" pair
i  `           * v:lua.MiniPairs.closeopen("``", "[^\\].")
                 Closeopen action for "``" pair
i  {           * v:lua.MiniPairs.open("{}", "[^\\].")
                 Open action for "{}" pair
i  }           * v:lua.MiniPairs.close("{}", "[^\\].")
                 Close action for "{}" pair

If I do :imap <C-Space> it says that no mappings are configured

@ad-on-is
Copy link

It doesn't work for me either... I tried Tab and Ctrl+k

@ovidius72
Copy link

I'm facing the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants