diff --git a/.gitmodules b/.gitmodules index e6d9d6541457..3442652a65a2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -198,3 +198,7 @@ path = helix-syntax/languages/tree-sitter-make url = https://github.com/alemuller/tree-sitter-make shallow = true +[submodule "helix-syntax/languages/tree-sitter-git-config"] + path = helix-syntax/languages/tree-sitter-git-config + url = https://github.com/the-mikedavis/tree-sitter-git-config.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index c093144f0f74..8b599f6b4dc7 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -12,6 +12,7 @@ | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | +| git-config | ✓ | | | | | git-diff | ✓ | | | | | git-rebase | ✓ | | | | | glsl | ✓ | | ✓ | | diff --git a/helix-syntax/languages/tree-sitter-git-config b/helix-syntax/languages/tree-sitter-git-config new file mode 160000 index 000000000000..0e4f0baf90b5 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-config @@ -0,0 +1 @@ +Subproject commit 0e4f0baf90b57e5aeb62dcdbf03062c6315d43ea diff --git a/languages.toml b/languages.toml index afee20aad3ef..0a19bb0449d6 100644 --- a/languages.toml +++ b/languages.toml @@ -545,3 +545,13 @@ scope = "source.regex" injection-regex = "regex" file-types = ["regex"] roots = [] + +[[language]] +name = "git-config" +scope = "source.gitconfig" +roots = [] +# TODO: allow specifying file-types as a regex so we can read directory names (e.g. `.git/config`) +file-types = [".gitmodules", ".gitconfig"] +injection-regex = "git-config" +comment-token = "#" +indent = { tab-width = 4, unit = "\t" } diff --git a/runtime/queries/git-config/highlights.scm b/runtime/queries/git-config/highlights.scm new file mode 100644 index 000000000000..84767edc6339 --- /dev/null +++ b/runtime/queries/git-config/highlights.scm @@ -0,0 +1,27 @@ +((section_name) @keyword.directive + (#eq? @keyword.directive "include")) + +((section_header + (section_name) @keyword.directive + (subsection_name)) + (#eq? @keyword.directive "includeIf")) + +(section_name) @markup.heading +(variable (name) @variable.other.member) +[(true) (false)] @constant.builtin.boolean +(integer) @constant.numeric.integer + +((string) @string.special.path + (#match? @string.special.path "^(~|./|/)")) + +[(string) (subsection_name)] @string + +[ + "[" + "]" + "\"" +] @punctuation.bracket + +"=" @punctuation.delimiter + +(comment) @comment