vim-racket
vim-racket copied to clipboard
ftdetect: Support #lang at-exp chains
Modifies the regular expression to ignore at-exp
when present in the #lang statement, and use the next language in the chain.
See documentation for #lang at-exp at https://docs.racket-lang.org/scribble/reader-internals.html#%28part._at-exp-lang%29
This is clever. If you use a \%()
group it won't even affect the sub-matches, because it's non-capturing. I'd like to integrate this in my fork, but I need a good test-case to try first.
@benknoble How do you run the tests for this project?
I added an example file with #lang at-exp and used your suggestion for a non-capturing group (good idea, thanks!).
I don't run the tests, per se--they mostly exist to take a look at the highlighting working, AFAIK. I just wanted to see an example to compare.
I will note that it is likely to be difficult to correctly support @
syntax mixed with arbitrary other syntaxes (I've been trying to do this with a pollen syntax file for weeks, unsuccessfully), so the end result may be "fine but not perfect."
HI @benknoble, did you see the test file I added? Good luck with the pollen/ @
expression parser!!
Hey @sundbry , I did see it. Been a bit busy.
As I said earlier, it won't be perfect: anything in the @
expression is liable to get "funky" highlighting, since the syntax will effectively ignore it, and continue to highlight both []
and {}
groups as racket s-exprs. But, I like the idea, since it makes everything else look a bit nicer.
I'm going to merge this into my fork. If you come across similar things "language modifiers", LMK! I know of one (pollen/mode
), so I'll add that too.
I took the liberty of re-organizing to make it easier to declaratively add more modifying langs, and also to allow for better user-overriding.