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
[Suggestion]: Use TextMate grammar files for syntax highlighting #1453
Comments
I agree that the quality of the syntax highlighting is not especially great. However it is fast and simple. Switching to TextMate grammars not only involves a huge amount of work parsing the language and getting it to fit into micro's existing interface, but would also require that users have the Oniguruma regular expression library installed. The highlighting itself would likely be slower and the bloat from including syntax files in the binary would be larger (TextMate grammars are very large). There is the Chroma syntax highlighting library for Go (https://github.com/alecthomas/chroma), but from my initial tests it seems much too slow (it highlights 1000-line files in ~120ms, which micro does instantly). I'm open to ideas about switching the highlighting engine but I'd like to do so without disrupting the other features micro tries to maintain (simple, no dependencies, lightweight). |
Look no further than tree-sitter. Tree-sitter is an incremental parser designed for integration into text editors, especially with syntax highlighting in mind. Individual parsers exist for the most common programming languages. Their quality blows even TextMate grammars out of the water, while also being faster in most cases, especially when updating the buffer. Tree-sitter is the default highlighting system in Atom for supported languages. It has recently been integrated into Neovim master, and will be part of the upcoming 0.5 release of Neovim. Integration into VSCode and other editors has been repeatedly discussed. Tree-sitter has a bright future for sure and the quality and number of its grammars can only be expected to increase further with time. Tree-sitter has actively maintained Go bindings. Note that those "bindings" actually contain the entire tree-sitter parser, so including them does not incur any external dependencies. IMO, high-quality syntax highlighting makes the difference between a text editor that is suitable for everyday use and one that is not. |
I doubt this to be honest because ive yet to see vscode not highlight a 1000 lines js file in 0 perceivable seconds, ive never had a flash of uncolored text If advanced (alternative) highlighting such as textmate is not within the ideology of micro, maybe it can be in a form of an official plugin, so it's a valid option for users who need it without compromising the size, complexity for those who don't.
Indeed, if But I appreciate the recognition that the syntax highlighter leaves a lot to be desired. |
I have added tree-sitter as an alternative syntax highlighting engine, with very promising results. See the WIP in #1466. |
Description of the problem or steps to reproduce
The current state of the syntax highlighting is mediocre at best, and terrible at worst
Given that the leading editor (VSCode) is using TextMate grammar, is it possible to 'swipe' their complex tmLanguage files to get much better highlighting?
Here is the vscode interpreter solution in javascript
it's neatly written and not hard to understand
https://github.com/microsoft/vscode-textmate
so it should be rewritten in go which while a big task im not certain it would be extremely comlicated
This is a huge request and may only stay as a 'nice to have' for maybe 2.0? 3.0?
In any case I wouldn't disregard this idea.
Specifications
You can use
micro -version
to get the commit hash.Commit hash:
OS:
Terminal:
The text was updated successfully, but these errors were encountered: