Skip to content
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

[BUG] conform.nvim with format_on_save = { } does not generate corresponding setup arg #2601

Open
1 task done
dwf opened this issue Dec 2, 2024 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@dwf
Copy link

dwf commented Dec 2, 2024

Field Description
Plugin conform-nvim
Nixpkgs 24.11
  • I have read the FAQ and my bug is not listed there.

Description

After upgrading to nixpkgs and nixvim 24.11, I noticed conform was no longer formatting on save. The Conform augroup was completely missing. Looking at the generated init.lua, the format_on_save argument was indeed missing despite being not null in my config.

I suspect this is a "truthiness" check gone wrong, but there's a lot of indirection in the derivation and I wasn't able to figure it out. The workaround I've used is format_on_save = { quiet = false; } which restates the default, but actually successfully generates.

Minimal, Reproducible Example (MRE)

config.plugins.conform-nvim = {
  enable = true;
  settings = {
    formatters_by_ft = {
      nix = [ "nixfmt" ];
    };
    format_on_save = {};  # Should generate this argument to setup() verbatim
  };
};
@dwf dwf added the bug Something isn't working label Dec 2, 2024
@MattSturgeon
Copy link
Member

The issue here is that our lua generation function filters out not just null, but also empty attrs.

This is a horrible behaviour, I know, but it is intended as otherwise many many un-defined options (or their parent attrs) end up in the generated lua.

As a workaround we provide the "empty attr" object, which looks like { __empty = null; } and can also be used via lib.nixvim.emptyTable.

In some cases you can also use "raw lua" to achieve the same thing: .__raw = "{ }";

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

2 participants