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

Doesn't seem to update with treesitter playground #35

Closed
expipiplus1 opened this issue May 27, 2021 · 28 comments
Closed

Doesn't seem to update with treesitter playground #35

expipiplus1 opened this issue May 27, 2021 · 28 comments

Comments

@expipiplus1
Copy link

Firstly: It's fantastic to see this working with Haskell!

I notice that with treesitter playground things don't seem to be updating (and I assume that this indicates a deeper problem)

Here's a recording of me editing a C file and a Haskell file, demonstrating the difference in experience:

https://asciinema.org/a/J38cw04yWrtdxFYfjWPwZXAvd

I'm using neovim master (as of today) and treesitter 0.19.5

@tek
Copy link
Contributor

tek commented May 27, 2021

yeah, I haven't managed to get it to work properly in neovim yet. For me it produces lots of errors and has problems with newlines. Do you get any errors? Haven't tried it in a month, I'll investigate with the latest masters.

@expipiplus1
Copy link
Author

No errors or anything like that I'm afraid. I'm happy to do any debugging, just let me know how!

@tek
Copy link
Contributor

tek commented May 27, 2021

that's great, maybe these problems were fixed recently.
When you edit a file containing

import Foo.Bar
import Foo.Bar

is the second line highlighted? or if you don't have highlighting, what's the tree displayed by playground?

@expipiplus1
Copy link
Author

expipiplus1 commented May 27, 2021

Seems to be highlighting things correctly, not sure if that's tree sitter or vim though. Playground is certainly not correct though

image

Edit: Seems to be vim nothing changes if I TSBufToggle highlight. Editing a C file, I do see differences when I toggle highlighting.

@expipiplus1
Copy link
Author

On a file with more imports, it seems to ERROR on some of the imports:

image

@tek
Copy link
Contributor

tek commented May 27, 2021

hm! it definitely looks better than previously. I will investigate.

@expipiplus1
Copy link
Author

expipiplus1 commented May 27, 2021 via email

@tek
Copy link
Contributor

tek commented May 28, 2021

so I gave it a try and it still suffers from the same problem I saw before, that when e.g. two import statements are in successive lines, the second one is skipped.

Then I added some code below the imports, and none of that was highlighted/shown in the playground, until I deleted one of the imports, which triggered an update. So that might be similar behaviour to what you described.

In any case, my guess is that this is still a problem with nvim, I think we'll need to wait for it to be stable, since the parsing itself works fine. Unfortunately, I haven't figured out how to reproduce these issues with the tree-sitter cli.

@expipiplus1
Copy link
Author

expipiplus1 commented May 29, 2021 via email

@tek
Copy link
Contributor

tek commented May 29, 2021

there's this issue nvim-treesitter/nvim-treesitter#1201 pertaining to a certain error reported by TS while editing which I also experience, and it seems likely to me that it's the cause of what's happening here (the error is "end_col out of range", which fits with the fact that consecutive lines are alternatingly not highlighted, something with the newlines).
So I'm gonna try to come up with a minimal reproducer for that.

I suspect that in order for an issue on neovim to be successfully processed this might be too vague of a situation

@expipiplus1
Copy link
Author

How are you seeing these error messages? I seem to get nothing printed from nvim. FWIW I tried with different line endings with no difference.

@tek
Copy link
Contributor

tek commented May 29, 2021

image

happens after doing a few edits.

I experimented with different newline chars as well in the tests.

@expipiplus1
Copy link
Author

expipiplus1 commented May 29, 2021 via email

@tek
Copy link
Contributor

tek commented May 29, 2021

I debugged this with the scanner in tests but haven't been able to find anything out.
I'd have to dive into how neovim does the parsing to get a better picture.

Anyway, since this exact error message is the topic of said issue, I hope its fix will improve this.

@theHamsta
Copy link

@tek does this problem only happen with nvim or does it also happen with tree-sitter's wasm playground?

@tek
Copy link
Contributor

tek commented Jun 8, 2021

@theHamsta I haven't seen that! Can you link me?

@theHamsta
Copy link

I couldn't find the docs for it. Everytime I look for it I compile it by trial and error

tree-sitter build-wasm # requires emcc or docker
tree-sitter web-ui

@tek
Copy link
Contributor

tek commented Jun 8, 2021

thanks! I'll investigate the problem with that.

@theHamsta
Copy link

It seems to miss the updates also with the web-ui

@tek
Copy link
Contributor

tek commented Jun 8, 2021

guess that answers #32 (comment) as well, @maxbrunsfeld .

Question is now, how do we create a minimal reproducer from this? Does the web ui provide some additional insights?

@ahlinc
Copy link

ahlinc commented Jun 9, 2021

I couldn't find the docs for it. Everytime I look for it I compile it by trial and error

I usually use tree-sitter CLI built from the master branch and found that there may be problems with starting the local playground due to collision of tree-sitter versions and if to be more concrete due to wasm components collision.

  • My tree-sitter version located in ~/.cargo/bin/ which I install there by the cargo install --path cli/ command from tree-sitter's repo.
  • Another tree-sitter version may be in a node_modules/.bin/ folder inside of a grammar folder cause it's general recommendation from tree-sitter's documentation and to have access to the node_modules/tree-sitter-cli/dsl.d.ts file what is useful in IDEs.
  • Also tree-sitter CLI binary may be located in the global .../node_modules/bin/ folder if some one installed it with npm install -g tree-sitter-cli.

The tree-sitter CLI binary ships by itself another binary tree-sitter.wasm what is its C parser compiled into WASM library and this file is served by tree-sitter web-ui along with a grammar WASM file that is build with tree-sitter build-wasm command.

It seems the reason that local playground may fail to start is that tree-sitter.wasm file and the tree-sitter-<grammar_name>.wasm may be compiled by incompatible emscripten + binaryen versions. Tree-sitter currently uses 2.0.11 emscripten version while in the docker registry there are 2.0.23 version and tree-sitter uses latest version from the docker registry for compilation of the wasm file by the tree-sitter build-wasm command.

I've thought before about proposals:

  • To patch tree-sitter that it would use exactly the same version from docker registry as it uses in its CI. But this doesn't protects from issues if someone wants to use locally installed version of Emscripten.
  • Add some fuses to tree-sitter CLI and generated WASM files that would protect from such flavor of issues and may be clearly explain what is wrong.
  • Another option is to ship with tree-sitter CLI pure C files and compile all of them with grammar files by tree-sitter build-wasm command.

@maxbrunsfeld Could you tell what do you think about above thoughts?

@tinygiant98
Copy link

@ahlinc ... Nailed it. The issue I was having in #1155 was resolved by installing emscripten 2.0.11 and rebuilding the parser to wasm. Still have a few issues (such as errors not being displayed in the document), but that's more likely something with the extension and not tree-sitter itself. Thanks!

@theHamsta
Copy link

This might be an issue with the playground. It only seems to update when `highlights.scm is present https://nvim-treesitter.zulipchat.com/#narrow/stream/252338-help/topic/Hot.20Reparsing.20with.20Custom.20Parsers/near/244874972

@expipiplus1
Copy link
Author

Seems to be fixed now, perhaps due to 9c1fd42?

@theHamsta
Copy link

theHamsta commented Jul 21, 2021

@expipiplus1 No, the bug is that the playground won't update when there are not highlighting queries. highlights.scm has now been added. So it's a bug in our repo not with tree-sitter-haskell, but maybe 9c1fd42 did fix another issue that was preventing to let it work with the web-ui playground

@tek
Copy link
Contributor

tek commented Jul 21, 2021

FYI my issues disappeared when nvim 0.5 was released.

@tek
Copy link
Contributor

tek commented Aug 27, 2021

@expipiplus1 can this be closed?

@expipiplus1
Copy link
Author

Yes! Thanks!

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

No branches or pull requests

5 participants