Did I mess up my lazyvim config?

since a couple of days, whenever I try to edit a zig file nvim/lazyvim, I get spammed by error messages:

   Error  08:25:45 PM msg_show.lua_error Error detected while processing TextChangedI Autocommands for "*":
08:25:45 PM msg_show Error executing lua callback: ...nvim-lazy/lazy/nvim-snippets/lua/snippets/utils/init.lua:213: Expected value but found invalid token at character 396
stack traceback:
	[C]: in function 'decode'
	...nvim-lazy/lazy/nvim-snippets/lua/snippets/utils/init.lua:213: in function 'get_snippets_for_ft'
	...share/nvim-lazy/lazy/nvim-snippets/lua/snippets/init.lua:53: in function 'load_snippets_for_ft'
	.../nvim-lazy/lazy/nvim-snippets/lua/snippets/utils/cmp.lua:24: in function 'complete'
	.../.local/share/nvim-lazy/lazy/nvim-cmp/lua/cmp/source.lua:326: in function 'complete'
	...oo/.local/share/nvim-lazy/lazy/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'
	...oo/.local/share/nvim-lazy/lazy/nvim-cmp/lua/cmp/core.lua:169: in function 'callback'
	...oo/.local/share/nvim-lazy/lazy/nvim-cmp/lua/cmp/core.lua:229: in function 'autoindent'
	...oo/.local/share/nvim-lazy/lazy/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
	...oo/.local/share/nvim-lazy/lazy/nvim-cmp/lua/cmp/init.lua:346: in function 'callback'
	.../share/nvim-lazy/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:49: in function 'emit'
	.../share/nvim-lazy/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:23: in function <.../share/nvim-lazy/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:22>

Does anyone here experience this as well or did I just mess something up?

I’m using nvim 0.10.2 on Linux, with a slightly modified lazyvim config, that includes the zig.vim plugin. Zig & zls from latest master. As I wrote, this started happening a couple of days ago; afaik, I did not change my lazyvim config /wrt Zig.

I don’t use lazyvim, nor the zig plugin. I see the error is with the snippet plugin tool and ultimately with nvim-cmp. Have you updated those recently? I Imagine that zls is giving a response to a query that isn’t being handled correctly by nvim-cmp.

Have you looked at the LspLogs for what requests are made when you go to insert mode in a zig file?

No, didn’t change anything related to nvim-cmp recently.

I removed zls completely and still get the error, so I don’t think this is coming from zls. Might still be the zig plugin, since the error is specific to when I’m editing zig files.

1 Like

yeah, looking at the cmp source, I was wrong, there is an issue with an autocommand that is getting set up, but which one… I can’t see.

found the issue. There is a badly escaped " in .local/share/nvim-lazy/lazy/friendly-snippets/snippets/zig.json:

[...]
"const exe = b.addExecutable(.{",
".name = \"${1}",\",
".root_source_file = b.path(\"${2: path}\"),",
[...]

notice the second line… it should be

[...]
"const exe = b.addExecutable(.{",
".name = \"${1}\",",
".root_source_file = b.path(\"${2: path}\"),",
[...]

Made a PR.

3 Likes

Thank you so much for finding this I had the exact same issue

2 Likes

Thanks for tracking this down. How did you manage to find the source of the problem? It’s not clear to me from inspecting the ‘emit’ call at the bottom of the stack traceback, how I could have found the root cause.

It actually was the second line of the traceback that gave the right clue. It says init.lua tried to load something and failed. If you inspect that piece of code you find that it parses json files. Now you need to find out which file is making trouble, and that’s it. In hindsight, this sounds so simple - but I can assure you, it gave me some headache ^^

Unfortunately, the fix is still not merged. I wasn’t even the first one to bring up the issue at the friendly-snippets repo.

2 Likes

seems to be fixed finally; Issues with Zig · Issue #520 · rafamadriz/friendly-snippets · GitHub

2 Likes