Skip to content

Toggle Format on Save does nothing after enabling conform #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
volfyd opened this issue Mar 27, 2025 · 3 comments
Open
1 task done

Toggle Format on Save does nothing after enabling conform #751

volfyd opened this issue Mar 27, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@volfyd
Copy link

volfyd commented Mar 27, 2025

⚠️ Please verify that this bug has NOT been reported before.

  • I checked all existing issues and didn't find a similar issue

Description

When using conform, the buffer local variable for disabling formatting is not checked.

I added this to my config to handle the issue:

        format_after_save =
          lib.generators.mkLuaInline
          # lua
          ''
            function(bufnr)
              if vim.b[bufnr].disableFormatSave then
                return
              end
              return { lsp_format = "fallback" }
            end
          '';
        format_on_save =
          lib.generators.mkLuaInline
          # lua
          ''
            function(bufnr)
              if vim.b[bufnr].disableFormatSave then
                return
              end
              return { timeout_ms = 500, lsp_format = "fallback" }
            end
          '';

👟 Reproduction steps

    formatter.conform-nvim = {
      enable = true;
      setupOpts = {
        formatters = {
          alejandra = {
            command = "${pkgs.alejandra}/bin/alejandra";
          };
        };
        formatters_by_ft = {
          nix = ["alejandra"];
        };
      };
    };

👀 Expected behavior

ltf should toggle formatting on save.

😓 Actual Behavior

formatting happens.

💻 Metadata

❯ nix-shell -p nix-info --run "nix-info -m" - system: "aarch64-linux" - host os: Linux 6.1.128-rt49, NixOS, 24.11 (Vicuna), 24.11.20250313.cdd2ef0 - multi-user?: yes - sandbox: yes - version: nix-env (Nix) 2.24.12 - nixpkgs: /nix/store/vawkv67jxh8kl4flrqgpcsmn9inqgvjv-source

📝 Relevant log output

none
@volfyd volfyd added the bug Something isn't working label Mar 27, 2025
@NotAShelf
Copy link
Owner

formatOnSafe does not yet integrate with conform. Though an integration might be added as a followup to #749. Until then I might add a warning to the documentation.

@NotAShelf NotAShelf self-assigned this Mar 27, 2025
@alfarelcynthesis
Copy link
Contributor

alfarelcynthesis commented Mar 28, 2025

Conform does have it's own option for formatting on/after save (in general, doesn't seem toggleable per buffer?), but it is broken in the current nvf module. I'll pr the fix, it's just allowing null. pr.

If you sometimes want it off, you may be able to get by by disabling it by default and formatting using a keybind?

@NotAShelf
Copy link
Owner

Could you see if #753 resolves this issue? It has been merged in main, and this issue can be closed if the problem is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants