From 45ea0df21a8494c7a8258bbb98ebd510716148e9 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 1 Jun 2020 00:22:59 +0200 Subject: [PATCH] Add tree-sitter-regex This might be interesting for injected highlighting --- README.md | 1 + lua/nvim-treesitter/configs.lua | 7 +++++++ queries/regex/highlights.scm | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 queries/regex/highlights.scm diff --git a/README.md b/README.md index c31ce8985..233487d7d 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 f79fed00c..f7b5ff2cf 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 000000000..48242543f --- /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 + +[ "*" "+" "|" "=" "<=" "!" "