From ccc6b25791ee5685a26663dffeb6d36702b3131d Mon Sep 17 00:00:00 2001 From: Matthew Toohey Date: Tue, 3 May 2022 23:58:53 -0400 Subject: [PATCH 1/3] feat(languages): git-ignore and git-attributes --- book/src/generated/lang-support.md | 2 ++ helix-core/src/syntax.rs | 2 +- languages.toml | 26 +++++++++++++++++++ runtime/queries/git-attributes/highlights.scm | 9 +++++++ runtime/queries/git-ignore/highlights.scm | 25 ++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/git-attributes/highlights.scm create mode 100644 runtime/queries/git-ignore/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 5c5ecaafe57c..b4e7ff93e402 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 eab3ab79fbb3..9208f0e8e1b7 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 = - 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 10f8f8441493..1405ae529f53 100644 --- a/languages.toml +++ b/languages.toml @@ -956,6 +956,32 @@ indent = { tab-width = 4, unit = "\t" } 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 = "ba4b39afcabf8a605f7a382f30be9450ac09ff08" } + +[[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 = "2e4cd389d2e187864569cf8fa8098a7e3d03bad6" } + [[language]] name = "graphql" scope = "source.graphql" diff --git a/runtime/queries/git-attributes/highlights.scm b/runtime/queries/git-attributes/highlights.scm new file mode 100644 index 000000000000..0b1415b581b7 --- /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 000000000000..4264eb04e217 --- /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 From 20147c26b0d502d5850df591bda0267bfa68dce8 Mon Sep 17 00:00:00 2001 From: Matthew Toohey Date: Wed, 4 May 2022 15:01:25 -0400 Subject: [PATCH 2/3] chore(languages): bump tree-sitter-gitattributes --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 1405ae529f53..bc4193ae1185 100644 --- a/languages.toml +++ b/languages.toml @@ -967,7 +967,7 @@ grammar = "gitattributes" [[grammar]] name = "gitattributes" -source = { git = "https://github.com/mtoohey31/tree-sitter-gitattributes", rev = "ba4b39afcabf8a605f7a382f30be9450ac09ff08" } +source = { git = "https://github.com/mtoohey31/tree-sitter-gitattributes", rev = "3dd50808e3096f93dccd5e9dc7dc3dba2eb12dc4" } [[language]] name = "git-ignore" From 5fee71f19ad8cdf0744dd75abcffdea9cc75cae7 Mon Sep 17 00:00:00 2001 From: Matthew Toohey Date: Thu, 5 May 2022 09:34:11 -0400 Subject: [PATCH 3/3] chore(languages): bump tree-sitter-gitignore --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index bc4193ae1185..0d1c73f5f475 100644 --- a/languages.toml +++ b/languages.toml @@ -980,7 +980,7 @@ grammar = "gitignore" [[grammar]] name = "gitignore" -source = { git = "https://github.com/shunsambongi/tree-sitter-gitignore", rev = "2e4cd389d2e187864569cf8fa8098a7e3d03bad6" } +source = { git = "https://github.com/shunsambongi/tree-sitter-gitignore", rev = "f4685bf11ac466dd278449bcfe5fd014e94aa504" } [[language]] name = "graphql"