Skip to content

Detect Git commit summaries not following the 50/72 rule #46

Closed
@ebkalderon

Description

@ebkalderon

One aspect of the standard gitcommit syntax highlighting present in Vim and Neovim that I particularly love is that it includes built-in rules that follow the 50/72 rule of writing Git commit messages. That is:

  1. If the commit summary extends beyond 50 characters, the syntax highlighting changes accordingly to gently warn you to shorten it, if you can.
  2. If the commit message extends beyond 72 characters, the syntax highlighting warns you that GitHub will automatically truncate your message (sometimes mid-word), insert ..., and overflow the rest into the commit message body, and you should definitely shorten it if you'd like your summary to remain intact.

This is helpful for folks writing commit messages who are looking to keep them nice. For reference, an example of such assistive highlighting in Neovim (using the standard gitcommit.vim syntax) is shown below:

Screenshot from 2023-07-26 14-51-00

On the other hand, this is how tree-sitter-gitcommit (installed via nvim-treesittter on my machine) highlights the same commit message:

Screenshot from 2023-07-26 14-55-01

It'd be great if this TS parser could apply similar syntax rules as those used in Vim/Neovim to detect poorly formed commit messages as they're being written, enabling editor color schemes to highlight these malformed sections accordingly. Thanks for maintaining this great open source parser!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions