mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 19:12:38 +00:00 
			
		
		
		
	language/ruby: migrate to conform/nvim-lint
This commit is contained in:
		
					parent
					
						
							
								7cf9e5c0a6
							
						
					
				
			
			
				commit
				
					
						2c153f57e6
					
				
			
		
					 1 changed files with 17 additions and 33 deletions
				
			
		|  | @ -6,10 +6,10 @@ | ||||||
| }: let | }: let | ||||||
|   inherit (builtins) attrNames; |   inherit (builtins) attrNames; | ||||||
|   inherit (lib.options) mkEnableOption mkOption; |   inherit (lib.options) mkEnableOption mkOption; | ||||||
|  |   inherit (lib.meta) getExe; | ||||||
|   inherit (lib.modules) mkIf mkMerge; |   inherit (lib.modules) mkIf mkMerge; | ||||||
|   inherit (lib.nvim.types) mkGrammarOption diagnostics; |   inherit (lib.nvim.types) mkGrammarOption diagnostics; | ||||||
|   inherit (lib.types) either listOf package str enum; |   inherit (lib.types) either listOf package str enum; | ||||||
|   inherit (lib.nvim.languages) diagnosticsToLua; |  | ||||||
| 
 | 
 | ||||||
|   cfg = config.vim.languages.ruby; |   cfg = config.vim.languages.ruby; | ||||||
| 
 | 
 | ||||||
|  | @ -35,24 +35,8 @@ | ||||||
|   defaultFormat = "rubocop"; |   defaultFormat = "rubocop"; | ||||||
|   formats = { |   formats = { | ||||||
|     rubocop = { |     rubocop = { | ||||||
|  |       # TODO: is this right? | ||||||
|       package = pkgs.rubyPackages.rubocop; |       package = pkgs.rubyPackages.rubocop; | ||||||
|       nullConfig = '' |  | ||||||
|         local conditional = function(fn) |  | ||||||
|           local utils = require("null-ls.utils").make_conditional_utils() |  | ||||||
|           return fn(utils) |  | ||||||
|         end |  | ||||||
| 
 |  | ||||||
|         table.insert( |  | ||||||
|           ls_sources, |  | ||||||
|           null_ls.builtins.formatting.rubocop.with({ |  | ||||||
|             command="${pkgs.bundler}/bin/bundle", |  | ||||||
|             args = vim.list_extend( |  | ||||||
|               {"exec", "rubocop", "-a" }, |  | ||||||
|               null_ls.builtins.formatting.rubocop._opts.args |  | ||||||
|             ), |  | ||||||
|           }) |  | ||||||
|         ) |  | ||||||
|       ''; |  | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  | @ -60,14 +44,7 @@ | ||||||
|   diagnosticsProviders = { |   diagnosticsProviders = { | ||||||
|     rubocop = { |     rubocop = { | ||||||
|       package = pkgs.rubyPackages.rubocop; |       package = pkgs.rubyPackages.rubocop; | ||||||
|       nullConfig = pkg: '' |       config.command = getExe cfg.format.package; | ||||||
|         table.insert( |  | ||||||
|           ls_sources, |  | ||||||
|           null_ls.builtins.diagnostics.rubocop.with({ |  | ||||||
|             command = "${lib.getExe pkg}", |  | ||||||
|           }) |  | ||||||
|         ) |  | ||||||
|       ''; |  | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| in { | in { | ||||||
|  | @ -136,16 +113,23 @@ in { | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     (mkIf cfg.format.enable { |     (mkIf cfg.format.enable { | ||||||
|       vim.lsp.null-ls.enable = true; |       vim.formatter.conform-nvim = { | ||||||
|       vim.lsp.null-ls.sources.ruby-format = formats.${cfg.format.type}.nullConfig; |         enable = true; | ||||||
|  |         setupOpts.formatters_by_ft.ruby = [cfg.format.type]; | ||||||
|  |         setupOpts.formatters.${cfg.format.type} = { | ||||||
|  |           command = getExe cfg.format.package; | ||||||
|  |         }; | ||||||
|  |       }; | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     (mkIf cfg.extraDiagnostics.enable { |     (mkIf cfg.extraDiagnostics.enable { | ||||||
|       vim.lsp.null-ls.enable = true; |       vim.diagnostics.nvim-lint = { | ||||||
|       vim.lsp.null-ls.sources = diagnosticsToLua { |         enable = true; | ||||||
|         lang = "ruby"; |         linters_by_ft.ruby = cfg.extraDiagnostics.types; | ||||||
|         config = cfg.extraDiagnostics.types; |         linters = mkMerge (map (name: { | ||||||
|         inherit diagnosticsProviders; |             ${name}.cmd = getExe diagnosticsProviders.${name}.package; | ||||||
|  |           }) | ||||||
|  |           cfg.extraDiagnostics.types); | ||||||
|       }; |       }; | ||||||
|     }) |     }) | ||||||
|   ]); |   ]); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ching Pei Yang
				Ching Pei Yang