vim-racket icon indicating copy to clipboard operation
vim-racket copied to clipboard

ftdetect: Support #lang at-exp chains

Open sundbry opened this issue 3 years ago • 7 comments

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

sundbry avatar Jul 22 '21 07:07 sundbry

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 avatar Aug 08 '21 20:08 benknoble

@benknoble How do you run the tests for this project?

sundbry avatar Aug 08 '21 21:08 sundbry

I added an example file with #lang at-exp and used your suggestion for a non-capturing group (good idea, thanks!).

sundbry avatar Aug 08 '21 22:08 sundbry

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."

benknoble avatar Aug 09 '21 11:08 benknoble

HI @benknoble, did you see the test file I added? Good luck with the pollen/ @ expression parser!!

sundbry avatar Aug 14 '21 06:08 sundbry

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.

benknoble avatar Aug 14 '21 15:08 benknoble

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.

benknoble avatar Aug 14 '21 16:08 benknoble