Unnamed repository; edit this file 'description' to name the repository.
feat: Nginx support (#12309)
Co-authored-by: Denis Gruzdev <[email protected]>
Nikita Revenco 2024-12-25
parent 9e77c44 · commit 0fd4a4a
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml18
-rw-r--r--runtime/queries/nginx/highlights.scm45
-rw-r--r--runtime/queries/nginx/injections.scm9
4 files changed, 73 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index c1c4dbb1..850facd1 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -140,6 +140,7 @@
| msbuild | ✓ | | ✓ | |
| nasm | ✓ | ✓ | | |
| nestedtext | ✓ | ✓ | ✓ | |
+| nginx | ✓ | | | |
| nickel | ✓ | | ✓ | `nls` |
| nim | ✓ | ✓ | ✓ | `nimlangserver` |
| nix | ✓ | ✓ | | `nil`, `nixd` |
diff --git a/languages.toml b/languages.toml
index 9adb1865..04889068 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4004,3 +4004,21 @@ indent = { tab-width = 4, unit = " " }
[[grammar]]
name = "vento"
source = { git = "https://github.com/ventojs/tree-sitter-vento", rev = "3321077d7446c1b3b017c294fd56ce028ed817fe" }
+
+[[language]]
+name = "nginx"
+scope = "source.nginx"
+injection-regex = "nginx"
+file-types = [
+ { glob = "sites-available/*.conf" },
+ { glob = "sites-enabled/*.conf" },
+ { glob = "nginx.conf" },
+ { glob = "conf.d/*.conf" }
+]
+roots = ["nginx.conf"]
+comment-token = "#"
+indent = { tab-width = 4, unit = " " }
+
+[[grammar]]
+name = "nginx"
+source = { git = "https://gitlab.com/joncoole/tree-sitter-nginx", rev = "b4b61db443602b69410ab469c122c01b1e685aa0" }
diff --git a/runtime/queries/nginx/highlights.scm b/runtime/queries/nginx/highlights.scm
new file mode 100644
index 00000000..2b6dd347
--- /dev/null
+++ b/runtime/queries/nginx/highlights.scm
@@ -0,0 +1,45 @@
+(comment) @comment
+
+(block_directive
+ (directive) @type)
+
+[
+ "{"
+ "}"
+ "("
+ ")"
+ "["
+ "]"
+] @punctuation.bracket
+
+(simple_directive
+ (directive) @function)
+
+[
+ ";"
+] @punctuation.delimiter
+
+((generic) @keyword
+ (#any-of? @keyword
+ "on"
+ "off"
+ "any"
+ "auto"))
+
+(modifier) @operator
+
+(generic) @variable
+
+(string) @string
+
+(number) @constant.numeric
+(metric) @constant.numeric
+
+(variable) @variable.parameter
+
+(regex) @string
+
+(modifier) @keyword.operator
+
+(lua_block_directive
+ "access_by_lua_block" @function)
diff --git a/runtime/queries/nginx/injections.scm b/runtime/queries/nginx/injections.scm
new file mode 100644
index 00000000..03c3786f
--- /dev/null
+++ b/runtime/queries/nginx/injections.scm
@@ -0,0 +1,9 @@
+((lua_code) @injection.content
+ (#set! injection.language "lua")
+ (#set! injection.combined))
+
+((regex) @injection.content
+ (#set! injection.language "regex"))
+
+((comment) @injection.content
+ (#set! injection.language "comment"))