How to implement syntax highlighting? #6
Replies: 5 comments 11 replies
-
Ideally, if language developers will provide implementation of the Language Server Protocol (https://microsoft.github.io/language-server-protocol/). Then you can hook up data which comes from LSP into TextView and apply appropriate rendering attributes. |
Beta Was this translation helpful? Give feedback.
-
With a help of https://github.com/ChimeHQ/Neon with tree-sitter parser and grammars is one way. I plan to add tree-sitter support to the STTextView at one point. |
Beta Was this translation helpful? Give feedback.
-
Would love to see tree-sitter or Neon integration with STTextView, especially for large docs / low latency use case. |
Beta Was this translation helpful? Give feedback.
-
First, just a quick clarification. The semantic tokens feature of Language Server Protocol can be used to augment existing highlighting, but it is not a great system on its own. Very high latency, often does not support incremental edits, and typically has a relatively small file size limitation. Think of it as a nice secondary system. Now, I made Neon because I've come to believe that it doesn't make sense for syntax highlighting to be within a view. It is much more flexible to keep the view and the data the view renders (the highlighted text) separate. Neon can probably just plug right into STTextView. And if not, I would be very happy to help make that work. At a higher level, I'd love to see STTextView be a very good text view, and to focus on that. I think that highlighting can be external, and both it and the view will end up better for it. |
Beta Was this translation helpful? Give feedback.
-
Use the dedicated plugin STTextView-Plugin-Neon it works great! |
Beta Was this translation helpful? Give feedback.
-
like markdown, go ...
Beta Was this translation helpful? Give feedback.
All reactions