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

Key map with suffix not work #713

Closed
2 tasks done
Kaiser-Yang opened this issue Dec 22, 2024 · 4 comments
Closed
2 tasks done

Key map with suffix not work #713

Kaiser-Yang opened this issue Dec 22, 2024 · 4 comments
Labels
bug Something isn't working keymap

Comments

@Kaiser-Yang
Copy link
Contributor

Kaiser-Yang commented Dec 22, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

I've mapped ;<space> to some functionality in insert mode, then I update the keymap to accept the second item.

I can not accept the second item unless I remove the ;<space> keymap:

Input something first:

image

Input ;, it seems to waif for updatetime to determine it's single key or continuous key:

image

After that, nothing happend, event the ; is not inserted:

image

Relevant configuration

local mapped_punc = {
    [','] = '',
    ['.'] = '',
    [':'] = '',
    [';'] = '',
    ['?'] = '',
    ['\\'] = ''
}
local function feed_key_helper(k, v)
    if v == nil or k == v then
        feedkeys(k, 'n')
    else
        feedkeys(v, 'm')
    end
end
            map.set({ 'i' }, k .. '<space>', function()
                feed_key_helper(v, v)
            end, opts())

keymap = {
                [';'] = {
                    -- FIX: can not work when binding ;<space> to other key
                    function(cmp)
                        if not vim.g.rime_enabled then return false end
                        local items = require('blink.cmp.completion.list').items
                        local rime_item_index = get_n_rime_item_index(2, items)
                        if #rime_item_index ~= 2 then return false end
                        return cmp.accept({ index = rime_item_index[2] })
                    end, 'fallback' },
}

neovim version

NVIM v0.10.1

blink.cmp version: branch, tag, or commit

v0.8.1

@Kaiser-Yang Kaiser-Yang added the bug Something isn't working label Dec 22, 2024
@Kaiser-Yang
Copy link
Contributor Author

This should be fixed after #487

@Saghen
Copy link
Owner

Saghen commented Dec 23, 2024

I'm not able to reproduce this

vim.keymap.set('i', ';<space>', '<cmd>echo "foo"<cr>', { noremap = false, silent = true })
keymap = {
  [';'] = { function() return false end, 'fallback' }
}

@Saghen Saghen added the keymap label Dec 23, 2024
@Kaiser-Yang
Copy link
Contributor Author

I'm not able to reproduce this

vim.keymap.set('i', ';<space>', '<cmd>echo "foo"<cr>', { noremap = false, silent = true })
keymap = {
  [';'] = { function() return false end, 'fallback' }
}

Return false will not reprodue, use this minimal below:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
    spec = {
        {

            'saghen/blink.cmp',
            version = '*',

            ---@module 'blink.cmp'
            ---@type blink.cmp.Config
            opts = {
                keymap = {
                    preset = 'none',
                    [';'] = {
                        function(cmp)
                            return cmp.accept()
                        end, 'fallback' },
                },
            },
            opts_extend = { "sources.default" }
        },
    }
})
vim.keymap.set({ 'i' }, ';<space>', '', { silent = true, remap = false })

@Saghen
Copy link
Owner

Saghen commented Dec 29, 2024

This is quite the edge case :D It seems like the keymap never gets called by neovim, so there's not much we can do on our side. You might want to want to wait for #487 which may resolve this

@Saghen Saghen closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working keymap
Projects
None yet
Development

No branches or pull requests

2 participants