nvim-lua / kickstart.nvim

A launch point for your personal nvim configuration
MIT License
16.69k stars 16.61k forks source link

On save trailing whitespace is removed #976

Closed JohnVillalovos closed 3 weeks ago

JohnVillalovos commented 3 weeks ago

When I save a file (in this case a PHP file) the trailing whitespace is being removed. Which I'm a fan of, but I am working on a preexisting code base and this is generating a lot of unrelated changes when submitting PRs.

I'm not sure which plugin or setting is causing this but I would like to be able to turn it off.

Thanks!

dam9000 commented 3 weeks ago

Did you enable php LSP? In that case it's probably the conform plugin auto-format-on-save. You can try adding php on the disable list by making this change:

diff --git a/init.lua b/init.lua
index 88658ef..f7cb136 100644
--- a/init.lua
+++ b/init.lua
@@ -644,7 +644,7 @@ require('lazy').setup({
         -- Disable "format_on_save lsp_fallback" for languages that don't
         -- have a well standardized coding style. You can add additional
         -- languages here or re-enable it for the disabled ones.
-        local disable_filetypes = { c = true, cpp = true }
+        local disable_filetypes = { c = true, cpp = true, php = true }
         return {
           timeout_ms = 500,
           lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
JohnVillalovos commented 3 weeks ago

@dam9000 Thanks. I should have mentioned that I had already completely commented out the conform section as that really messed things up for doing PRs.

So something else is removing the trailing whitespace.

ro0gr commented 3 weeks ago

Sounds like it might be caused by the editorconfig integration https://neovim.io/doc/user/editorconfig.html. you might want to disable the trim_trailing_whitespace option

JohnVillalovos commented 3 weeks ago

Sounds like it might be caused by the editorconfig integration https://neovim.io/doc/user/editorconfig.html. you might want to disable the trim_trailing_whitespace option

Woo hoo! That was it! Thanks!

So the project I was doing a PR for has a .editorconfig in the repo that has trim_trailing_whitespace set. But they don't seem to have trimmed the whitespace yet on a lot of the files ☹️

When I uncommented the line in .editorconfig it stopped removing the trailing whitespace.

I'll go ahead and close this.