oakmac / tree-sitter-clojure

Clojure / ClojureScript grammar for tree-sitter
MIT License
32 stars 5 forks source link

Clojure and ClojureScript should have awesome syntax highlighting #1

Open oakmac opened 5 years ago

oakmac commented 5 years ago

Most existing solutions for syntax highlighting for Clojure and ClojureScript use regular expressions, which are not robust enough to understand Clojure code and often result in complex, difficult to maintain regular expressions.

Tree-sitter is an ambitious new library for syntax highlighting that uses a language grammar for improved syntax highlighting and code folding.

Clojure and ClojureScript syntax highlighting can be greatly improved in many environments by having a complete tree-sitter grammar.

sogaiu commented 4 years ago

I've worked with Clojure / ClojureScript / ClojureCLR in a variety of editors including Emacs, vim, Atom, VSCode, and IDEA. I did notice that the highlighting wasn't perfect and sometimes really slow on large files pretty much in most cases, but for the most part have been pretty happy.

If you have some thoughts about details for what you think could be improved, would you mind sharing them some time?

I tried some experiments in VSCode with the 3 tree-sitter grammars for syntax highlighting. One thing I tried was to color the names of forms being defined by the various "def" forms. Another thing was to color the symbol in the call position of a list form. Changing keywords' colors also. Also the functionality similar to rainbow parens, though only for '(', ')', '[', and ']' (i.e. no curly braces).

I think having different colors for some of the different kinds of things can be helpful, e.g. comments in one color, strings in another.

Having concrete ideas of what would be desirable to highlight I think could inform what is better to have in the grammar.