nvf/modules/plugins/formatter/conform-nvim/conform-nvim.nix

62 lines
2 KiB
Nix
Raw Normal View History

2024-09-26 14:43:14 +00:00
{
pkgs,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression;
2024-09-26 14:58:01 +00:00
inherit (lib.types) attrs enum;
2024-09-26 14:43:14 +00:00
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.formatter.conform-nvim = {
enable = mkEnableOption "lightweight yet powerful formatter plugin for Neovim [conform-nvim]";
setupOpts = mkPluginSetupOption "conform.nvim" {
formatters_by_ft = mkOption {
type = attrs;
default = {};
example = literalExpression "lua = [\"${pkgs.stylua}/bin/stylua\"]";
description = ''
Map of filetype to formatters. This option takes a set of
`key = value` format where the `value will` be converted
to its Lua equivalent. You are responsible for passing the
correct Nix data types to generate a correct Lua value that
conform is able to accept.
'';
};
default_format_opts = mkOption {
type = attrs;
default = {lsp_format = "fallback";};
description = "Default values when calling `conform.format()`";
};
2024-09-26 14:58:01 +00:00
format_on_save = mkOption {
type = attrs;
default = {
lsp_format = "fallback";
timeout_ms = 500;
};
description = ''
Table that will be passed to `conform.format()`. If this
is set, Conform will run the formatter on save.
'';
};
format_after_save = mkOption {
type = attrs;
default = {lsp_format = "fallback";};
description = ''
Table that will be passed to `conform.format()`. If this
is set, Conform will run the formatter asynchronously after
save.
'';
};
log_level = mkOption {
type = enum ["vim.log.levels.ERROR" "vim.log.levels.WARN" "vim.log.levels.INFO" "vim.log.levels.DEBUG"];
default = "vim.log.levels.ERROR"; # TODO: make this luaInline
description = "Logging level for conform-nvim";
};
2024-09-26 14:43:14 +00:00
};
};
}