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

Remapping <C-x> in insert mode causes broken completion #1239

Closed
2 tasks done
drowning-cat opened this issue Feb 16, 2025 · 2 comments
Closed
2 tasks done

Remapping <C-x> in insert mode causes broken completion #1239

drowning-cat opened this issue Feb 16, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@drowning-cat
Copy link

Make sure you have done the following

  • Updated to the latest version of blink.cmp
  • Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

Is there any way to remap <C-x> to clear the line in insert mode without affecting the completion system?

blink-remap.mp4

Relevant configuration

vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))()

-- The culprit
vim.keymap.set('i', '<C-x>', '<C-u>')

---@diagnostic disable-next-line: missing-fields
require('lazy.minit').repro({
  spec = {
    {
      'saghen/blink.cmp',
      build = 'cargo build --release',
      opts = {},
    },
    {
      'neovim/nvim-lspconfig',
      opts = {
        servers = {
          lua_ls = {},
        },
      },
      config = function(_, opts)
        local lspconfig = require('lspconfig')
        for server, config in pairs(opts.servers) do
          config.capabilities = require('blink.cmp').get_lsp_capabilities()
          lspconfig[server].setup(config)
        end
      end,
    },
  },
})

neovim version

NVIM v0.11.0-dev-1742+g66b60fe62b

blink.cmp version

v0.12.3 cc2f10e

@drowning-cat drowning-cat added the bug Something isn't working label Feb 16, 2025
@drowning-cat
Copy link
Author

drowning-cat commented Feb 16, 2025

I've read a bit of https://neovim.io/doc/user/insert.html#i_CTRL-X and realized I was unlucky enough to outsmart myself by changing <C-x> keymap for clearing the line.
I appreciate if you try to run the non-remapped <C-x> in your code or show me any way to clear the line with <C-x> in insert mode without affecting completion.

@drowning-cat
Copy link
Author

drowning-cat commented Feb 16, 2025

local dot_repeat_hack_name = '<Plug>BlinkCmpDotRepeatHack'
local opts = {
  callback = function()
    if vim.api.nvim_get_mode().mode:match('i') then return '<C-x><C-z>' end
    return ''
  end,
  silent = true,
  replace_keycodes = true,
  expr = true,
  noremap = true, -- NEW!
}
vim.api.nvim_set_keymap('i', dot_repeat_hack_name, '', opts)
vim.api.nvim_set_keymap('n', dot_repeat_hack_name, '', opts)
vim.api.nvim_set_keymap('s', dot_repeat_hack_name, '', opts)
vim.api.nvim_set_keymap('v', dot_repeat_hack_name, '', opts)
vim.api.nvim_set_keymap('c', dot_repeat_hack_name, '', opts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant