mirror of
https://github.com/zyedidia/micro
synced 2024-11-05 17:41:24 +00:00
Merge
This commit is contained in:
commit
d326a9cddd
4 changed files with 20 additions and 5 deletions
|
@ -129,6 +129,7 @@ func luaImportMicroUtil() *lua.LTable {
|
|||
ulua.L.SetField(pkg, "RuneAt", luar.New(ulua.L, util.LuaRuneAt))
|
||||
ulua.L.SetField(pkg, "GetLeadingWhitespace", luar.New(ulua.L, util.LuaGetLeadingWhitespace))
|
||||
ulua.L.SetField(pkg, "IsWordChar", luar.New(ulua.L, util.LuaIsWordChar))
|
||||
ulua.L.SetField(pkg, "String", luar.New(ulua.L, util.String))
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -417,3 +417,7 @@ func IsNonAlphaNumeric(c rune) bool {
|
|||
func ParseSpecial(s string) string {
|
||||
return strings.Replace(s, "\\t", "\t", -1)
|
||||
}
|
||||
|
||||
func String(s []byte) string {
|
||||
return string(s)
|
||||
}
|
||||
|
|
|
@ -32,7 +32,10 @@ local linters = {}
|
|||
-- coffset: column offset will be added to the col number returned by the linter
|
||||
-- useful if the linter returns 0-indexed columns
|
||||
-- optional param, default: 0
|
||||
function makeLinter(name, filetype, cmd, args, errorformat, os, whitelist, domatch, loffset, coffset)
|
||||
-- callback: function to call before executing the linter, if it returns
|
||||
-- false the lint is canceled. The callback is passed the buf.
|
||||
-- optional param, default: nil
|
||||
function makeLinter(name, filetype, cmd, args, errorformat, os, whitelist, domatch, loffset, coffset, callback)
|
||||
if linters[name] == nil then
|
||||
linters[name] = {}
|
||||
linters[name].filetype = filetype
|
||||
|
@ -44,6 +47,7 @@ function makeLinter(name, filetype, cmd, args, errorformat, os, whitelist, domat
|
|||
linters[name].domatch = domatch or false
|
||||
linters[name].loffset = loffset or 0
|
||||
linters[name].coffset = coffset or 0
|
||||
linters[name].callback = callback or nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -118,7 +122,7 @@ function runLinter(buf)
|
|||
end
|
||||
|
||||
if ftmatch then
|
||||
lint(buf, k, v.cmd, args, v.errorformat, v.loffset, v.coffset)
|
||||
lint(buf, k, v.cmd, args, v.errorformat, v.loffset, v.coffset, v.callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -128,9 +132,15 @@ function onSave(bp)
|
|||
return true
|
||||
end
|
||||
|
||||
function lint(buf, linter, cmd, args, errorformat, loff, coff)
|
||||
function lint(buf, linter, cmd, args, errorformat, loff, coff, callback)
|
||||
buf:ClearMessages(linter)
|
||||
|
||||
if callback ~= nil then
|
||||
if not callback(buf) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
shell.JobSpawn(cmd, args, "", "", "linter.onExit", buf, linter, errorformat, loff, coff)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue