From a01338af30d39b3f5ba7f0a00a8adeddc26699b7 Mon Sep 17 00:00:00 2001 From: Denis Gruzdev Date: Thu, 3 Oct 2024 12:59:00 +0000 Subject: [PATCH] feat: Add language support for nginx config files --- book/src/generated/lang-support.md | 1 + languages.toml | 14 +++++++++ runtime/queries/nginx/highlights.scm | 44 ++++++++++++++++++++++++++++ runtime/queries/nginx/injections.scm | 4 +++ 4 files changed, 63 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 79f3a69647a3..1e6cae8f5b4d 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -134,6 +134,7 @@ | move | ✓ | | | | | msbuild | ✓ | | ✓ | | | nasm | ✓ | ✓ | | | +| nginx | ✓ | | | | | nickel | ✓ | | ✓ | `nls` | | nim | ✓ | ✓ | ✓ | `nimlangserver` | | nix | ✓ | ✓ | | `nil`, `nixd` | diff --git a/languages.toml b/languages.toml index 806aa815e618..1e8dd3f8bf64 100644 --- a/languages.toml +++ b/languages.toml @@ -3810,3 +3810,17 @@ language-servers = ["circom-lsp"] [[grammar]] name = "circom" source = { git = "https://github.com/Decurity/tree-sitter-circom", rev = "02150524228b1e6afef96949f2d6b7cc0aaf999e" } + +[[language]] +name = "nginx" +scope = "source.nginx" +injection-regex = "nginx" +file-types = ["conf"] +roots = [] +comment-token = "#" +indent = { tab-width = 4, unit = " " } +auto-format = false + +[[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 000000000000..67c678a90a27 --- /dev/null +++ b/runtime/queries/nginx/highlights.scm @@ -0,0 +1,44 @@ +(comment) @comment + +(number) @number +(metric) @number + +(regex) @regex + +(variable) @variable + +(modifier) @operator + +(simple_directive + name: (directive) @function) + +(block_directive + name: (directive) @function) + +(lua_block_directive + "access_by_lua_block" @function) + +((generic) @constant.builtin + (#match? @constant.builtin "^(off|on)$")) + +(generic) @string +(string) @string + +(scheme) @string +(ipv4) @number + +[ + ";" +] @delimiter + +[ + "{" + "}" + "(" + ")" + "[" + "]" +] @punctuation.bracket + +; Lua Debug +(lua_code) @definition.type diff --git a/runtime/queries/nginx/injections.scm b/runtime/queries/nginx/injections.scm new file mode 100644 index 000000000000..1c89f46b8057 --- /dev/null +++ b/runtime/queries/nginx/injections.scm @@ -0,0 +1,4 @@ +; Script tags +((lua_code) @injection.content + (#set! injection.language "lua") + (#set! injection.combined))