vscode-neovim: `` not working when `vim.g.mapleader = ' '`

Repro, in init.vim

let mapleader="\<Space>"
nnoremap <Leader><Leader> <Cmd>call VSCodeNotify("workbench.action.quickOpen")<CR>
nnoremap <Leader>w <Cmd>call VSCodeCall("workbench.action.files.save")<CR>

You’ll get ‘Space, Space’ is not a command message at the bottom for the <Leader>w works. If you change mapleader to U and press it twice, it works as expected. I think there’s something about finding space twice in the LHS of the map. I tried this theory out with this mapping:

nnoremap <Leader>w<Leader> <Cmd>call VSCodeCall("workbench.action.files.save")<CR>

And it doesn’t work (space character appearing twice) in the mapping.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 5
  • Comments: 18 (3 by maintainers)

Most upvoted comments

For anyone looking for the answer:

Put this at the top of your init.lua

vim.keymap.set("", "<Space>", "<Nop>")
vim.g.mapleader = " "

The default mapping for <Space> need to be deleted for this to work. Since vim.keymap.del is not working so mapping it to <Nop> should do the trick.

cc: @ListenLove

I’m using lua file, I’ve tried using mapleader & maplocalleader, and still not working:

vim.g.mapleader = "," -- leader key
vim.g.maplocalleader = "," -- leader key

@craigmac I found that setting this to disable the original space action resolves this question. thanks anyway.

    map("", "<Space>", "<Nop>", opts)

Sorry, this simply cannot be a bug with vscode-neovim. There is a problem with your vim config.