ft["nginx"] = "# %s"
ft["nim"] = "# %s"
ft["objc"] = "// %s"
+ft["ocaml"] = "(* %s *)"
ft["pascal"] = "{ %s }"
ft["perl"] = "# %s"
ft["php"] = "// %s"
ft["zscript"] = "// %s"
ft["zsh"] = "# %s"
-function onBufferOpen(buf)
- if buf.Settings["commenttype"] == nil then
- if ft[buf.Settings["filetype"]] ~= nil then
- buf.Settings["commenttype"] = ft[buf.Settings["filetype"]]
- else
- buf.Settings["commenttype"] = "# %s"
- end
+function updateCommentType(buf)
+ if ft[buf.Settings["filetype"]] ~= nil and ft[buf.Settings["filetype"]] ~= nil then
+ buf.Settings["commenttype"] = ft[buf.Settings["filetype"]]
+ elseif buf.Settings["commenttype"] == nil then
+ buf.Settings["commenttype"] = "# %s"
end
end
end
function commentLine(bp, lineN)
+ updateCommentType(bp.Buf)
+
local line = bp.Buf:Line(lineN)
local commentType = bp.Buf.Settings["commenttype"]
local sel = -bp.Cursor.CurSelection
end
function uncommentLine(bp, lineN, commentRegex)
+ updateCommentType(bp.Buf)
+
local line = bp.Buf:Line(lineN)
local commentType = bp.Buf.Settings["commenttype"]
local sel = -bp.Cursor.CurSelection
end
function comment(bp, args)
+ updateCommentType(bp.Buf)
+
local commentType = bp.Buf.Settings["commenttype"]
local commentRegex = "^%s*" .. commentType:gsub("%%","%%%%"):gsub("%$","%$"):gsub("%)","%)"):gsub("%(","%("):gsub("%?","%?"):gsub("%*", "%*"):gsub("%-", "%-"):gsub("%.", "%."):gsub("%+", "%+"):gsub("%]", "%]"):gsub("%[", "%["):gsub("%%%%s", "(.*)"):gsub("%s+", "%s*")