nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
The Unlicense
2.39k stars 69 forks source link

fix(ktlint): bug where buffer is clobbered by ktlint formatter #132

Closed notkaj closed 3 months ago

notkaj commented 3 months ago

The ktlint formatter clobbers your current Neovim buffer with log errors and warnings. This is especially problematic when working with Kotlin Script files.

If you have something like this in your buffer:

#!/usr/bin/env kotlin

println("Hello World!")

and write the file, triggering the formatter, you'll end up with something like this:

04:27:56.342 [main] WARN com.pinterest.ktlint.cli.internal.KtlintCommandLine -- Can not parse input from <stdin> as Kotlin, due to error below:
    Not a valid Kotlin file (3:1 expecting a top level declaration)
Now, trying to read the input as Kotlin Script.
#!/usr/bin/env kotlin

println("Hello World!")

I just went through some old PR's, and it looks like a similar thing happened on the diagnostic side, and they came up with the same fix: https://github.com/nvimtools/none-ls.nvim/pull/75