From e0a99ae51ac099e30dc1039f9ac1059bba90a806 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 9 Jan 2022 08:10:20 -0600 Subject: [PATCH] add tree-sitter-git-config (#1426) * add tree-sitter-git-config * add todo comment for improving filetype check --- .gitmodules | 4 +++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-git-config | 1 + languages.toml | 10 +++++++ runtime/queries/git-config/highlights.scm | 27 +++++++++++++++++++ 5 files changed, 43 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-git-config create mode 100644 runtime/queries/git-config/highlights.scm diff --git a/.gitmodules b/.gitmodules index e6d9d6541..3442652a6 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 c093144f0..8b599f6b4 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 000000000..0e4f0baf9 --- /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 afee20aad..0a19bb044 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 000000000..84767edc6 --- /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