mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 19:12:38 +00:00 
			
		
		
		
	Make conform respect config.vim.lsp.formatOnSave and config.vim.lsp.mappings.toggleFormatOnSave
This commit is contained in:
		
					parent
					
						
							
								09f2e1d524
							
						
					
				
			
			
				commit
				
					
						22f5704527
					
				
			
		
					 1 changed files with 42 additions and 25 deletions
				
			
		|  | @ -1,12 +1,9 @@ | ||||||
| { | {lib, ...}: let | ||||||
|   pkgs, |   inherit (lib.generators) mkLuaInline; | ||||||
|   lib, |   inherit (lib.options) mkOption mkEnableOption literalMD; | ||||||
|   ... |   inherit (lib.types) attrs either nullOr; | ||||||
| }: let |   inherit (lib.nvim.lua) toLuaObject; | ||||||
|   inherit (lib.options) mkOption mkEnableOption literalExpression; |   inherit (lib.nvim.types) luaInline mkPluginSetupOption; | ||||||
|   inherit (lib.types) attrs enum nullOr; |  | ||||||
|   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,24 +28,44 @@ in { | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       format_on_save = mkOption { |       format_on_save = mkOption { | ||||||
|         type = nullOr attrs; |         type = nullOr (either attrs luaInline); | ||||||
|         default = { |         default = mkLuaInline '' | ||||||
|           lsp_format = "fallback"; |           function() | ||||||
|           timeout_ms = 500; |             if not vim.g.formatsave or vim.b.disableFormatSave then | ||||||
|         }; |               return | ||||||
|  |             else | ||||||
|  |               return {lsp_format = "fallback", timeout_ms = 500} | ||||||
|  |             end | ||||||
|  |           end | ||||||
|  |         ''; | ||||||
|  |         defaultText = literalMD '' | ||||||
|  |           enabled by default, and respects {option}`vim.lsp.formatOnSave` and | ||||||
|  |           {option}`vim.lsp.mappings.toggleFormatSave` | ||||||
|  |         ''; | ||||||
|         description = '' |         description = '' | ||||||
|           Table that will be passed to `conform.format()`. If this |           Attribute set or Lua function that will be passed to | ||||||
|           is set, Conform will run the formatter on save. |           `conform.format()`. If this is set, Conform will run the formatter | ||||||
|  |           on save. | ||||||
|         ''; |         ''; | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       format_after_save = mkOption { |       format_after_save = let | ||||||
|         type = nullOr attrs; |         defaultFormatAfterSaveOpts = {lsp_format = "fallback";}; | ||||||
|         default = {lsp_format = "fallback";}; |       in | ||||||
|  |         mkOption { | ||||||
|  |           type = nullOr (either attrs luaInline); | ||||||
|  |           default = mkLuaInline '' | ||||||
|  |             function() | ||||||
|  |               if not vim.g.formatsave or vim.b.disableFormatSave then | ||||||
|  |                 return | ||||||
|  |               else | ||||||
|  |                 return ${toLuaObject defaultFormatAfterSaveOpts} | ||||||
|  |               end | ||||||
|  |             end | ||||||
|  |           ''; | ||||||
|           description = '' |           description = '' | ||||||
|           Table that will be passed to `conform.format()`. If this |             Table or function(luainline) 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 save. | ||||||
|           save. |  | ||||||
|           ''; |           ''; | ||||||
|         }; |         }; | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Venkatesan Ravi
				Venkatesan Ravi