Skip to content

Allow customising format commandΒ #747

@TheColorman

Description

@TheColorman

⚠️ Please verify that this feature request has NOT been suggested before.

  • I checked and didn't find a similar feature request

🏷️ Feature Type

API Additions

πŸ”– Feature description

A lot of formatters come with options and configuration, but NVF does not support configuring any of them.

βœ”οΈ Solution

A simple vim.languages.<lang>.format.command would suffice, as it's standard practice for formatters to support configuration either through CLI arguments or by passing a configuration file.
This option would override vim.languages.<lang>.format.{package, type} as you would effectively need to specify a path in the nix store to the formatter.

Usage example:

{ pkgs, lib, ...}: {
  vim.languages.nix.format.command =
    "${lib.getExe pkgs.alejandra} --experimental-config ${./alejandra.toml}";
}

❓ Alternatives

A lot of formatters read configuration files automatically relative to their execution directory, but I'd like to set defaults for all files of a specific language.

πŸ“ Additional Context

#382 will completely change how language configuration works, so I'd like to take a shot at implementing this myself with a bit of guidance if given the go-ahead, to prevent needlessly increasing your workload.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions