Skip to content

Unexpected token 'goto' using stylua from pre-commit #867

@Terseus

Description

@Terseus

I've readed the problem with stylua prebuilt binaries in #240 and #407 , however AFAIK this error isn't expected in the stylua compiled by pre-commit using the repo's file Cargo.toml.

My relevant pre-commit config:

- repo: https://github.com/JohnnyMorganz/StyLua
  rev: v0.20.0
  hooks:
    - id: stylua

But still it doesn't work:

❯ pre-commit run --files nvim/.config/nvim/lua/modules/neotest/consumers/fidget.lua
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...........................................(no files to check)Skipped
Check JSON...........................................(no files to check)Skipped
Check for added large files..............................................Passed
Git Secrets..............................................................Passed
StyLua (cargo)...........................................................Failed
- hook id: stylua
- exit code: 2

error: could not format file nvim/.config/nvim/lua/modules/neotest/consumers/fidget.lua: error parsing: error occurred while creating ast: unexpected token `goto`. (starting from line 70, character 13 and ending on line 70, character 17)
additional information: expected 'end'

Is this error expected?
If it is, is there any workaround apart from using the stylua-system hook?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions