From a184872d89767616a9c6f1c789aa8dd837eb9a48 Mon Sep 17 00:00:00 2001 From: Venkatesan Ravi Date: Mon, 31 Mar 2025 01:25:52 +0000 Subject: [PATCH] Make conform respect config.vim.lsp.formatOnSave --- .../formatter/conform-nvim/conform-nvim.nix | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/modules/plugins/formatter/conform-nvim/conform-nvim.nix b/modules/plugins/formatter/conform-nvim/conform-nvim.nix index 423a4f44..28fd2efe 100644 --- a/modules/plugins/formatter/conform-nvim/conform-nvim.nix +++ b/modules/plugins/formatter/conform-nvim/conform-nvim.nix @@ -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