Add latex support in comment plugin (#1725)

This commit is contained in:
Ján Priner
2020-06-12 18:58:51 +02:00
committed by GitHub
parent 5ce26cca71
commit b2261fc225
2 changed files with 6 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ ft["ruby"] = "# %s"
ft["d"] = "// %s"
ft["swift"] = "// %s"
ft["elm"] = "-- %s"
ft["tex"] = "% %s"
function onBufferOpen(buf)
if buf.Settings["commenttype"] == nil then
@@ -38,7 +39,7 @@ end
function commentLine(bp, lineN)
local line = bp.Buf:Line(lineN)
local commentType = bp.Buf.Settings["commenttype"]
local commentRegex = "^%s*" .. commentType:gsub("%*", "%*"):gsub("%-", "%-"):gsub("%.", "%."):gsub("%+", "%+"):gsub("%]", "%]"):gsub("%[", "%["):gsub("%%s", "(.*)")
local commentRegex = "^%s*" .. commentType:gsub("%%","%%%%"):gsub("%$","%$"):gsub("%)","%)"):gsub("%(","%("):gsub("%?","%?"):gsub("%*", "%*"):gsub("%-", "%-"):gsub("%.", "%."):gsub("%+", "%+"):gsub("%]", "%]"):gsub("%[", "%["):gsub("%%%%s", "(.*)")
local sel = -bp.Cursor.CurSelection
local curpos = -bp.Cursor.Loc
local index = string.find(commentType, "%%s") - 1
@@ -98,7 +99,8 @@ function comment(bp, args)
end
function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
local trimmed = s:gsub("^%s*(.-)%s*$", "%1"):gsub("%%","%%%%")
return trimmed
end
function string.starts(String,Start)