Skip to content

Commit

Permalink
added ts language
Browse files Browse the repository at this point in the history
  • Loading branch information
RednibCoding committed Apr 4, 2024
1 parent 8d97e80 commit 1e62892
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions data/plugins/language_ts.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
local syntax = require "core.syntax"

syntax.add {
files = { "%.ts$", "%.tsx$" },
comment = "//",
patterns = {
{ pattern = "//.-\n", type = "comment" },
{ pattern = { "/%*", "%*/" }, type = "comment" },
{ pattern = { '"', '"', '\\' }, type = "string" },
{ 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" },
{ pattern = ":[%s]*[%a_][%w_]*", type = "keyword2" }, -- Type annotations
{ pattern = "<[%a_][%w_]*>", type = "keyword2" }, -- Generic types
},
symbols = {
-- Existing JavaScript keywords
["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",
["get"] = "keyword",
["if"] = "keyword",
["import"] = "keyword",
["in"] = "keyword",
["instanceof"] = "keyword",
["let"] = "keyword",
["new"] = "keyword",
["return"] = "keyword",
["set"] = "keyword",
["static"] = "keyword",
["super"] = "keyword",
["switch"] = "keyword",
["throw"] = "keyword",
["try"] = "keyword",
["typeof"] = "keyword",
["var"] = "keyword",
["void"] = "keyword",
["while"] = "keyword",
["with"] = "keyword",
["yield"] = "keyword",
["true"] = "literal",
["false"] = "literal",
["null"] = "literal",
["undefined"] = "literal",
["arguments"] = "keyword2",
["Infinity"] = "keyword2",
["NaN"] = "keyword2",
["this"] = "keyword2",

-- TypeScript-specific keywords
["type"] = "keyword",
["interface"] = "keyword",
["enum"] = "keyword",
["implements"] = "keyword",
["public"] = "keyword",
["private"] = "keyword",
["protected"] = "keyword",
["readonly"] = "keyword",
["abstract"] = "keyword",
["any"] = "keyword2",
["boolean"] = "keyword2",
["number"] = "keyword2",
["string"] = "keyword2",
["symbol"] = "keyword2",
["void"] = "keyword2",
["unknown"] = "keyword2",
["never"] = "keyword2",
["object"] = "keyword2",
},
}

0 comments on commit 1e62892

Please sign in to comment.