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

Racket: Mark all quoted symbols as @symbol #5376

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

Conversation

17451k
Copy link

@17451k 17451k commented Sep 11, 2023

I've noticed that Neovim does not distinguish quoted and unquoted lists and highlights them the same.

For example, (a b c) is a list that can be evaluated as a function call to a with b and c as arguments. But '(a b c) is a list of the symbols a, b, and c, not evaluated, just data.

How it looks now:
image

How it will look with this PR:
image

As you may note, this PR doesn't fix highlighting inside (quote (a b c)) - this requires a minor change to the racket treesitter parser and will be implemented separately.

Important disclaimer: I am not a Racket expert, so it's possible that I understand quote semantics incorrectly. I've tried to look at how other editors highlight such code (Emacs, VS Code, Sublime Text, Helix), but they either do not highlight quotes at all, or highlight them approximately the same as Neovim now.

@17451k 17451k changed the title Mark all quoted symbols as @symbol Racket: Mark all quoted symbols as @symbol Sep 12, 2023
@Lazerbeak12345
Copy link

Lazerbeak12345 commented Sep 12, 2023

Here's how that code looks in DrRacket

image

I notice that the Strings are still the same normal color as they always are. I'm not sure what's the correct behavior here. (Side note, no idea what's going on with "astring")

@17451k
Copy link
Author

17451k commented Sep 13, 2023

@Lazerbeak12345 Thanks for checking! I've changed the PR to exclude changes to the Strings, now they will look more like in DrRacket.

image

@Lazerbeak12345
Copy link

Oh, don't forget numbers too.

image

@Lazerbeak12345
Copy link

Oh, and booleans. I'm pretty sure just most primitive values.

image

@17451k
Copy link
Author

17451k commented Sep 21, 2023

Yep, I didn't change the highlighting of other primitive types, nut in neovim they are already highlighted as symbols regardless of whether they are quoted or not.

@@ -58,7 +62,7 @@

(list
.
(symbol) @function)
(symbol) @function (#not-has-ancestor? @function quote))
Copy link
Member

@amaanq amaanq Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just an fyi the ancestor functions are expensive - I'd pick one to use it on, and then another not - so ideally the later more-strict query using an ancestor predicate will override the looser former one, you can structure it how you'd like

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.

None yet

3 participants