A tree-sitter based major mode for editing Git commit messages in GNU Emacs.
Evaluate the Lisp code below:
(add-to-list 'treesit-language-source-alist
'(gitcommit . ("https://github.com/gbprod/tree-sitter-gitcommit")))
Running M-x treesit-install-language-grammar [RET] gitcommit
will compile and
install the latest tree-sitter-gitcommit.
If you use elpaca and use-package to manage packages in Emacs, use the following code to install git-commit-ts-mode
:
(use-package git-commit-ts-mode
:elpaca (git-commit-ts-mode :host github
:repo "danilshvalov/git-commit-ts-mode")
:mode "\\COMMIT_EDITMSG\\'")
To specify the maximum allowed message size, use the git-commit-ts-max-message-size
variable (default value is 72). If the specified limit is exceeded, the rest of the message will be highlighted using git-commit-ts-overflow-face
.
To use git-commit-ts-mode
in the Magit commit buffer, you need to change the value of the git-commit-major-mode
variable, for example, as follows:
(setq git-commit-major-mode 'git-commit-ts-mode)