lite/data/plugins/language_js.lua

46 lines
1.5 KiB
Lua
Raw Normal View History

2019-12-28 12:16:32 +01:00
local syntax = require "core.syntax"
syntax.add {
files = { "%.js$", "%.json$", "%.cson$" },
comment = "//",
patterns = {
{ pattern = "//.-\n", type = "comment" },
{ pattern = { "/%*", "%*/" }, type = "comment" },
{ pattern = { '"', '"', '\\' }, type = "string" },
{ pattern = { "'", "'", '\\' }, type = "string" },
{ pattern = "0x[%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" },
},
symbols = {
["if"] = "keyword",
["then"] = "keyword",
["else"] = "keyword",
["do"] = "keyword",
["while"] = "keyword",
["for"] = "keyword",
["break"] = "keyword",
["continue"] = "keyword",
["return"] = "keyword",
["switch"] = "keyword",
["case"] = "keyword",
["const"] = "keyword",
["try"] = "keyword",
["catch"] = "keyword",
["throw"] = "keyword",
["var"] = "keyword",
["let"] = "keyword",
["get"] = "keyword",
["set"] = "keyword",
["function"] = "keyword",
["new"] = "keyword",
["this"] = "keyword2",
["true"] = "literal",
["false"] = "literal",
["null"] = "literal",
},
}