Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: wrap vim.treesitter.get_parser in pcall #184

Merged
merged 2 commits into from
May 22, 2024
Merged

Conversation

cbochs
Copy link
Contributor

@cbochs cbochs commented May 22, 2024

Fixes #183

Tested manually on a local ruby erb file. Please let me know if you would like other tests added for this.

@PriceHiller
Copy link
Collaborator

PriceHiller commented May 22, 2024

Thanks for the PR @cbochs, it's much appreciated!

I hate to be a pain, but there's (unfortunately) more than one place where we call vim.treesitter.get_parser.

If you could update your commit wrapping those up too, I'll gladly merge this.

If you don't want to do that, no problem -- I can open a separate PR later tonight to do so.

Locations:


I really need to set aside a bit of time to do some light refactoring and depulication across the internal.lua file, kinda scuffed in some spots 😝

@cbochs
Copy link
Contributor Author

cbochs commented May 22, 2024

Oh yes, I just noticed this myself. Apologies for the half-baked PR. I will clean it up here

@PriceHiller
Copy link
Collaborator

PriceHiller commented May 22, 2024

Apologies for the half-baked PR!

Apologies from me for the kinda scuffed code lol. No problem, just ping me when you're good to go/request a review from me.

Thanks again 🙂

@cbochs
Copy link
Contributor Author

cbochs commented May 22, 2024

Just fixed the few other calls to vim.treesitter.get_parser. There appear to be a few failing tests, but I think they're also failing on the main branch:

Failing tests
Fail    ||      [rename tag] test 21 rescript rename open tag
            ./tests/utils/helpers.lua:58:

             text error: 21 rescript rename open tag

            Expected objects to be the same.
            Passed in:
            (string) '<lala> dsadsa </div> '
            Expected:
            (string) '<lala> dsadsa </lala> '

            stack traceback:
                ./tests/utils/helpers.lua:58: in function 'compare_text'
                ./tests/utils/helpers.lua:136: in function <./tests/utils/helpers.lua:78>

Fail    ||      [rename tag] test 22 rescript rename open tag with attr
            ./tests/utils/helpers.lua:58:

             text error: 22 rescript rename open tag with attr

            Expected objects to be the same.
            Passed in:
            (string) '<lala class="lla"> dsadsa </div> '
            Expected:
            (string) '<lala class="lla"> dsadsa </lala> '

            stack traceback:
                ./tests/utils/helpers.lua:58: in function 'compare_text'
                ./tests/utils/helpers.lua:136: in function <./tests/utils/helpers.lua:78>

Fail    ||      [rename tag] test 23 rescript rename close tag with attr
            ./tests/utils/helpers.lua:58:

             text error: 23 rescript rename close tag with attr

            Expected objects to be the same.
            Passed in:
            (string) '<div class="lla"> dsadsa </lala> '
            Expected:
            (string) '<lala class="lla"> dsadsa </lala> '

            stack traceback:
                ./tests/utils/helpers.lua:58: in function 'compare_text'
                ./tests/utils/helpers.lua:136: in function <./tests/utils/helpers.lua:78>

However, I did find the following error - which appeared when running make test on the main branch has been fixed with this PR:

Error message
< [SETUP] Finished setting up minimal initError detected while processing command line..InsertLeave Autocommands for "<buffer=4>":
< Error executing lua callback: ...arm64/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'rescript' language, see :help treesitter-parsers
< stack traceback:
<       [C]: in function 'error'
<       ...arm64/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
<       ...4/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
<       ...im-macos-arm64/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
<       ...im-macos-arm64/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
<       ...ersonal/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:433: in function <...ersonal/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:431>
<       [builtin#36]: at 0x010055a1a4
<       .../tests/.deps/plugins/plenary.nvim/lua/plenary/busted.lua:268: in function 'run'
<       [string ":lua"]:1: in main chunkError executing lua callback: ...arm64/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'rescript' language, see :help treesitter-parsers
< stack traceback:
<       [C]: in function 'error'
<       ...arm64/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
<       ...4/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
<       ...im-macos-arm64/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
<       ...im-macos-arm64/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
<       ...ersonal/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:433: in function <...ersonal/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:431>
<       [builtin#36]: at 0x010055a1a4
<       .../tests/.deps/plugins/plenary.nvim/lua/plenary/busted.lua:268: in function 'run'
<       [string ":lua"]:1: in main chunkError executing lua callback: ...arm64/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'rescript' language, see :help treesitter-parsers
< stack traceback:
<       [C]: in function 'error'
<       ...arm64/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
<       ...4/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
<       ...im-macos-arm64/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
<       ...im-macos-arm64/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
<       ...ersonal/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:433: in function <...ersonal/nvim-ts-autotag/lua/nvim-ts-autotag/internal.lua:431>
<       [builtin#36]: at 0x010055a1a4
<       .../tests/.deps/plugins/plenary.nvim/lua/plenary/busted.lua:268: in function 'run'
<       [string ":lua"]:1: in main chunk

@PriceHiller
Copy link
Collaborator

There appear to be a few failing tests, but I think they're also failing on the main branch

You probably don't have the treesitter-cli or nodejs installed locally which I think the rescript parser is using to generate some grammars.

Tests pass in CI, so it's probably just fine.

Looking good, thanks for the PR!

@PriceHiller PriceHiller merged commit 8ae54b9 into windwp:main May 22, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: No parser for 'embedded_template' language
2 participants