Make conform respect config.vim.lsp.formatOnSave

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

View file

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