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

Syntax: Add highlighting for section comments #296

Merged
merged 1 commit into from
Feb 26, 2022

Conversation

deathaxe
Copy link
Member

@deathaxe deathaxe commented May 26, 2020

It's not an official feature of a sublime-syntax file, but as I started to split syntaxes into sections for better readability I'd find it a good idea to also use them for navigation.

Syntaxes which make use of sections are:

Inspired by the contexts recently added to R.
see: sublimehq/Packages@d43b3b7

@FichteFoll
Copy link
Member

FichteFoll commented Jun 7, 2020

While I do see value in having some sort of section markers in a long file, this is very much non-standard. Many people use different syntaxes for denoting sections and I don't see a compelling reason for why we should support this syntax in particular.

Is this format ever used somewhere outside of RStudio? Do you have any references?

Copy link

@midopooler midopooler left a comment

Choose a reason for hiding this comment

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

LGTM

@deathaxe
Copy link
Member Author

I decided to use this style of grouping related contexts in all my recent syntax updates, many of them merged and shipped with ST.

I like the one-liner style and the ability to break long files into logical pieces. They allow folding related stuff which makes editing easier.

Such a kind of delimiters is especially useful as inheritance requires as many contexts as possible to be turned into named contexts because an inherited syntax would otherwise not be able to provide overrides.

We could say: A syntax desined to be a base syntax for inheritance must not use anonymous contexts, which causes many named contexts to be added to a syntax file, which need to be grouped logically somehow.

@FichteFoll
Copy link
Member

I decided to use this style of grouping related contexts in all my recent syntax updates, many of them merged and shipped with ST.

Could you point me to some examples? I'm not finding anything other than for R. https://github.com/sublimehq/Packages/search?q=entity.name.section

I'm not opposed to adding some sort of section marker to syntax highlighting and I'm okay with more or less dictating the style to be used, since I believe we have this freedom as the only package providing syntax definitions for ST resource files.
But there are way too many different section marking comment styles out in the wild and I'd like the marker to be consistent with other (popular) syntaxes and even better if the default packages used the same schema. Has Will ever commented on this?

@deathaxe
Copy link
Member Author

deathaxe commented Jan 25, 2021

Is the list in the initial post not enough?

EDIT: Added some more.

@FichteFoll
Copy link
Member

Ah, I think I completely missed what meant with your examples. I was looking for matches in the syntax definitions that would apply entity.name.section to a specifically formatted comment instead of instances of what you mean to highlight with this PR.

I doubt we'll get a "wider adoption" of this standard other than the default packages, probably, and at this point I'm fine with dictating the format. I believe we'd want to add a snippet that inserts a comment formatted like this and document that in the wiki, but I can take care of that when I prepare another release.

@deathaxe
Copy link
Member Author

Even though not enforced by the syntax and some rules exceeding it anyway, I always tried to adjust those delimiters to 80 chars, just to make it look well, if everything is collapsed. Not sure if a snippet could also help with that as the captions are typed after committing it.

@FichteFoll FichteFoll added this to the 3.3.2 milestone Feb 26, 2022
@FichteFoll FichteFoll merged commit 843eec9 into SublimeText:master Feb 26, 2022
@FichteFoll
Copy link
Member

I added some refinements in 8c3b361.

@deathaxe deathaxe deleted the pr/syntax-section-headers branch March 27, 2022 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants