~whynothugo/tree-sitter-sway

sway config grammar for tree-sitter

d55ef06 Add an extra note for future reference

3 months ago

a285781 Add a README

3 months ago

#tree-sitter-sway

A tree-sitter for sway's config style.

This is very incomplete and won't really work except for a few keywords.

If you're interested in seeing this tree-sitter finalised, I'd suggest starting from scratch with something that merely recognise keywords, arguments, comments, blocks and colours. Trying to recognise individual commands and their arguments in the expected format is too much work and not worth it. Also note that colours vs comments might require a bit of attention. I suggest handling font as a special case, and not using comment as an extra rule.

Don't make the same mistakes I did.

Oh, you might want to treat arguments with : different, and also purely-numeric ones too. It'll yield better highlighting results.


This repo is mostly shared as an experiment: it proves that this approach is a bad one. Scientists often publish articles on how they ran an experiment to prove their hypothesis and they were proved wrong. In the same spirit, I hope others wanting to implement this tree-sitter can benefit from using this bad approach as a warning.