12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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",
- },
- }
|