mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 11:02:37 +00:00 
			
		
		
		
	languages/css: add formatter support via prettier/prettierd
This commit is contained in:
		
					parent
					
						
							
								57446f7afb
							
						
					
				
			
			
				commit
				
					
						9cb7239085
					
				
			
		
					 2 changed files with 50 additions and 2 deletions
				
			
		|  | @ -32,6 +32,33 @@ | |||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   defaultFormat = "prettier"; | ||||
|   formats = { | ||||
|     prettier = { | ||||
|       package = pkgs.nodePackages.prettier; | ||||
|       nullConfig = '' | ||||
|         table.insert( | ||||
|           ls_sources, | ||||
|           null_ls.builtins.formatting.prettier.with({ | ||||
|             command = "${cfg.format.package}/bin/prettier", | ||||
|           }) | ||||
|         ) | ||||
|       ''; | ||||
|     }; | ||||
| 
 | ||||
|     prettierd = { | ||||
|       package = pkgs.prettierd; | ||||
|       nullConfig = '' | ||||
|         table.insert( | ||||
|           ls_sources, | ||||
|           null_ls.builtins.formatting.prettier.with({ | ||||
|             command = "${cfg.format.package}/bin/prettierd", | ||||
|           }) | ||||
|         ) | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| in { | ||||
|   options.vim.languages.css = { | ||||
|     enable = mkEnableOption "CSS language support"; | ||||
|  | @ -58,6 +85,22 @@ in { | |||
|         default = servers.${cfg.lsp.server}.package; | ||||
|       }; | ||||
|     }; | ||||
| 
 | ||||
|     format = { | ||||
|       enable = mkEnableOption "CSS formatting" // {default = config.vim.languages.enableFormat;}; | ||||
| 
 | ||||
|       type = mkOption { | ||||
|         description = "CSS formatter to use"; | ||||
|         type = with types; enum (attrNames formats); | ||||
|         default = defaultFormat; | ||||
|       }; | ||||
| 
 | ||||
|       package = mkOption { | ||||
|         description = "CSS formatter package"; | ||||
|         type = types.package; | ||||
|         default = formats.${cfg.format.type}.package; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   config = mkIf cfg.enable (mkMerge [ | ||||
|  | @ -68,7 +111,12 @@ in { | |||
| 
 | ||||
|     (mkIf cfg.lsp.enable { | ||||
|       vim.lsp.lspconfig.enable = true; | ||||
|       vim.lsp.lspconfig.sources.tailwindcss-lsp = servers.${cfg.lsp.server}.lspConfig; | ||||
|       vim.lsp.lspconfig.sources.css-lsp = servers.${cfg.lsp.server}.lspConfig; | ||||
|     }) | ||||
| 
 | ||||
|     (mkIf cfg.format.enable { | ||||
|       vim.lsp.null-ls.enable = true; | ||||
|       vim.lsp.null-ls.sources.css-format = formats.${cfg.format.type}.nullConfig; | ||||
|     }) | ||||
|   ]); | ||||
| } | ||||
|  |  | |||
|  | @ -51,7 +51,7 @@ in { | |||
|   config = mkIf cfg.enable (mkMerge [ | ||||
|     (mkIf cfg.lsp.enable { | ||||
|       vim.lsp.lspconfig.enable = true; | ||||
|       vim.lsp.lspconfig.sources.css-lsp = servers.${cfg.lsp.server}.lspConfig; | ||||
|       vim.lsp.lspconfig.sources.tailwindcss-lsp = servers.${cfg.lsp.server}.lspConfig; | ||||
|     }) | ||||
|   ]); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue