From e93bfb1afafda1e84aa014f3f3f2aac90a1224cf Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Tue, 14 Sep 2021 09:20:58 +0200 Subject: Attempt to improve tex syntax highlighting In theory we could have a sub-syntax for the math mode but this is difficult to achieve. --- plugins/language_tex.lua | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/language_tex.lua b/plugins/language_tex.lua index 1bc08f5..9878505 100644 --- a/plugins/language_tex.lua +++ b/plugins/language_tex.lua @@ -5,13 +5,22 @@ syntax.add { files = { "%.tex$" }, comment = "%%", patterns = { - { pattern = {"%%", "\n"}, type = "comment" }, - { pattern = "&", type = "operator" }, - { pattern = "\\\\", type = "operator" }, - { pattern = {"%$", "%$"}, type = "operator" }, - { pattern = {"\\%[", "\\]"}, type = "operator" }, - { pattern = {"{", "}"}, type = "keyword" }, - { pattern = "\\%w*", type = "keyword2" }, + { pattern = "%%.-\n", type = "comment" }, + { pattern = "\\documentclass().-{()%a%w+()}", type = {"keyword", "symbol", "function", "symbol"} }, + { pattern = "\\usepackage", type = "keyword" }, + { pattern = "\\chapter", type = "keyword" }, + { pattern = "\\section", type = "keyword" }, + { pattern = "\\subsection", type = "keyword" }, + { pattern = "\\paragraph", type = "keyword" }, + { pattern = "\\subparagraph", type = "keyword" }, + { pattern = "\\begin(){()%a%w+()}", type = {"keyword2", "symbol", "function", "symbol"} }, + { pattern = "\\end(){()%a%w+()}", type = {"keyword2", "symbol", "function", "symbol"} }, + { pattern = "\\%a%w+()%*", type = {"keyword2", "operator"} }, + { pattern = "\\%a%w+", type = "keyword2" }, + { pattern = "&", type = "operator" }, + { pattern = "\\\\", type = "operator" }, + { pattern = "%$", type = "operator" }, + { pattern = "\\[%[%]()]", type = "operator" }, }, symbols = {} } -- cgit v1.2.3