aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip L <p410n3@gmail.com>2020-04-18 23:43:25 +0200
committerGitHub <noreply@github.com>2020-04-18 23:43:25 +0200
commit74b8f107cd0eeec99ab4c7782434c79550962957 (patch)
tree8bbad336a4bc1bd89c27d73c4be80bbcb8ebd62b
parentdc4c196706b2eb92d16a69a935b12fae88613c06 (diff)
downloadlite-xl-plugins-74b8f107cd0eeec99ab4c7782434c79550962957.tar.gz
lite-xl-plugins-74b8f107cd0eeec99ab4c7782434c79550962957.zip
Syntax highlighting for PHP
I hope I did not miss anything obvious, but works decent for the files I just tested. I highlight $ as a operator because I like having only the $ in front of my variables highlighted
-rw-r--r--language_php.lua97
1 files changed, 97 insertions, 0 deletions
diff --git a/language_php.lua b/language_php.lua
new file mode 100644
index 0000000..55597d6
--- /dev/null
+++ b/language_php.lua
@@ -0,0 +1,97 @@
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.php$", "%.phtml" },
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ -- I dont know why the '//' are needed but I leave it here for now
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = "%\\x[%da-fA-F]+", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "[%.%+%-=/%*%^%%<>!~|&]", type = "operator" },
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ -- To indicate variables.
+ { pattern = "%$", type = "operator" },
+ },
+ symbols = {
+ ["return"] = "keyword",
+ ["if"] = "keyword",
+ ["else"] = "keyword",
+ ["elseif"] = "keyword",
+ ["endif"] = "keyword",
+ ["declare"] = "keyword",
+ ["enddeclare"] = "keyword",
+ ["switch"] = "keyword",
+ ["endswitch"] = "keyword",
+ ["as"] = "keyword",
+ ["do"] = "keyword",
+ ["for"] = "keyword",
+ ["endfor"] = "keyword",
+ ["foreach"] = "keyword",
+ ["endforeach"] = "keyword",
+ ["while"] = "keyword",
+ ["endwhile"] = "keyword",
+ ["switch"] = "keyword",
+ ["case"] = "keyword",
+ ["continue"] = "keyword",
+ ["default"] = "keyword",
+ ["break"] = "keyword",
+ ["exit"] = "keyword",
+ ["goto"] = "keyword",
+
+ ["catch"] = "keyword",
+ ["throw"] = "keyword",
+ ["try"] = "keyword",
+ ["finally"] = "keyword",
+
+ ["class"] = "keyword",
+ ["trait"] = "keyword",
+ ["interface"] = "keyword",
+ ["public"] = "keyword",
+ ["static"] = "keyword",
+ ["protected"] = "keyword",
+ ["private"] = "keyword",
+ ["abstract"] = "keyword",
+ ["final"] = "keyword",
+
+ ["function"] = "keyword2",
+ ["global"] = "keyword2",
+ ["var"] = "keyword2",
+ ["const"] = "keyword2",
+ ["bool"] = "keyword2",
+ ["boolean"] = "keyword2",
+ ["int"] = "keyword2",
+ ["integer"] = "keyword2",
+ ["real"] = "keyword2",
+ ["double"] = "keyword2",
+ ["float"] = "keyword2",
+ ["string"] = "keyword2",
+ ["array"] = "keyword2",
+ ["object"] = "keyword2",
+ ["callable"] = "keyword2",
+ ["iterable"] = "keyword2",
+
+ ["namespace"] = "keyword2",
+ ["extends"] = "keyword2",
+ ["implements"] = "keyword2",
+ ["instanceof"] = "keyword2",
+ ["require"] = "keyword2",
+ ["require_once"] = "keyword2",
+ ["include"] = "keyword2",
+ ["include_once"] = "keyword2",
+ ["use"] = "keyword2",
+ ["new"] = "keyword2",
+ ["clone"] = "keyword2",
+
+ ["true"] = "literal",
+ ["false"] = "literal",
+ ["NULL"] = "literal",
+ ["parent"] = "literal",
+ ["self"] = "literal",
+ },
+}