Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug when from_lua snippets are loaded with incorrectly formatted content #810

Closed
dwainm opened this issue Mar 8, 2023 · 1 comment · Fixed by #820
Closed

Bug when from_lua snippets are loaded with incorrectly formatted content #810

dwainm opened this issue Mar 8, 2023 · 1 comment · Fixed by #820

Comments

@dwainm
Copy link
Contributor

dwainm commented Mar 8, 2023

When loading a snippet that is incorrectly formatted, the error catching is bypassed ass it is checking the wrong value.

To reproduce:

Add this to your luasnip config:

require("luasnip.loaders.from_lua").load({paths = "~/snippets"})

Then add this to all.lua in that directory:

{
  "Standard Starter Template": {
    "prefix": "sst",
    "body": [
      "#include <stdlib.h>",
      "#include <stdio.h>",
      "",
      "int main(int argc, char *argv[])",
      "{$0",
      "",
      "\treturn EXIT_SUCCESS;",
      "}"
    ],
    "description": "Standard starter template for a tiny C program"
}
}

Open NVIM and see the error:

Error detected while processing /Users/dwain/.config/nvim/after/plugin/luasnip.lua:                                                                                                   
E5113: Error while calling lua chunk: ...ck/packer/start/LuaSnip/lua/luasnip/loaders/from_lua.lua:77: bad argument #1 to 'setfenv' (number expected, got nil)  
@L3MON4D3
Copy link
Owner

L3MON4D3 commented Mar 8, 2023

Nice catch, thank you for doing a PR immediately 👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants