L3MON4D3 / LuaSnip

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

Parsing error when loading VSCode `.code-snippets` files #1204

Closed alexgorbatchev closed 3 months ago

alexgorbatchev commented 3 months ago

I'm using require("luasnip.loaders.from_vscode").load_standalone({ path = path }) to load snippets from a VSCode project and seeing the following errors:

ERROR | vscode-loader: Could not parse file .../.vscode/personal.code-snippets: ...local/share/nvim/lazy/LuaSnip/lua/luasnip/util/jsonc.lua:429: ERROR: expected ']' or ',' at line 68 col 5
ERROR | vscode-loader: Reading json from file `.../.vscode/personal.code-snippets` failed, skipping it.

Relevant lines from the personal.code-snippets file:

    "jest / test file for storybook": {
        "scope": "typescriptreact",
        "prefix": "new-jest-storybook",
        "body": [
            "import * as React from 'react';",
            "import { composeStories } from '@storybook/testing-react';",
            "import { render } from '...';",
            "import * as stories from '../stories/${TM_FILENAME/\\..*$//}.stories';",
            "",
            "const { ${TM_FILENAME/\\..*$//} } = composeStories(stories);"
LINE 68 >       "",
            "describe('${TM_FILENAME/\\..*$//}', () => {",
            "  test('renders', () => {",
            "    const component = render(<${TM_FILENAME/\\..*$//} />);",
            "    expect(component.getByTestId('$1')).toBeVisible();",
            "  });",
            "});",
        ]
    },
L3MON4D3 commented 3 months ago

Hey :) There's really just a comma missing, check line 67

alexgorbatchev commented 3 months ago

image

oddly enough i think it works in vscode... anyways, apologies for wasting your time