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

Keymap normalization not compatible with <Leader> key #2071

Open
2 tasks done
cissoid opened this issue Oct 24, 2024 · 3 comments
Open
2 tasks done

Keymap normalization not compatible with <Leader> key #2071

cissoid opened this issue Oct 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@cissoid
Copy link

cissoid commented Oct 24, 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

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
    ['<Leader>g<Space>'] = cmp.mapping.complete()
  },

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "buffer" },
  }),
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

require'lspconfig'.cssls.setup {
  capabilities = capabilities,
}
EOF

Description

Add this config:

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
    ['<Leader>g<Space>'] = cmp.mapping.complete()
  },

This keymap <Leader>g<Space> is not functioning properly, while it was working fine before.

Result with imap:

i  <*Leader>g<Space> * <Lua 24: /tmp/plugged/vim-plug/nvim-cmp/lua/cmp/utils/keymap.lua:133>
                 cmp.utils.keymap.set_map

Steps to reproduce

Included in reproducible config file.

Expected behavior

The keymap should worked.

Actual behavior

It not worked after upgrade cmp. Result in imap looks wired.

Additional context

No response

@cissoid cissoid added the bug Something isn't working label Oct 24, 2024
@phanen
Copy link
Contributor

phanen commented Oct 29, 2024

Not sure if is this a bug of vim/nvim:

let g:mapleader = "\<Space>"
map <Leader> <Cmd>echo "work"<CR>
map <*Leader> <Cmd>echo "not work"<CR>
map <Space> <Cmd>echo "work"<CR>
map <*Space> <Cmd>echo "work"<CR>

But here is a workaround:

'<Leader>g<Space>' -> (vim.g.mapleader or '\\') .. 'g<Space>'

@Shougo
Copy link

Shougo commented Nov 4, 2024

#2073

Please test the latest version.

@cissoid
Copy link
Author

cissoid commented Nov 19, 2024

#2073

Please test the latest version.

I tried the latest version, but the problem still persists.
I guess this commit caused the issue: 19bd8c7. It attempted to use <*xxx> to properly handle the modifier key, but <Leader> is not a terminal keycode.

The workaround solution is working well, thanks for your help!

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