Add flake8 linter, postinit and preinit

Closes #1768
This commit is contained in:
Zachary Yedidia
2020-07-13 13:28:26 -04:00
parent a45591a24d
commit 781a2dd826
4 changed files with 20 additions and 4 deletions

View File

@@ -299,6 +299,11 @@ func main() {
screen.TermMessage(err)
}
err = config.RunPluginFn("preinit")
if err != nil {
screen.TermMessage(err)
}
args := flag.Args()
b := LoadInput(args)
@@ -316,6 +321,11 @@ func main() {
screen.TermMessage(err)
}
err = config.RunPluginFn("postinit")
if err != nil {
screen.TermMessage(err)
}
if clipErr != nil {
action.InfoBar.Error(clipErr, " or change 'clipboard' option")
}

File diff suppressed because one or more lines are too long

View File

@@ -43,6 +43,12 @@ are called when certain events happen. Here is the list of callbacks
which micro defines:
* `init()`: this function should be used for your plugin initialization.
This function is called after buffers have been initialized.
* `preinit()`: initialization function called before buffers have been
initialized.
* `postinit()`: initialization function called after `init()`.
* `onBufferOpen(buf)`: runs when a buffer is opened. The input contains
the buffer object.

View File

@@ -59,7 +59,7 @@ function removeLinter(name)
linters[name] = nil
end
function init()
function preinit()
local devnull = "/dev/null"
if runtime.GOOS == "windows" then
devnull = "NUL"
@@ -81,6 +81,7 @@ function init()
makeLinter("pyflakes", "python", "pyflakes", {"%f"}, "%f:%l:.-:? %m")
makeLinter("mypy", "python", "mypy", {"%f"}, "%f:%l: %m")
makeLinter("pylint", "python", "pylint", {"--output-format=parseable", "--reports=no", "%f"}, "%f:%l: %m")
makeLinter("flake8", "python", "flake8", {"%f"}, "%f:%l:%c: %m")
makeLinter("shfmt", "shell", "shfmt", {"%f"}, "%f:%l:%c: %m")
makeLinter("swiftc", "swift", "xcrun", {"swiftc", "%f"}, "%f:%l:%c:.+: %m", {"darwin"}, true)
makeLinter("swiftc", "swift", "swiftc", {"%f"}, "%f:%l:%c:.+: %m", {"linux"}, true)
@@ -167,7 +168,6 @@ function onExit(output, args)
elseif col == nil then
hascol = false
end
micro.Log(basename(buf.Path), basename(file))
if basename(buf.Path) == basename(file) then
local bmsg = nil
if hascol then