3

In Vim 8.1, I can run :!pre-commit run --files % to lint and auto-format the current file. Is there some way I can turn that (or any way of calling pre-commit) into in-editor highlighting, like https://github.com/dense-analysis/ale does?

In the past I've run ale in vim with pip-installed mypy, black, and yamllint and brew- or apt-installed shellcheck, delaying shell pre-commit runs until after editing. The downsides to that are in addition to the delayed feedback, this only brings a subset of the hooks into my editor (end-of-file-fixer is missing for example) and I haven't configured all of the twice-installed hooks as language: system, leaving the possibility open for in-editor and out-of-editor runs to diverge on versions and arguments. I could of course switch hooks over to language: system but I'm hoping for a way to go with the flow of using .pre-commit-config.yaml as the single-source-of-truth for versions and arguments, while surfacing results in-editor.

cov
  • 146
  • 7
  • 1
    IIRC, there is a section in ALE's documentation for writing your own "linter" (and plenty of existing ones for inspiration). If you can somehow get `pre-commit` to output information in a usable format then it should be possible to write a ALE "linter". Hell, you might even be able to write a native `:help compiler`. – romainl Jan 14 '22 at 16:43

0 Answers0