mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-08 01:53:20 +00:00
formatters/conform-nvim: expose configured formatters on top-level
Some checks are pending
Check for typos in the source tree / check-typos (push) Waiting to run
Some checks are pending
Check for typos in the source tree / check-typos (push) Waiting to run
This should allow language modules to define new formatters without accessing conform's setupOpts each time.
This commit is contained in:
parent
5e9c8760e0
commit
26567dffef
1 changed files with 38 additions and 8 deletions
|
@ -1,18 +1,48 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.types) attrs enum;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
inherit (lib.nvim.lua) mkLuaInline;
|
||||
inherit (lib.types) attrsOf anything list either;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
|
||||
cfg = config.vim.formatter.conform-nvim;
|
||||
in {
|
||||
options.vim.formatter.conform-nvim = {
|
||||
enable = mkEnableOption "lightweight yet powerful formatter plugin for Neovim [conform-nvim]";
|
||||
|
||||
# This is to declare all custom formatters nvf uses for language modules in a single
|
||||
# module option so that
|
||||
# 1. Modules can refer to each others' formatters
|
||||
# 2. If users already have some of the formatters in PATH, they can override the attrset.
|
||||
# Values set here will be passed directly to setupOpts.formatters.
|
||||
configuredFormatters = mkOption {
|
||||
type = attrsOf anything;
|
||||
default = {};
|
||||
example = literalExpression ''
|
||||
{
|
||||
yamlfix.command = "$${lib.getExe pkgs.yamlfix}";
|
||||
rustfmt.env = {
|
||||
RUST_SRC_PATH = "$${pkgs.rustPlatform.rustLibSrc}";
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = "Override options for formatters provided by conform.nvim";
|
||||
};
|
||||
|
||||
setupOpts = mkPluginSetupOption "conform.nvim" {
|
||||
formatters = mkOption {
|
||||
type = attrsOf anything;
|
||||
default = cfg.configuredFormatters;
|
||||
description = ''
|
||||
Attribute set containing overrides for conform's own formatters, or
|
||||
new formatters to be recognized by conform in, e.g., `formatters_by_ft`
|
||||
'';
|
||||
};
|
||||
|
||||
formatters_by_ft = mkOption {
|
||||
type = attrs;
|
||||
type = either (attrsOf list) luaInline;
|
||||
default = {};
|
||||
example = {lua = ["stylua"];};
|
||||
description = ''
|
||||
|
@ -25,13 +55,13 @@ in {
|
|||
};
|
||||
|
||||
default_format_opts = mkOption {
|
||||
type = attrs;
|
||||
type = attrsOf anything;
|
||||
default = {lsp_format = "fallback";};
|
||||
description = "Default values when calling `conform.format()`";
|
||||
};
|
||||
|
||||
format_on_save = mkOption {
|
||||
type = attrs;
|
||||
type = attrsOf anything;
|
||||
default = {
|
||||
lsp_format = "fallback";
|
||||
timeout_ms = 500;
|
||||
|
@ -43,7 +73,7 @@ in {
|
|||
};
|
||||
|
||||
format_after_save = mkOption {
|
||||
type = attrs;
|
||||
type = attrsOf anything;
|
||||
default = {lsp_format = "fallback";};
|
||||
description = ''
|
||||
Table that will be passed to `conform.format()`. If this
|
||||
|
|
Loading…
Add table
Reference in a new issue