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 not working as expected after installed plugin. #1910

Open
2 tasks done
snoymy opened this issue May 5, 2024 · 1 comment
Open
2 tasks done

Key map not working as expected after installed plugin. #1910

snoymy opened this issue May 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@snoymy
Copy link

snoymy commented May 5, 2024

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Example key mapping to reproduce
nnoremap oo o<Esc>
inoremap mm pp

" Some other example case
nnoremap t o
nnoremap tt o<Esc>
inoremap mm pp

nnoremap r i
nnoremap rr i<Esc>
inoremap mm pp

Description

Key map in insert mode not work as expected after entered insert mode by key (First Character) in normal mode that have other key map that start with same key (First Character).

Steps to reproduce

  1. Add nvim-cmp plugin without or with setup
  2. Add key map for normal mode and add key map for insert mode as shown in Minimal reproducible full config.
" eg 1:
nnoremap oo o<Esc>
inoremap mm pp

" eg 2:
nnoremap t o
nnoremap tt o<Esc>
inoremap mm pp

" eg 3:
nnoremap r i
nnoremap rr i<Esc>
inoremap mm pp
  1. Enter normal mode in neovim then hit omm or tmm or rmm

Expected behavior

Neovim enter insert mode and mm turn into pp

Actual behavior

Text still mm

Additional context

After remove Plug 'hrsh7th/nvim-cmp' key map work as expected.

@snoymy snoymy added the bug Something isn't working label May 5, 2024
@snoymy
Copy link
Author

snoymy commented May 5, 2024

After I tinkering around I found that in this line of code, if I put 'in' into the second parameter feedkeys.call('', 'in', callback) it fix the problem.

feedkeys.call('', '', callback)

@snoymy snoymy changed the title Key map not working as expected after enabled plugin. Key map not working as expected after installed plugin. May 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

1 participant