helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.32k stars 2.47k forks source link

Git commit message length based highlighting #2882

Open A-Walrus opened 2 years ago

A-Walrus commented 2 years ago

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.

archseer commented 2 years ago

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

the-mikedavis commented 2 years ago

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 commented 2 years ago

It's possible to do this if you'd like to override your git-commit highlights.scm: https://github.com/the-mikedavis/helix/commit/e2b8506cca5cf6957cfa24b5179a070ee19ae37d

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

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 this[^1]. 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).

[^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.