Unnamed repository; edit this file 'description' to name the repository.
feat: add `robots.txt` language (#14089)
| -rw-r--r-- | book/src/generated/lang-support.md | 1 | ||||
| -rw-r--r-- | languages.toml | 12 | ||||
| -rw-r--r-- | runtime/queries/robots.txt/highlights.scm | 28 | ||||
| -rw-r--r-- | runtime/queries/robots.txt/injections.scm | 2 | ||||
| -rw-r--r-- | runtime/queries/robots.txt/tags.scm | 4 | ||||
| -rw-r--r-- | runtime/queries/robots.txt/textobjects.scm | 4 |
6 files changed, 51 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 7364e03c..17f01222 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -208,6 +208,7 @@ | rescript | ✓ | ✓ | | | | `rescript-language-server` | | rmarkdown | ✓ | | ✓ | | | `R` | | robot | ✓ | | | | | `robotframework_ls` | +| robots.txt | ✓ | ✓ | | ✓ | | | | ron | ✓ | | ✓ | | | | | rst | ✓ | | | | | | | ruby | ✓ | ✓ | ✓ | ✓ | ✓ | `ruby-lsp`, `solargraph` | diff --git a/languages.toml b/languages.toml index 7c6fe7a3..84a39ebd 100644 --- a/languages.toml +++ b/languages.toml @@ -4605,3 +4605,15 @@ comment-tokens = ["#"] [[grammar]] name = "properties" source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-properties", rev = "579b62f5ad8d96c2bb331f07d1408c92767531d9" } + +[[language]] +name = "robots.txt" +scope = "source.robots.txt" +file-types = [{ glob = "robots.txt" }] +injection-regex = "robots[\\.-]txt" +grammar = "robots" +comment-token = "#" + +[[grammar]] +name = "robots" +source = { git = "https://github.com/opa-oz/tree-sitter-robots-txt", rev = "8e3a4205b76236bb6dbebdbee5afc262ce38bb62" } diff --git a/runtime/queries/robots.txt/highlights.scm b/runtime/queries/robots.txt/highlights.scm new file mode 100644 index 00000000..b6eec1b6 --- /dev/null +++ b/runtime/queries/robots.txt/highlights.scm @@ -0,0 +1,28 @@ +(comment) @comment + +(directive) @attribute + +(rule (unknownDirective) @attribute) @diagnostic.error + +(userAgent) @namespace + +(value) @string + +((value) @string.special.path + (#match? @string.special.path "^/")) + +((value) @ui.text.directory + (#match? @ui.text.directory "^/.+/$")) + +((value) @operator + (#match? @operator "\\*")) + +(rule + (directive (sitemap)) + (value) @string.special.url) + +(rule + (directive (crawlDelay)) + (value) @constant.numeric.integer) + +":" @punctuation.delimiter diff --git a/runtime/queries/robots.txt/injections.scm b/runtime/queries/robots.txt/injections.scm new file mode 100644 index 00000000..2f0e58eb --- /dev/null +++ b/runtime/queries/robots.txt/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/robots.txt/tags.scm b/runtime/queries/robots.txt/tags.scm new file mode 100644 index 00000000..04a61c9c --- /dev/null +++ b/runtime/queries/robots.txt/tags.scm @@ -0,0 +1,4 @@ +(rule + (directive + (userAgent)) + (value) @definition.module) diff --git a/runtime/queries/robots.txt/textobjects.scm b/runtime/queries/robots.txt/textobjects.scm new file mode 100644 index 00000000..8374dda9 --- /dev/null +++ b/runtime/queries/robots.txt/textobjects.scm @@ -0,0 +1,4 @@ +(comment) @comment.inside +(comment)+ @comment.around + +(rule (_) @entry.inside) @entry.around |