Make conform respect config.vim.lsp.formatOnSave

This commit is contained in:
Venkatesan Ravi 2025-03-31 01:25:52 +00:00
parent 701dd911eb
commit a184872d89

View file

@ -1,12 +1,11 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrs enum;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) attrs nullOr;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.lua) mkLuaInline;
in {
options.vim.formatter.conform-nvim = {
enable = mkEnableOption "lightweight yet powerful formatter plugin for Neovim [conform-nvim]";
@ -31,11 +30,14 @@ in {
};
format_on_save = mkOption {
type = attrs;
default = {
lsp_format = "fallback";
timeout_ms = 500;
};
type = nullOr attrs;
default =
if config.vim.lsp.formatOnSave
then {
lsp_format = "fallback";
timeout_ms = 500;
}
else null;
description = ''
Table that will be passed to `conform.format()`. If this
is set, Conform will run the formatter on save.
@ -43,8 +45,11 @@ in {
};
format_after_save = mkOption {
type = attrs;
default = {lsp_format = "fallback";};
type = nullOr attrs;
default =
if config.vim.lsp.formatOnSave
then {lsp_format = "fallback";}
else null;
description = ''
Table that will be passed to `conform.format()`. If this
is set, Conform will run the formatter asynchronously after