mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
1.77k stars 191 forks source link

Feature request: shadow file / temporary file as when `stdin = false` #235

Open FelipeLema opened 1 year ago

FelipeLema commented 1 year ago

Hi, there

Great plugin you got going. I like it that it's easy to configure and/or extend since it's written in lua.

One thing I'm missing is being able to use a temporary file when stdin = false (namely, with mypy). This way I don't need to save my file to get lint the current buffer.

I think I can implement this if maintainers are open to dealing with opening pandora's box this rather complicated feature. My belief is that, while it may lead to lots of corner cases, these can and will be covered through usage within few months (ie: this is a feature that'll take some time to stabilize)

see https://github.com/neomake/neomake/commit/4bb03bf7343357f241b763018a078ed6f3d163e1

mfussenegger commented 1 year ago

I think this wouldn't be too hard and I could imagine that something like this would then also make it possible to run linters on portions of a file identified by tree-sitter injections/language-trees (e.g. you could lint a python block in a markdown document with the python linters)

I'm overall open to this, but seeing some upvotes to gauge interest would help

petobens commented 9 months ago

Is this the reason why if, as in the GIF, I run ruff,mypy and pylint for python files then I need to save the file for both pylint and mypy to run whereas ruff runs automatically? If that's the case then it is indeed something needed/useful since, for instance, the quickfix get initially popluated by ruff, then when I save the file it add the pylint/mypy stuff but when I delete the unused variable there is lag and it still show mypy/pylint warnings (even though the variable is not there)

nvinlintagain

dante0624 commented 4 months ago

If anyone is looking to do this, conform is a similar plugin which managed to implement this feature. Their README says


-- Send file contents to stdin, read new contents from stdout (default true)
-- When false, will create a temp file (will appear in "$FILENAME" args). The temp
-- file is assumed to be modified in-place by the format command.```