Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Support external tokenizers #8669

Closed
Closed

Description

@jpsim

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.

I'd love if Atom supported syntax highlighting based on external tokenizers. It would allow, for example, highlighting Swift code using the same mechanism Xcode uses (see https://github.com/jpsim/SourceKitten#syntax).

Activity

  1. mehcode commented on Sep 4, 2015

    @mehcode
    Contributor

    👍 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.

  2. p-e-w commented on Sep 12, 2015

    @p-e-w
    Contributor

    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.

  3. hedefalk commented on Oct 11, 2015

    @hedefalk

    +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.

  4. kpmeen commented on Oct 12, 2015

    @kpmeen
  5. nightscape commented on Oct 12, 2015

    @nightscape
  6. jurStv commented on Oct 12, 2015

    @jurStv
  7. maxbrunsfeld commented on Oct 12, 2015

    @maxbrunsfeld
    Contributor

    /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.

  8. jordwalke commented on Oct 27, 2016

    @jordwalke

    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).

  9. pmlodawski commented on May 31, 2017

    @pmlodawski
  10. stale commented on May 31, 2018

    @stale
  11. laughedelic commented on May 31, 2018

    @laughedelic

    I'm not sure if the tree-sitter introduction solves this issue, but anyway it's better not to close it without a triage.

  12. stale commented on May 31, 2019

    @stale

    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:

    1. Verify that you can still reproduce the issue in the latest version of Atom
    2. 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.

  13. lock commented on Dec 11, 2019

    @lock

    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!

  14. locked as resolved and limited conversation to collaborators on Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions