From 5c9ef47ef8782759af72e4a0e908bfb93e8a6673 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 24 Dec 2024 19:22:29 +0000 Subject: [PATCH] feat: Nginx support (#12309) Co-authored-by: Denis Gruzdev --- book/src/generated/lang-support.md | 1 + languages.toml | 18 +++++++++++ runtime/queries/nginx/highlights.scm | 45 ++++++++++++++++++++++++++++ runtime/queries/nginx/injections.scm | 9 ++++++ 4 files changed, 73 insertions(+) create mode 100644 runtime/queries/nginx/highlights.scm create mode 100644 runtime/queries/nginx/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index c1c4dbb10bdd5..850facd177b67 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 9adb186517ce7..048890684ac26 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 0000000000000..2b6dd34736fd4 --- /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 0000000000000..03c3786f937cc --- /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"))