mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 19:12:38 +00:00 
			
		
		
		
	nvim-lint: added required files support
This commit is contained in:
		
					parent
					
						
							
								ed31499ad6
							
						
					
				
			
			
				commit
				
					
						a436aca603
					
				
			
		
					 6 changed files with 71 additions and 68 deletions
				
			
		|  | @ -38,8 +38,29 @@ in { | |||
|           { | ||||
|             event = ["BufWritePost"]; | ||||
|             callback = mkLuaInline '' | ||||
|               function() | ||||
|                 require("lint").try_lint() | ||||
|               function(args) | ||||
|                 local ft = vim.api.nvim_get_option_value("filetype", { buf = args.buf }) | ||||
|                 local linters = require("lint").linters | ||||
|                 local linters_from_ft = require("lint").linters_by_ft[ft] | ||||
| 
 | ||||
|                 -- if no linter is configured for this filetype, stops linting | ||||
|                 if linters_from_ft == nil then return end | ||||
| 
 | ||||
|                 for _, name in ipairs(linters_from_ft) do | ||||
|                   local cwd = linters[name].required_files | ||||
| 
 | ||||
|                   -- if no configuration files are configured, lint | ||||
|                   if cwd == nil then | ||||
|                     require("lint").try_lint(name) | ||||
|                   else | ||||
|                     -- if configuration files are configured and present in the project, lint | ||||
|                     for _, fn in ipairs(cwd) do | ||||
|                       if vim.uv.fs_stat(fn) then | ||||
|                         require("lint").try_lint(name) | ||||
|                       end | ||||
|                     end | ||||
|                   end | ||||
|                 end | ||||
|               end | ||||
|             ''; | ||||
|           } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 rice-cracker-dev
				rice-cracker-dev