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

Git commit message length based highlighting #2882

Open
A-Walrus opened this issue Jun 26, 2022 · 3 comments
Open

Git commit message length based highlighting #2882

A-Walrus opened this issue Jun 26, 2022 · 3 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@A-Walrus
Copy link
Contributor

Describe your feature request

When using helix as the editor for git I want the commit message to have highlighting which indicates whether it is too long (over 50 characters).

This is available in Neovim like this:
image

I think this is a useful feature for making sure your messages are not too long.

@A-Walrus A-Walrus added the C-enhancement Category: Improvements label Jun 26, 2022
@archseer
Copy link
Member

It's not the same but you could use the ruler feature to indicate a max line length

@the-mikedavis
Copy link
Member

I tried this out initially in tree-sitter-git-commit but I found that tree-sitter's compilation time for the grammar shot way up when using regular expressions with count quantifiers like

choice(alias(/.{1,50}/, $.short_message), alias(/.{51,}/, $.long_message))

I do want this kind of highlight though. I'll take a look at how bad that performance really gets and if it affects runtime performance or just compile-time. We can also try doing this by changing the queries instead of the grammar.

@the-mikedavis the-mikedavis added the A-tree-sitter Area: Tree-sitter label Jun 26, 2022
@the-mikedavis the-mikedavis self-assigned this Jun 26, 2022
the-mikedavis added a commit to the-mikedavis/helix that referenced this issue Jun 29, 2022
This is simpler than the neovim counterpart, we simply switch
scope based on length:

* 1-50: `markup.heading`
* 51-72: `warning`
* 73+: `error`

closes helix-editor#2882
@the-mikedavis
Copy link
Member

It's possible to do this if you'd like to override your git-commit highlights.scm: the-mikedavis@e2b8506

In order for this to be a good core feature we'd like to have it be configurable:

  • enabled / disabled
  • the number of characters it takes to go from one mode to the next

even if it's enabled by default (which is not a given).

Once we change configuration languages from TOML to something more general purpose it should be easier to support this1. In the meantime, the rulers feature is a reasonable way to guide commit message lengths (though not perfect because of the different good-practice lengths of messages and bodies).

Footnotes

  1. I'm thinking that along with a plugin system and/or more general purpose config language that it should be easier to control which tree-sitter queries are used via configuration.

@the-mikedavis the-mikedavis removed their assignment Jul 3, 2022
@the-mikedavis the-mikedavis added A-helix-term Area: Helix term improvements and removed A-tree-sitter Area: Tree-sitter labels Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants