Any ideas on why Python files without an extension have auto-disabled vim-better-whitespace options?

Hi,

I’ve recently started to move to Neovim from Vim and it’s been an excellent experience. One thing that I can’t figure out is why custom options for GitHub - ntpeters/vim-better-whitespace: Better whitespace highlighting for Vim have been disabled, but only for Python files without a .py extension. In this case there’s a shebang at the top of the file to set Python as the interpreter.

I did not have this issue with Vim for reference.

I am using LazyVim. The plugin is installed and configured like this:

return {
  {
    "ntpeters/vim-better-whitespace",
    init = function()
      vim.g.strip_whitespace_confirm = false
      vim.g.strip_whitelines_at_eof = true
      vim.g.strip_whitespace_on_save = true
      vim.g.better_whitespace_filetypes_blacklist = {}
    end,
  },
}

When I open tons of different file types (csv, ruby, bash, sh, etc.), whitespace gets removed on save based on the above settings, even if it’s a shell script with no file extension.

When I load any Python file without an extention, these settings are not applied. I can still run the :StripWhitespace command successfully but of course I’d prefer to have it done on save. If the Python file has a .py extension then it works normally.

When I echo those settings in the Python file they are the correct value so nothing is overriding them in a way that would cause them to change.

I’m not using a Python LSP but I do have Treesitter set up for it with the stock LazyVim configuration. In both cases where Pyhon files have an extension or not, the filetype is python so there’s no discrepency there.

Any thoughts on where to go next to troubleshoot what’s causing this to happen? Thanks!

Since this post I was able to narrow down the scope of the problem. It’s not all Python files without a file extension, plutus/src/plutus at main · nickjj/plutus · GitHub used to prevent whitespace being removed on save through vim-better-whitespace.

The reason was because in that src/ directory I had an __init.py file instead of __init__.py. That was a fun one.