L3MON4D3 / LuaSnip

Snippet Engine for Neovim written in Lua.
Apache License 2.0
3.44k stars 245 forks source link

snippet.lua:764 : breaks vscode-es7-javascript-react-snippets #467

Closed quantumsnowball closed 2 years ago

quantumsnowball commented 2 years ago

I found this error very recently. I am using 'dsznajder/vscode-es7-javascript-react-snippets' in my lua config, but when I confirm my snippet (e.g. type rafc~ for react arrow function component ) in luasnip, the following error occurs.

E5108: Error executing lua .../pack/packer/start/LuaSnip/lua/luasnip/nodes/snippet.lua:764: attempt to concatenate a nil value
stack traceback:
        .../pack/packer/start/LuaSnip/lua/luasnip/nodes/snippet.lua:764: in function 'get_static_text'
        .../pack/packer/start/LuaSnip/lua/luasnip/nodes/snippet.lua:762: in function 'get_static_text'
        ...te/pack/packer/start/LuaSnip/lua/luasnip/util/parser.lua:173: in function 'fn'
        ...k/packer/start/LuaSnip/lua/luasnip/nodes/dynamicNode.lua:129: in function 'update'
        .../pack/packer/start/LuaSnip/lua/luasnip/nodes/snippet.lua:807: in function 'update'
        .../pack/packer/start/LuaSnip/lua/luasnip/nodes/snippet.lua:486: in function 'trigger_expand'
        ...nvim/site/pack/packer/start/LuaSnip/lua/luasnip/init.lua:204: in function 'snip_expand'
        ...e/pack/packer/start/cmp_luasnip/lua/cmp_luasnip/init.lua:142: in function 'execute'
        .../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:360: in function 'execute'
        ...e/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/entry.lua:446: in function 'execute'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:463: in function <...re/nvim/site/pack/packer/start/nvim-cm
p/lua/cmp/core.lua:462>
        ...te/pack/packer/start/nvim-cmp/lua/cmp/utils/feedkeys.lua:47: in function <...te/pack/packer/start/nvim-cmp/lua/cmp/u
tils/feedkeys.lua:45>

After digging into the source code for snippet.lua in line 764, found that this file has been recently updated in commit e2a044f8fa4d8b86b63b4494c257bb1aa7379c97. I tried to revert back to the commit right before it 79b2019c68a2ff5ae4d732d50746c901dd45603a which contains the last version of this file, then the problem is gone. I have also tried to reproduce the same error in a docker container, and the exact problem exists, and can be solved in the exact same way.

FYI, you may reference my full config repo here. My work around on the fix is located here. I am using neovim v0.7. I have tested this problem on Manjaro Linux, MacOS, and a docker container running Arch Linux.

L3MON4D3 commented 2 years ago

Ooooh yes I can reproduce and see what's going on, quick (:sweat_smile: I hope) fix coming up

L3MON4D3 commented 2 years ago

Okay 9643335 should do it, thank you for opening this issue, that was a nasty bug