-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Add Caddyfile lexer #363
Add Caddyfile lexer #363
Conversation
This is beautiful. 😍 |
Very nice! Please add a test file per the instructions in lexers/README.md. Overall looks pretty good, I'll come back with some suggestions shortly. |
) | ||
|
||
// CaddyfileCommon are the rules common to both of the lexer variants | ||
var CaddyfileCommon = Rules{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to make this or the other intermediate values public.
LGTM, merged. Any followups just send a new PR. |
Thanks! |
Thank you @alecthomas!! I already made a PR to update the Caddy website with this caddyserver/website#41 I definitely will have a followup PR soon, I noticed a few edgecases that aren't well covered. |
Might be useful for alecthomas#363.
Closes #338
So, I definitely have no idea what I'm doing 😄
I spent most of the day hacking on this, seems like it's in decent shape, but who knows. There's probably a much better way to approach it, but this is what I came up with after trying to resolve a ton of edge cases.
I was testing it doing a spam of:
and
$ go build && ./chroma --trace -l caddyfile Caddyfile
I implemented two lexers here because we have two main usecases - displaying a full Caddyfile config, and showing just partials (matchers and directives) in documentation and such.
I'm not certain which token types to pick, I just kinda with what sorta made sense and made it look pretty in the output 🤷♂️
I'd very much appreciate any tips/feedback on this. 🎉
Here's a couple somewhat representative config examples and screenshots. Caddyfiles are very rarely this long or complicated, but these show most of the tricky elements.
Another:
Screenshots:
Another: