summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2020-06-01 00:22:59 +0200
committerStephan Seitz <stephan.seitz@fau.de>2020-06-14 13:09:38 +0200
commit45ea0df21a8494c7a8258bbb98ebd510716148e9 (patch)
tree7d6468805fb54b9cfcadb4b2c4e8de0e585d3cf5
parenta06792450799f7cfe24cebac099cb47d640a2be3 (diff)
Add tree-sitter-regex
This might be interesting for injected highlighting
-rw-r--r--README.md1
-rw-r--r--lua/nvim-treesitter/configs.lua7
-rw-r--r--queries/regex/highlights.scm29
3 files changed, 37 insertions, 0 deletions
diff --git a/README.md b/README.md
index c31ce898..233487d7 100644
--- a/README.md
+++ b/README.md
@@ -180,6 +180,7 @@ List of currently supported languages:
- [ ] yaml
- [ ] nix
- [ ] markdown
+- [x] regex (maintained by @theHamsta)
## Troubleshooting
Before doing anything run `:checkhealth nvim_treesitter`. This will help you find where the bug might come from.
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua
index f79fed00..f7b5ff2c 100644
--- a/lua/nvim-treesitter/configs.lua
+++ b/lua/nvim-treesitter/configs.lua
@@ -203,6 +203,13 @@ parsers.nix = {
}
}
+parsers.regex = {
+ install_info = {
+ url = "https://github.com/tree-sitter/tree-sitter-regex",
+ files = { "src/parser.c" }
+ }
+}
+
-- @enable can be true or false
-- @disable is a list of languages, only relevant if enable is true
-- @keymaps list of user mappings for a given module if relevant
diff --git a/queries/regex/highlights.scm b/queries/regex/highlights.scm
new file mode 100644
index 00000000..48242543
--- /dev/null
+++ b/queries/regex/highlights.scm
@@ -0,0 +1,29 @@
+;; Forked from tree-sitter-regex
+;; The MIT License (MIT) Copyright (c) 2014 Max Brunsfeld
+[
+ "("
+ ")"
+ "(?"
+ "(?:"
+ "(?<"
+ ">"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+(group_name) @property
+
+[
+ (identity_escape)
+ (control_letter_escape)
+ (character_class_escape)
+ (control_escape)
+ (start_assertion)
+ (end_assertion)
+ (boundary_assertion)
+ (non_boundary_assertion)
+] @escape
+
+[ "*" "+" "|" "=" "<=" "!" "<!" ] @operator