Skip to content
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

ftdetect: Support #lang at-exp chains #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sundbry
Copy link

@sundbry sundbry commented Jul 22, 2021

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

@benknoble
Copy link
Contributor

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.

@sundbry
Copy link
Author

sundbry commented Aug 8, 2021

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

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
Copy link
Author

sundbry commented Aug 8, 2021

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

@benknoble
Copy link
Contributor

benknoble commented Aug 9, 2021

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

@sundbry
Copy link
Author

sundbry commented Aug 14, 2021

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

@benknoble
Copy link
Contributor

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 added a commit to benknoble/vim-racket that referenced this pull request Aug 14, 2021
Pull-request: wlangstroth#65

* sundbry/master:
  ftdetect: Support #lang at-exp chains

Conflicts:
  ftdetect/racket.vim
    The differences in `g:racket_hash_lang_dict` caused conflicts. Keep
    my dict and the new regex.
@benknoble
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants