mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 02:52:37 +00:00 
			
		
		
		
	nvim-lint: add lint after save autocmd
This commit is contained in:
		
					parent
					
						
							
								aed996eb33
							
						
					
				
			
			
				commit
				
					
						6e8b6bf635
					
				
			
		
					 2 changed files with 29 additions and 9 deletions
				
			
		|  | @ -3,18 +3,36 @@ | ||||||
|   lib, |   lib, | ||||||
|   ... |   ... | ||||||
| }: let | }: let | ||||||
|   inherit (lib.modules) mkIf; |   inherit (lib.modules) mkIf mkMerge; | ||||||
|  |   inherit (lib.generators) mkLuaInline; | ||||||
|   inherit (lib.nvim.dag) entryAnywhere; |   inherit (lib.nvim.dag) entryAnywhere; | ||||||
|   inherit (lib.nvim.lua) toLuaObject; |   inherit (lib.nvim.lua) toLuaObject; | ||||||
| 
 | 
 | ||||||
|   cfg = config.vim.diagnostics.nvim-lint; |   cfg = config.vim.diagnostics.nvim-lint; | ||||||
| in { | in { | ||||||
|   config = mkIf cfg.enable { |   config = mkMerge [ | ||||||
|  |     (mkIf cfg.enable { | ||||||
|       vim = { |       vim = { | ||||||
|         startPlugins = ["nvim-lint"]; |         startPlugins = ["nvim-lint"]; | ||||||
|         pluginRC.nvim-lint = entryAnywhere '' |         pluginRC.nvim-lint = entryAnywhere '' | ||||||
|           require("lint").linters_by_ft = ${toLuaObject cfg.linters_by_ft} |           require("lint").linters_by_ft = ${toLuaObject cfg.linters_by_ft} | ||||||
|         ''; |         ''; | ||||||
|       }; |       }; | ||||||
|  |     }) | ||||||
|  |     (mkIf cfg.lint_after_save { | ||||||
|  |       vim = { | ||||||
|  |         augroups = [{name = "nvf_nvim_lint";}]; | ||||||
|  |         autocmds = [ | ||||||
|  |           { | ||||||
|  |             event = ["BufWritePost"]; | ||||||
|  |             callback = mkLuaInline '' | ||||||
|  |               function() | ||||||
|  |                 require("lint").try_lint() | ||||||
|  |               end | ||||||
|  |             ''; | ||||||
|  |           } | ||||||
|  |         ]; | ||||||
|       }; |       }; | ||||||
|  |     }) | ||||||
|  |   ]; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -21,5 +21,7 @@ in { | ||||||
|         accept. |         accept. | ||||||
|       ''; |       ''; | ||||||
|     }; |     }; | ||||||
|  | 
 | ||||||
|  |     lint_after_save = mkEnableOption "autocmd to lint after each save" // {default = true;}; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ching Pei Yang
				Ching Pei Yang