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

Vim's default keymap 'o' will aways trigger cmp window at a blank new line #228

Closed
2 tasks done
dddddjent opened this issue Nov 1, 2024 · 7 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@dddddjent
Copy link

dddddjent commented Nov 1, 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

It always triggers a completion window when I type 'o' to enter the insert mode to add a new line. After going through all the possible options in the trigger section, I still could not disable this behavior. This doesn't happen if I use 'i' or 'a' to enter insert mode. Is this what it is supposed to be? thx

Relevant configuration

keymap = {
        ['<C-e>'] = { 'hide' },
        ['<CR>'] = { 'select_and_accept', 'fallback' },

        ['<C-k>'] = { 'select_prev', 'fallback' },
        ['<C-j>'] = { 'select_next', 'fallback' },

        ['<M-j>'] = { 'snippet_forward', 'fallback' },
        ['<M-k>'] = { 'snippet_backward', 'fallback' },
    },
    accept = { auto_brackets = { enabled = false } },
    trigger = {
        signature_help = { enabled = false },
        completion = {
            show_in_snippet = true,
        }
    },

neovim version

v0.10.0

blink.cmp version: branch, tag, or commit

main

@dddddjent dddddjent added the bug Something isn't working label Nov 1, 2024
@Saghen
Copy link
Owner

Saghen commented Nov 1, 2024

That's bizarre, does it happen on all LSPs?

@dddddjent
Copy link
Author

That's bizarre, does it happen on all LSPs?
Yes, all servers.

@Saghen
Copy link
Owner

Saghen commented Nov 4, 2024

It seems like an incompatibility with one of your plugins. Are you able to reproduce this on a fresh neovim instance with no other plugins?

@dddddjent
Copy link
Author

Now I've found the problem. I remapped my esc to 'jk' and whenever I use this keymap to exit from the insert mode the next time pressing 'o' will trigger the window. Simply pressing esc to exit will not have such behavior. Do you know if there's a way to continue to use my keymap?

@Saghen
Copy link
Owner

Saghen commented Nov 4, 2024

I can take a look if you can create a minimal reproduction (vim.keymap.set and video/steps for reproducing). I tried with the better-escape config in your dotfiles but I wasn't able to reproduce it

@dddddjent
Copy link
Author

vim.loader.enable()
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not 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)
vim.g.mapleader = " "

require("lazy").setup({
    {
        'saghen/blink.cmp',
        lazy = false,
        dependencies = 'rafamadriz/friendly-snippets',
        version = 'v0.*',
        opts = {
            keymap = {
                ['<C-e>'] = { 'hide' },
                ['<CR>'] = { 'select_and_accept', 'fallback' },

                ['<C-k>'] = { 'select_prev', 'fallback' },
                ['<C-j>'] = { 'select_next', 'fallback' },

                ['<M-j>'] = { 'snippet_forward', 'fallback' },
                ['<M-k>'] = { 'snippet_backward', 'fallback' },
            },
            highlight = {
                use_nvim_cmp_as_default = true,
            },
            nerd_font_variant = 'mono',
            accept = { auto_brackets = { enabled = false } },
            trigger = {
                signature_help = { enabled = false },
                completion = {
                    show_in_snippet = true,
                }
            },
        },
    },

    {
        "max397574/better-escape.nvim",
        config = function()
            require("better_escape").setup{
                mapping = { "kj", "jk", }, -- a table with mappings to use
                timeout = 200,             -- the time in which the keys must be hit in ms. Use option timeoutlen by default
                clear_empty_lines = false, -- clear line after escaping if there is only whitespace
                keys = "<Esc>",            -- keys used for escaping, if it is a function will use the result everytime
            }
        end,
    },
})
out.mp4

While it does seem like a better-escape issue. If I use nvim's builtin keymap to map "kj" then blink works correctly.

@roycrippen4
Copy link

+1 I'm having the exact same issue as @dddddjent. Disabling better-escape and using builtin keymaps fixes my issue as well.

@Saghen Saghen closed this as completed in 1ce30c9 Nov 5, 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
Projects
None yet
Development

No branches or pull requests

3 participants