2021-08-17 15:46:21 +02:00
|
|
|
-- mod-version:2 -- lite-xl 2.0
|
2019-12-28 12:16:32 +01:00
|
|
|
local syntax = require "core.syntax"
|
|
|
|
|
|
|
|
syntax.add {
|
2021-11-21 03:46:43 +01:00
|
|
|
name = "Python",
|
2020-12-19 11:19:08 +01:00
|
|
|
files = { "%.py$", "%.pyw$" },
|
2020-06-08 10:44:51 +02:00
|
|
|
headers = "^#!.*[ /]python",
|
2019-12-28 12:16:32 +01:00
|
|
|
comment = "#",
|
|
|
|
patterns = {
|
2021-10-23 15:01:16 +02:00
|
|
|
{ pattern = { "#", "\n" }, type = "comment" },
|
|
|
|
{ pattern = { '[ruU]?"""', '"""'; '\\' }, type = "string" },
|
|
|
|
{ pattern = { '[ruU]?"', '"', '\\' }, type = "string" },
|
|
|
|
{ pattern = { "[ruU]?'", "'", '\\' }, 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" },
|
2019-12-28 12:16:32 +01:00
|
|
|
},
|
|
|
|
symbols = {
|
|
|
|
["class"] = "keyword",
|
|
|
|
["finally"] = "keyword",
|
|
|
|
["is"] = "keyword",
|
|
|
|
["return"] = "keyword",
|
|
|
|
["continue"] = "keyword",
|
|
|
|
["for"] = "keyword",
|
|
|
|
["lambda"] = "keyword",
|
|
|
|
["try"] = "keyword",
|
|
|
|
["def"] = "keyword",
|
|
|
|
["from"] = "keyword",
|
|
|
|
["nonlocal"] = "keyword",
|
|
|
|
["while"] = "keyword",
|
|
|
|
["and"] = "keyword",
|
|
|
|
["global"] = "keyword",
|
|
|
|
["not"] = "keyword",
|
|
|
|
["with"] = "keyword",
|
|
|
|
["as"] = "keyword",
|
|
|
|
["elif"] = "keyword",
|
|
|
|
["if"] = "keyword",
|
|
|
|
["or"] = "keyword",
|
|
|
|
["else"] = "keyword",
|
|
|
|
["import"] = "keyword",
|
|
|
|
["pass"] = "keyword",
|
|
|
|
["break"] = "keyword",
|
|
|
|
["except"] = "keyword",
|
|
|
|
["in"] = "keyword",
|
|
|
|
["del"] = "keyword",
|
|
|
|
["raise"] = "keyword",
|
|
|
|
["yield"] = "keyword",
|
|
|
|
["assert"] = "keyword",
|
|
|
|
["self"] = "keyword2",
|
|
|
|
["None"] = "literal",
|
|
|
|
["True"] = "literal",
|
|
|
|
["False"] = "literal",
|
|
|
|
}
|
|
|
|
}
|