garymjr / nvim-snippets

Snippet support using native neovim snippets
MIT License
215 stars 13 forks source link

Deprecated(?)` ._snippet_grammar` member no longer available #29

Closed awilkins closed 3 months ago

awilkins commented 3 months ago

Using nvim-snippets as part of LazyVim

Running into this error every time snippets are listed in completion.

Error executing vim.schedule lua callback: ...hare/nvim/lazy/nvim-snippets/lua/snippets/utils/init.lua:202: attempt to index field '_snippet_grammar' (a nil value)
stack traceback:
    ...hare/nvim/lazy/nvim-snippets/lua/snippets/utils/init.lua:202: in function 'safe_parse'
    ...hare/nvim/lazy/nvim-snippets/lua/snippets/utils/init.lua:215: in function 'expand_vars'
    ...share/nvim/lazy/nvim-snippets/lua/snippets/utils/cmp.lua:79: in function 'resolve'
    ...lkins/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:384: in function 'resolve'
    ...ilkins/.local/share/nvim/lazy/nvim-cmp/lua/cmp/entry.lua:505: in function 'resolve'
    ...wilkins/.local/share/nvim/lazy/nvim-cmp/lua/cmp/view.lua:287: in function 'fn'
    .../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/async.lua:71: in function <.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/async.lua:69>
garymjr commented 3 months ago

I've hopefully resolved this with #30. I copied the parser logic that was being used in _snippet_grammer locally into nvim-snippets. Let me know if the issue persists and thanks for reporting it.

folke commented 3 months ago

Why was this needed? As far as I can see, vim.lsp._snippet_grammar is still in core. Maybe op is using an old nightly?

It's on nightly and also in 0.10.

Best to keep using Neovim's grammar, since they will add support for some features that are currently missing.

garymjr commented 3 months ago

I was hesitant to do this to begin with since I didn't want to need to maintain a separate instance of of the same grammar. I didn't want to cause a regression in LazyVim though if there was a potential that the grammar didn't exist on on 0.10. I'm going to revert this PR then as a result. Thanks for pointing this out @folke

folke commented 3 months ago

@garymjr You also want to remove the vim.print statements in get_selected_text!! :)

garymjr commented 3 months ago

@garymjr You also want to remove the vim.print statements in get_selected_text!! :)

Done 🤦

awilkins commented 3 months ago

Why was this needed? As far as I can see, vim.lsp._snippet_grammar is still in core. Maybe op is using an old nightly?

"underscores mean this thing is private by convention in Lua" made me think that maybe it was an internal thing that moved but I'm inferring that it's a newer internal thing that nvim-snippets is newly depending on more recently.

Hmm, AFAIK I'm on the nightly PPA but let's check.

Aha, not been built since January for Focal. Annoying.

And I have a nasty feeling it might have been something I said that caused this - I pointed out that it wasn't building with LuaJIT on ARM (I think?) and the last 2 fails were 17 weeks ago ... or around 27th January, the last time a Focal release was out.

Edit : have fixed this on focal (20.04) by installing the nvim snap instead.