aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--plugins/language_caddyfile.lua104
2 files changed, 105 insertions, 0 deletions
diff --git a/README.md b/README.md
index f5bf1fb..5fc4269 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,7 @@ to something other than a raw file it should be marked with an asterisk.*
| [`language_autohotkey`](https://github.com/devPnal/lite-plugin-autohotkey)\* | Syntax for the [AutoHotkey](https://www.autohotkey.com) programming language |
| [`language_batch`](plugins/language_batch.lua?raw=1) | Syntax for Windows [Batch Files](https://en.wikipedia.org/wiki/Batch_file) |
| [`language_bib`](plugins/language_bib.lua?raw=1) | Syntax for [BibTex](https://en.wikipedia.org/wiki/BibTeX) files |
+| [`language_caddyfile`](plugins/language_caddyfile.lua?raw=1) | Syntax for the Caddyfile used on the [Caddy](https://caddyserver.com/) web server |
| [`language_cmake`](plugins/language_cmake.lua?raw=1) | Syntax for the CMake build system language |
| [`language_containerfile`](https://github.com/FilBot3/lite-xl-language-containerfile)\* | Syntax for [Containerfile](https://github.com/containers/common/blob/main/docs/Containerfile.5.md)/[Dockerfile](https://docs.docker.com/engine/reference/builder/) |
| [`language_cpp`](plugins/language_cpp.lua?raw=1) | Syntax for the [C++](https://isocpp.org/) programming language |
diff --git a/plugins/language_caddyfile.lua b/plugins/language_caddyfile.lua
new file mode 100644
index 0000000..f918c16
--- /dev/null
+++ b/plugins/language_caddyfile.lua
@@ -0,0 +1,104 @@
+-- mod-version:3
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "Caddyfile" },
+ comment = "#",
+ patterns = {
+ { pattern = { "#", "\n"}, type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ -- Matcher definition
+ { pattern = "@[%w_]+", type = "operator" },
+ -- Snippet
+ { pattern = "%(%g+%)", type = "operator" },
+ -- Properties
+ { pattern = "^[%a_][%w_]*()%s+%f[%g]",
+ type = { "function", "normal" }
+ },
+ { pattern = "^[%a_][%w_]*()%s+$",
+ type = { "function", "normal" }
+ },
+ { pattern = "^%s*()[%a_][%w_]*()%s+$",
+ type = { "normal", "function", "normal" }
+ },
+ { pattern = "^%s*()[%a_][%w_]*()%s+%f[%g]",
+ type = { "normal", "function", "normal" }
+ },
+ -- Environment variables
+ { pattern = "{()%$[%w_]+():()[%w_]+()}",
+ type = { "operator", "keyword2", "operator", "keyword2", "operator" }
+ },
+ { pattern = "{()%$[%w_]+()}",
+ type = { "operator", "keyword2", "operator" }
+ },
+ -- Place holder
+ { pattern = "{%g-}", type = "keyword2" },
+ -- Operators
+ { pattern = "[+%-,:]", type = "operator" },
+ -- IP Address
+ { pattern = "%d+%.%d+%.%d+%.%d+", type = "literal" },
+ -- Path /path/subpath
+ { pattern = "/[%w%./]+", type = "literal" },
+ -- Wildcard domain *.levels
+ { pattern = "%*()[%w.]+",
+ type = { "operator", "literal" }
+ },
+ -- Match Operator
+ { pattern = "%*+", type = "operator" },
+ -- Domain leve1.level2
+ { pattern = "https?://[%w%./%*]+", type = "literal" },
+ -- Domain leve1.level2
+ { pattern = "%w+%.[%w%.]+", type = "literal" },
+ -- Number
+ { pattern = "%d+[mhskbi]*", type = "number" },
+ -- Everything else for symbols to work
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ ["true"] = "literal",
+ ["false"] = "literal",
+ ["localhost"] = "literal",
+
+ -- built-in directives
+ ["abort"] = "keyword",
+ ["acme_server"] = "keyword",
+ ["basicauth"] = "keyword",
+ ["bind"] = "keyword",
+ ["encode"] = "keyword",
+ ["error"] = "keyword",
+ ["file_server"] = "keyword",
+ ["forward_auth"] = "keyword",
+ ["handle"] = "keyword",
+ ["handle_errors"] = "keyword",
+ ["handle_path"] = "keyword",
+ ["header"] = "keyword",
+ ["import"] = "keyword",
+ ["log"] = "keyword",
+ ["method"] = "keyword",
+ ["map"] = "keyword",
+ ["metrics"] = "keyword",
+ ["php_fastcgi"] = "keyword",
+ ["push"] = "keyword",
+ ["redir"] = "keyword",
+ ["request_body"] = "keyword",
+ ["request_header"] = "keyword",
+ ["respond"] = "keyword",
+ ["reverse_proxy"] = "keyword",
+ ["rewrite"] = "keyword",
+ ["root"] = "keyword",
+ ["route"] = "keyword",
+ ["templates"] = "keyword",
+ ["tls"] = "keyword",
+ ["tracing"] = "keyword",
+ ["try_files"] = "keyword",
+ ["uri"] = "keyword",
+ ["vars"] = "keyword",
+
+ -- Module directives
+ ["cgi"] = "keyword",
+ ["ssh"] = "keyword",
+ ["exec"] = "keyword",
+ ["supervisor"] = "keyword",
+ ["layer4"] = "keyword",
+ },
+}