|
1 | 1 | # tree-sitter-gitcommit |
2 | 2 |
|
3 | | -**This grammar is under development** |
| 3 | +[](https://github.com/gbprod/tree-sitter-gitcommit/actions/workflows/ci.yml) |
4 | 4 |
|
5 | 5 | `gitcommit` grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter). |
6 | 6 |
|
7 | 7 | Support [Conventionnal commit](https://www.conventionalcommits.org) specifications. |
8 | 8 |
|
9 | | -[](https://github.com/gbprod/tree-sitter-gitcommit/actions/workflows/ci.yml) |
10 | | - |
11 | | -## Installation |
12 | | - |
13 | | -### Neovim |
14 | | - |
15 | | -As this grammar is not (yet) available throught [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter), |
16 | | -you must install it manualy. |
17 | | - |
18 | | -```lua |
19 | | -local parser_config = require("nvim-treesitter.parsers").get_parser_configs() |
20 | | - |
21 | | -parser_config.gitcommit = { |
22 | | - install_info = { |
23 | | - url = "https://github.com/gbprod/tree-sitter-gitcommit", |
24 | | - files = { "src/parser.c", "src/scanner.c" }, |
25 | | - branch = "main", |
26 | | - }, |
27 | | - filetype = "gitcommit", |
28 | | - maintainers = { "@gbprod" }, |
29 | | -} |
30 | | -``` |
31 | | - |
32 | | -Then we need some queries for nvim-treesitter: |
33 | | - |
34 | | -Edit file `~/.config/nvim/after/queries/gitcommit/highlights.scm` or execute `:TSEditQueryUserAfter highlights gitcommit` |
35 | | -and copy the content of [`queries/highlights.scm`](https://github.com/gbprod/tree-sitter-gitcommit/blob/main/queries/highlights.scm). |
36 | | - |
37 | | -Edit file `~/.config/nvim/after/queries/gitcommit/injections.scm` or execute `:TSEditQueryUserAfter injections gitcommit` with the content: |
38 | | - |
39 | | -```scheme |
40 | | -(diff) @diff |
41 | | -(rebase_command) @git_rebase |
42 | | -``` |
43 | | - |
44 | | -Now we can install the `gitcommit` parser via nvim-treesitter. |
45 | | - |
46 | | -```vim |
47 | | -:TSInstall gitcommit |
48 | | -``` |
49 | | - |
50 | | -To have a complete highlight, you should have `git_rebase` and `diff` parsers installed : |
51 | | - |
52 | | -```vim |
53 | | -:TSInstall diff git_rebase |
54 | | -``` |
55 | | - |
56 | 9 | ## Credits |
57 | 10 |
|
58 | 11 | - [https://github.com/the-mikedavis/tree-sitter-git-commit](https://github.com/the-mikedavis/tree-sitter-git-commit) good parser but [only works in english](https://github.com/the-mikedavis/tree-sitter-git-commit/issues/4). |
0 commit comments