Skip to content

Delimiter/Separator Highlighting #56

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Iron-E
Copy link

@Iron-E Iron-E commented Dec 18, 2020

This PR adds highlighting of separators/delimiters, and takes steps to increase the usage of those tokens in all areas of the syntax file.

This PR also incorporates functionality provided by #52.

master This PR
master PR

I know that the maintainer's opinion is that highlighting individual characters isn't all that useful­— although, from the perspective of a colorscheme maintainer it is the opposite:

  • If you want tokens in a language to appear the same, then one may simply change those links to be the same and any potential distraction is negated.
  • If one pursues adherence to semantic highlighting, not having enough customization means that there is just nothing you can do to further define tokens for a language.

As such, as long as display is used where applicable and nextgroup/contains is used to meaningfully provide hints to Vim about the location of syntax groups, the benefits appear to be enough that such changes are worth inclusion.

@Iron-E Iron-E changed the title Delimiter Highlighting Delimiter/Separator Highlighting Dec 18, 2020
@cespare
Copy link
Owner

cespare commented Sep 18, 2021

@a-vrma could you take a look at this?

@averms averms self-assigned this Sep 18, 2021
@Iron-E
Copy link
Author

Iron-E commented Sep 21, 2021

I meant to ask. Can you clarify how tomlKeyDq and Sq are used?

I should probably also give this one more pass since I've gotten more experience writing syntax files while working on the Rust syntax file since submitting the PR.

@Iron-E
Copy link
Author

Iron-E commented Sep 21, 2021

Pass complete. Sorry about that 😅

@averms
Copy link
Collaborator

averms commented Sep 26, 2021 via email

@Iron-E
Copy link
Author

Iron-E commented Sep 26, 2021

The benefit here is twofold:

  1. It clarifies certain parts of the syntax: [[foo]] on master is highlighted the same as a normal table, whereas in this PR it is clearly shown to be an array of table. Someone who doesn't even know that syntax could glean its meaning as of this PR.
  2. Users have the option to highlight delimiters and assignment operators as they wish, to maintain consistency with a their colorscheme over a broad range of syntax files (from all in vim-polyglot to elsewhere) which do pursue semantic highlighting to some degree. As a colorscheme maintainer, this plugin is currently the only one I support which doesn't allow synchronizing it for my users in the manner described above.

Treesitter is, in my experience, surprisingly less semantic than Vim syntax files. It will get there in time.

If it was a concern, these changes neither impact performance meaningfully nor increase the overhead of maintaining this plugin.

@Iron-E Iron-E force-pushed the feature/delimiter-highlighting branch from ff8da2f to e3b5698 Compare November 23, 2021 19:47
@Iron-E
Copy link
Author

Iron-E commented Nov 23, 2021

@averms Rebased onto master. No conflicts anymore

Iron-E added 10 commits May 12, 2022 15:55
Previously, connecting characters such as ',', '{}', '[]', and '=' where
not always highlighted. Further, there were several dedicated highlight
groups where only one comprehensive definition is needed.

For example, the `tomlTableArray` has been replaced with a `tomlTable`
that is wrapped inside of a `tomlArray`.
I believe I put these here because I saw a `,` in the definition, but
did not understand it was before the `\zs`.
@Iron-E Iron-E force-pushed the feature/delimiter-highlighting branch from 597dc31 to 9455b84 Compare May 12, 2022 19:55
@Iron-E
Copy link
Author

Iron-E commented May 12, 2022

Rebased onto master again.

@Iron-E
Copy link
Author

Iron-E commented Mar 23, 2023

@averms what is the status of this PR wrt #56 (comment) ?

@cespare
Copy link
Owner

cespare commented Apr 10, 2025

Sorry that this has just been sitting. From your description of the PR the change makes sense to me.

The problem is that it's hard to review. It will take me a while to page back in context about how vim syntax highlighting works, and with the interactions between groups and all the regexes it gets quite subtle. I'm afraid that if I just merge it, we'll find out that there are a bunch of regressions. So I do think that someone needs to do a close review first.

@averms any interest in picking it up? Or if someone else can convincingly provide a review, that would be great. Thanks.

@cespare
Copy link
Owner

cespare commented Apr 10, 2025

I did download and play around with this PR. It seems to mostly work in my tests. Here are some issues that I noticed, though:

  • tomlKey highlighting doesn't work quite right on some of the corner cases in test.toml.
    • 3.14159 = "pi" -- the LHS gets highlighted as a tomlFloat.
    • If you write apple . type = "fruit" (that is, you add some spaces), it gets highlighted as <nothing><tomlNoise><tomlKey>. The first part should also be tomlKey, I think. (The TOML spec says that is valid but discouraged.)
    • site."google.com" = true -- the LHS gets highlighted as <nothing><tomlNoise><tomlString> when it should be a key. (This is Quoted dotted keys break tomlKey highlighting #58, but should it be addressed by this reworking?)
  • I do think that highlighting tables vs. arrays so differently is quite odd/distracting. To me, at least, I find them conceptually similar. Just loading up the default Python and JSON highlighting for comparison, both of them highlight {...} and [...] the same way.
  • Highlighting = as Operator stands out as different from other syntaxes I'm used to.

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.

3 participants