2022-03-24 16:57:26 +01:00
|
|
|
-- mod-version:3 -- lite-xl 2.1
|
2019-12-28 12:16:32 +01:00
|
|
|
local syntax = require "core.syntax"
|
|
|
|
|
|
|
|
syntax.add {
|
2021-11-21 03:46:43 +01:00
|
|
|
name = "JavaScript",
|
2019-12-28 12:16:32 +01:00
|
|
|
files = { "%.js$", "%.json$", "%.cson$" },
|
|
|
|
comment = "//",
|
2021-12-26 08:05:27 +01:00
|
|
|
block_comment = { "/*", "*/" },
|
2019-12-28 12:16:32 +01:00
|
|
|
patterns = {
|
|
|
|
{ pattern = "//.-\n", type = "comment" },
|
|
|
|
{ pattern = { "/%*", "%*/" }, type = "comment" },
|
2021-09-06 09:31:17 +02:00
|
|
|
{ pattern = { '/[^= ]', '/', '\\' },type = "string" },
|
2019-12-28 12:16:32 +01:00
|
|
|
{ pattern = { '"', '"', '\\' }, type = "string" },
|
|
|
|
{ pattern = { "'", "'", '\\' }, type = "string" },
|
2020-06-05 23:37:51 +02:00
|
|
|
{ pattern = { "`", "`", '\\' }, type = "string" },
|
2021-11-22 21:15:19 +01:00
|
|
|
{ pattern = "0x[%da-fA-F_]+n?", type = "number" },
|
2021-11-15 18:20:34 +01:00
|
|
|
{ pattern = "-?%d+[%d%.eE_n]*", type = "number" },
|
2019-12-28 12:16:32 +01:00
|
|
|
{ pattern = "-?%.?%d+", type = "number" },
|
|
|
|
{ pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
|
|
|
|
{ pattern = "[%a_][%w_]*%f[(]", type = "function" },
|
|
|
|
{ pattern = "[%a_][%w_]*", type = "symbol" },
|
|
|
|
},
|
|
|
|
symbols = {
|
2020-05-10 10:51:45 +02:00
|
|
|
["async"] = "keyword",
|
|
|
|
["await"] = "keyword",
|
|
|
|
["break"] = "keyword",
|
|
|
|
["case"] = "keyword",
|
|
|
|
["catch"] = "keyword",
|
|
|
|
["class"] = "keyword",
|
|
|
|
["const"] = "keyword",
|
|
|
|
["continue"] = "keyword",
|
|
|
|
["debugger"] = "keyword",
|
|
|
|
["default"] = "keyword",
|
|
|
|
["delete"] = "keyword",
|
|
|
|
["do"] = "keyword",
|
|
|
|
["else"] = "keyword",
|
|
|
|
["export"] = "keyword",
|
|
|
|
["extends"] = "keyword",
|
|
|
|
["finally"] = "keyword",
|
|
|
|
["for"] = "keyword",
|
|
|
|
["function"] = "keyword",
|
2020-05-10 10:56:28 +02:00
|
|
|
["get"] = "keyword",
|
2020-05-10 10:51:45 +02:00
|
|
|
["if"] = "keyword",
|
|
|
|
["import"] = "keyword",
|
|
|
|
["in"] = "keyword",
|
2021-05-17 08:56:21 +02:00
|
|
|
["of"] = "keyword",
|
2020-05-10 10:51:45 +02:00
|
|
|
["instanceof"] = "keyword",
|
|
|
|
["let"] = "keyword",
|
|
|
|
["new"] = "keyword",
|
|
|
|
["return"] = "keyword",
|
2020-05-10 10:56:28 +02:00
|
|
|
["set"] = "keyword",
|
2020-06-05 23:37:51 +02:00
|
|
|
["static"] = "keyword",
|
2020-05-10 10:51:45 +02:00
|
|
|
["super"] = "keyword",
|
|
|
|
["switch"] = "keyword",
|
|
|
|
["throw"] = "keyword",
|
|
|
|
["try"] = "keyword",
|
|
|
|
["typeof"] = "keyword",
|
|
|
|
["var"] = "keyword",
|
|
|
|
["void"] = "keyword",
|
|
|
|
["while"] = "keyword",
|
|
|
|
["with"] = "keyword",
|
|
|
|
["yield"] = "keyword",
|
2020-06-05 23:37:51 +02:00
|
|
|
["true"] = "literal",
|
|
|
|
["false"] = "literal",
|
|
|
|
["null"] = "literal",
|
|
|
|
["undefined"] = "literal",
|
|
|
|
["arguments"] = "keyword2",
|
|
|
|
["Infinity"] = "keyword2",
|
|
|
|
["NaN"] = "keyword2",
|
|
|
|
["this"] = "keyword2",
|
2019-12-28 12:16:32 +01:00
|
|
|
},
|
|
|
|
}
|