aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Toohey2022-05-05 13:47:28 +0000
committerGitHub2022-05-05 13:47:28 +0000
commita5f4925f53d447bb7201c9a6e7a1c2730f292ae4 (patch)
tree3e9c1a6d70df846a81d2848898220e0fe9ce01f4
parentfc61796895a0175ccfed7f572960dc3cd21e7f04 (diff)
feat(languages): git-ignore and git-attributes (#2397)
-rw-r--r--book/src/generated/lang-support.md2
-rw-r--r--helix-core/src/syntax.rs2
-rw-r--r--languages.toml26
-rw-r--r--runtime/queries/git-attributes/highlights.scm9
-rw-r--r--runtime/queries/git-ignore/highlights.scm25
5 files changed, 63 insertions, 1 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 5c5ecaaf..b4e7ff93 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -20,9 +20,11 @@
| erlang | ✓ | | | `erlang_ls` |
| fish | ✓ | ✓ | ✓ | |
| gdscript | ✓ | | ✓ | |
+| git-attributes | ✓ | | | |
| git-commit | ✓ | | | |
| git-config | ✓ | | | |
| git-diff | ✓ | | | |
+| git-ignore | ✓ | | | |
| git-rebase | ✓ | | | |
| gleam | ✓ | | | |
| glsl | ✓ | | ✓ | |
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index eab3ab79..9208f0e8 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -321,7 +321,7 @@ impl TextObjectQuery {
fn read_query(language: &str, filename: &str) -> String {
static INHERITS_REGEX: Lazy<Regex> =
- Lazy::new(|| Regex::new(r";+\s*inherits\s*:?\s*([a-z_,()]+)\s*").unwrap());
+ Lazy::new(|| Regex::new(r";+\s*inherits\s*:?\s*([a-z_,()-]+)\s*").unwrap());
let query = load_runtime_file(language, filename).unwrap_or_default();
diff --git a/languages.toml b/languages.toml
index 9d3ad27b..279dab1f 100644
--- a/languages.toml
+++ b/languages.toml
@@ -957,6 +957,32 @@ name = "git-config"
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-config", rev = "0e4f0baf90b57e5aeb62dcdbf03062c6315d43ea" }
[[language]]
+name = "git-attributes"
+scope = "source.gitattributes"
+roots = []
+file-types = [".gitattributes"]
+injection-regex = "git-attributes"
+comment-token = "#"
+grammar = "gitattributes"
+
+[[grammar]]
+name = "gitattributes"
+source = { git = "https://github.com/mtoohey31/tree-sitter-gitattributes", rev = "3dd50808e3096f93dccd5e9dc7dc3dba2eb12dc4" }
+
+[[language]]
+name = "git-ignore"
+scope = "source.gitignore"
+roots = []
+file-types = [".gitignore"]
+injection-regex = "git-ignore"
+comment-token = "#"
+grammar = "gitignore"
+
+[[grammar]]
+name = "gitignore"
+source = { git = "https://github.com/shunsambongi/tree-sitter-gitignore", rev = "f4685bf11ac466dd278449bcfe5fd014e94aa504" }
+
+[[language]]
name = "graphql"
scope = "source.graphql"
injection-regex = "graphql"
diff --git a/runtime/queries/git-attributes/highlights.scm b/runtime/queries/git-attributes/highlights.scm
new file mode 100644
index 00000000..0b1415b5
--- /dev/null
+++ b/runtime/queries/git-attributes/highlights.scm
@@ -0,0 +1,9 @@
+; inherits: git-ignore
+
+(attribute) @variable
+(value) @string
+
+(quoted_pattern ["\""] @string)
+
+(attribute_unset) @operator
+(attribute_set_to) @operator
diff --git a/runtime/queries/git-ignore/highlights.scm b/runtime/queries/git-ignore/highlights.scm
new file mode 100644
index 00000000..4264eb04
--- /dev/null
+++ b/runtime/queries/git-ignore/highlights.scm
@@ -0,0 +1,25 @@
+(pattern_char) @string
+(pattern_char_escaped) @constant.character.escape
+
+(directory_separator) @string
+(directory_separator_escaped) @constant.character.escape
+
+(negation) @operator
+
+(wildcard_char_single) @operator
+(wildcard_chars) @operator
+(wildcard_chars_allow_slash) @operator
+
+(bracket_char) @string
+(bracket_char_escaped) @constant.character.escape
+
+(bracket_negation) @operator
+(bracket_range) @operator
+(bracket_char_class) @keyword
+
+[
+ "["
+ "]"
+] @punctuation.bracket
+
+(comment) @comment