You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Formalizing this forum question as a feature request here. Some languages don't lend themselves very well to regex-based grammars, and there are several languages out there that expose their tokenizers.
Reacted by IC Rainbow, Jordan W, Arets Paeglis, Philipp Emanuel Weidmann, Cheng Lou, Ricky Vetter, repsac, remexre, mx-scissortail, Piotr Młodawski and 7 more
I work on my own language and updating the relevant syntax package feels like a lot of duplicated work.
Furthermore the regex-based grammar doesn't work very well as @jpsim said for many languages (which currently have inaccurate highlighting or outright bugs because of this).
Also.. this should be many orders of magnitude faster than the regex-based grammar.
/cc @bolinfest - I know you were interested in using this kind of an API, but for Flow. Maybe you could share some of you thoughts here on how the API could work.
One thought about this: I think it would be awesome to eventually add this kind of feature, to enable packages like ensime and flow to provide IDE-like semantic highlighting (e.g. indicating unused variables or imports, or distinguishing constants from variables). That said, I don't think that this feature will help to address the performance problems of Atom's parsing, at least not in a general way.
The reason is that we will always need to provide at least basic syntax highlighting synchronously. If you type the word if, and 300ms later after you've already moved the cursor, the if turns yellow, that's not a good user experience. Syntax information that is obtained from external compilers via child processes or RPC is never going to be available quickly enough for synchronous syntax highlighting. JetBrains IDEs, for example, perform tokenization synchronously, even though they do parsing and semantic analysis asynchronously.
Now for some languages, there may be a parser that we could call synchronously from javascript, but it would need to support things like nested languages (e.g. JavaScript within HTML within Markdown). This limits the number of languages that we could apply this technique to pretty severely.
Anyway, I may be missing something here, but it seems like we need to view this as enabling cool IDE features on top of Atom's built-in highlighting, not replacing it for performance improvements.
We would definitely be interested in this. There are things that are just very difficult to do without proper language tooling to actually parse and understand the grammar. We would still like the current Atom highlighting convention for "recovered" regions that our tooling detected invalid parses for, but for the large portion of the buffer that is a valid parse, we can provide a much more accurate highlighting (and furthermore we can do it much faster with yacc generated parsers). Our tooling would be capable of telling Atom exactly which regions of text should be highlighted using which token class, and we can tell Atom exactly which regions of text we were not able to parse at all (and should therefore fall back to some much less accurate (but easy to build) Atom specific interactive tokenizing).
This issue has been automatically marked as stale because it has not had recent activity. Because the Atom team treats their issues as their backlog, stale issues are closed. If you would like this issue to remain open:
Verify that you can still reproduce the issue in the latest version of Atom
Comment that the issue is still reproducible and include:
What version of Atom you reproduced the issue on
What OS and version you reproduced the issue on
What steps you followed to reproduce the issue
Issues that are labeled as triaged will not be automatically marked as stale.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
Activity
mehcode commentedon Sep 4, 2015
👍 A thousand times.
I work on my own language and updating the relevant syntax package feels like a lot of duplicated work.
Furthermore the regex-based grammar doesn't work very well as @jpsim said for many languages (which currently have inaccurate highlighting or outright bugs because of this).
Also.. this should be many orders of magnitude faster than the regex-based grammar.
p-e-w commentedon Sep 12, 2015
https://github.com/p-e-w/language-javascript-semantic requires this in order to work. I'm getting tired of adapting the code to match Atom's ever-changing internal line representations. There should be a public API for connecting arbitrary tokenizers that are simply JavaScript functions.
hedefalk commentedon Oct 11, 2015
+1.
We have the need for this in the Ensime Scala plugin as well. https://atom.io/packages/ensime. Here is my forum question for reference: https://discuss.atom.io/t/marker-decorations-that-add-style-classes-to-the-actual-text-nodes/20254
The Ensime backend already supports semantic highlighting of Scala source but I can't find a way to leverage this without a programmatic async api.
kpmeen commentedon Oct 12, 2015
nightscape commentedon Oct 12, 2015
jurStv commentedon Oct 12, 2015
maxbrunsfeld commentedon Oct 12, 2015
/cc @bolinfest - I know you were interested in using this kind of an API, but for Flow. Maybe you could share some of you thoughts here on how the API could work.
One thought about this: I think it would be awesome to eventually add this kind of feature, to enable packages like
ensimeandflowto provide IDE-like semantic highlighting (e.g. indicating unused variables or imports, or distinguishing constants from variables). That said, I don't think that this feature will help to address the performance problems of Atom's parsing, at least not in a general way.The reason is that we will always need to provide at least basic syntax highlighting synchronously. If you type the word
if, and 300ms later after you've already moved the cursor, theifturns yellow, that's not a good user experience. Syntax information that is obtained from external compilers via child processes or RPC is never going to be available quickly enough for synchronous syntax highlighting. JetBrains IDEs, for example, perform tokenization synchronously, even though they do parsing and semantic analysis asynchronously.Now for some languages, there may be a parser that we could call synchronously from javascript, but it would need to support things like nested languages (e.g. JavaScript within HTML within Markdown). This limits the number of languages that we could apply this technique to pretty severely.
Anyway, I may be missing something here, but it seems like we need to view this as enabling cool IDE features on top of Atom's built-in highlighting, not replacing it for performance improvements.
jordwalke commentedon Oct 27, 2016
We would definitely be interested in this. There are things that are just very difficult to do without proper language tooling to actually parse and understand the grammar. We would still like the current Atom highlighting convention for "recovered" regions that our tooling detected invalid parses for, but for the large portion of the buffer that is a valid parse, we can provide a much more accurate highlighting (and furthermore we can do it much faster with
yaccgenerated parsers). Our tooling would be capable of telling Atom exactly which regions of text should be highlighted using which token class, and we can tell Atom exactly which regions of text we were not able to parse at all (and should therefore fall back to some much less accurate (but easy to build) Atom specific interactive tokenizing).pmlodawski commentedon May 31, 2017
stale commentedon May 31, 2018
laughedelic commentedon May 31, 2018
I'm not sure if the tree-sitter introduction solves this issue, but anyway it's better not to close it without a triage.
stale commentedon May 31, 2019
Thanks for your contribution!
This issue has been automatically marked as stale because it has not had recent activity. Because the Atom team treats their issues as their backlog, stale issues are closed. If you would like this issue to remain open:
Issues that are labeled as triaged will not be automatically marked as stale.
lock commentedon Dec 11, 2019
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!