wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.82k stars 266 forks source link

Incorrect escape sign handling #988

Closed konart closed 2 years ago

konart commented 2 years ago

Steps to reproduce

Run :PackerSync after install the latest packer (commit 213ed031490ab5318e7996a594b52131e5c1c06f)

Actual behaviour

Mappings with \ sign (for example vim.keymap.set("n", "\\[", ":NvimTreeToggle<CR>", { silent = true })) cause the following error:

[packer.nvim] [ERROR 09:06:46] async.lua:20: Error in coroutine: ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:725: Vim(source):E5112: Error while creating lua chunk: /Users/user/.config/nvim/plugin/packer_compiled.lua:477: invalid escape sequence near '"'

Expected behaviour

No error

Commit 213ed031490ab5318e7996a594b52131e5c1c06f introduced this error I believe (installing previous versions and rerunning :PackerSync fixes the error.

The latest version produces

vim.api.nvim_set_keymap("", "\[", "<cmd>lua require('packer.load')({'nvim-tree.lua'}, { keys = '\\[', prefix = '' }, _G.packer_plugins)<cr>", { noremap = true, silent = true })

note the second argument to nvim_set_keymap

akinsho commented 2 years ago

Thanks for reporting this. I'll have a look

kevinhwang91 commented 2 years ago

keys = {[[<Leader>\]]} doesn't work also.

Bekaboo commented 2 years ago

Also have this bug, if I have keys = '<C-\\>', in packer_compiled.lua it will be compiled to <C-\>.

akinsho commented 2 years ago

I'm working on a fix over in #989

akinsho commented 2 years ago

Can anyone hitting this issue try the PR in #989 I want to confirm that it fixes the issue for other people

sfrieds3 commented 2 years ago

The PR in #989 fixes the issue for me