format_on_save = {} causes toggleFormatOnSave to stop working
I have confirmed that this is a bug related to nvf
- [x] This is a bug, and not an user error or a support request. I understand that my issue will be closed if it is not a bug in nvf.
- [x] I have checked the issues tab and confirmed that my issue has not yet been reported. I understand that my issue will be closed if it is a duplicate.
Description
Setting
vim.formatter.conform-nvim.setupOpts.format_on_save = {};
causes toggleFormatOnSave to stop working.
Installation Method
Standalone (flake outputs, nix profile install, etc.)
Installation Method (Other)
No response
nvf Version
v0.8 (ea3ee477fa1814352b30d114f31bf4895eed053e)
Reproduction steps
- Add
vim.formatter.conform-nvim.setupOpts.format_on_save = {};to a config with an enabled format on save functionality. - Make sure toggleFormatOnSave has a mapping:
vim.lsp.mappings.toggleFormatOnSave = "<leader>ltf"; - Open a file that requires formatting.
- Toggle format on save (off).
- Save the file,
:w
Expected behavior
The file to not be formatted.
Actual Behavior
The file is still being formatted, ignoring toggleFormatOnSave.
System Information
- system: `"x86_64-linux"`
- host os: `Linux 6.12.51, NixOS, 25.11 (Xantusia), 25.11.20251015.544961d`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Lix, like Nix) 2.93.3
System type: x86_64-linux
Additional system types: aarch64-linux, i686-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/ny/.config/nix/nix.conf:/nix/store/rmdbggbsmm4jd92rkbgfpsqf1pz8pk5b-kglobalacceld-6.4.5/etc/xdg/nix/nix.conf:/nix/store/rmdbggbsmm4jd92rkbgfpsqf1pz8pk5b-kglobalacceld-6.4.5/etc/xdg/nix/nix.conf:/home/ny/.config/kdedefaults/nix/nix.conf:/nix/store/xsh698rv45vmf8y8mf5wl9pwx53hgkdh-plasma-workspace-6.4.5/etc/xdg/nix/nix.conf:/nix/store/rmdbggbsmm4jd92rkbgfpsqf1pz8pk5b-kglobalacceld-6.4.5/etc/xdg/nix/nix.conf:/nix/store/q31rwxq31qix2cnr7aff0ha2j66pwnpx-baloo-6.18.0/etc/xdg/nix/nix.conf:/home/ny/.config/kdedefaults/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/ny/.local/share/flatpak/exports/etc/xdg/nix/nix.conf:/var/lib/flatpak/exports/etc/xdg/nix/nix.conf:/home/ny/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/ny/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/ny/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/zxl9ivn2v7xcrzlf4j036fl6av34zwv9-lix-2.93.3/share`
- channels(root): `"nixos-24.05"`
- nixpkgs: `/nix/store/rcsmdj802sk3w9l8m0b0bvdy0jiw2wgr-source`
Relevant log output
https://0x0.st/K14S.txt
setupOpts.format_on_save is enabled by default, and uses a custom function to check for the variables relating to toggleFormatOnSave, don't set anything if you want to keep the default
setupOpts.format_on_saveis enabled by default, and uses a custom function to check for the variables relating to toggleFormatOnSave, don't set anything if you want to keep the default
This is still an issue however when I try to set values one might want to set:
format_on_save = { timeout_ms = 500; lsp_format = "fallback"; };
Wouldn't it be possible to add the toggle checker function regardless of the user's supplied value? Or to inform the user that this combination of options renders the toggle unable to work properly?
Wouldn't it be possible to add the toggle checker function regardless of the user's supplied value?
I don't think there's a good way to do that, we could override vim.lsp.format to check for vim.b.formatsave but that's not good.
I think adding a note to the docs is the best we can do
That sounds like a good compromise