mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 11:02:37 +00:00 
			
		
		
		
	languages/markdown: move to standalone file; add deno formatter
This commit is contained in:
		
					parent
					
						
							
								efd8b44ce1
							
						
					
				
			
			
				commit
				
					
						d06ff3d7db
					
				
			
		
					 5 changed files with 45 additions and 51 deletions
				
			
		|  | @ -5,7 +5,6 @@ in { | |||
|     ./bash | ||||
|     ./dart | ||||
|     ./elixir | ||||
|     ./markdown | ||||
|     ./tidal | ||||
| 
 | ||||
|     ./clang.nix | ||||
|  | @ -14,6 +13,7 @@ in { | |||
|     ./html.nix | ||||
|     ./java.nix | ||||
|     ./lua.nix | ||||
|     ./markdown.nix | ||||
|     ./nim.nix | ||||
|     ./nix.nix | ||||
|     ./php.nix | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ | |||
|   lib, | ||||
|   ... | ||||
| }: let | ||||
|   inherit (builtins) attrNames; | ||||
|   inherit (builtins) attrNames concatLists; | ||||
|   inherit (lib.options) mkEnableOption mkOption; | ||||
|   inherit (lib.lists) isList; | ||||
|   inherit (lib.types) bool enum either package listOf str; | ||||
|  | @ -29,6 +29,22 @@ | |||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   defaultFormat = "denofmt"; | ||||
|   formats = { | ||||
|     denofmt = { | ||||
|       package = pkgs.deno; | ||||
|       nullConfig = '' | ||||
|         table.insert( | ||||
|           ls_sources, | ||||
|           null_ls.builtins.formatting.deno_fmt.with({ | ||||
|             filetypes = ${concatLists cfg.format.extraFiletypes ["markdown"]}, | ||||
|             command = "${cfg.format.package}/bin/deno", | ||||
|           }) | ||||
|         ) | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| in { | ||||
|   options.vim.languages.markdown = { | ||||
|     enable = mkEnableOption "Markdown markup language support"; | ||||
|  | @ -59,5 +75,27 @@ in { | |||
|         default = servers.${cfg.lsp.server}.package; | ||||
|       }; | ||||
|     }; | ||||
| 
 | ||||
|     format = { | ||||
|       enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;}; | ||||
| 
 | ||||
|       type = mkOption { | ||||
|         description = "Markdown formatter to use"; | ||||
|         type = enum (attrNames formats); | ||||
|         default = defaultFormat; | ||||
|       }; | ||||
| 
 | ||||
|       package = mkOption { | ||||
|         description = "Markdown formatter package"; | ||||
|         type = package; | ||||
|         default = formats.${cfg.format.type}.package; | ||||
|       }; | ||||
| 
 | ||||
|       extraFiletypes = mkOption { | ||||
|         description = "Extra filetypes to format with the Markdown formatter"; | ||||
|         type = listOf str; | ||||
|         default = []; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
|  | @ -1,40 +0,0 @@ | |||
| { | ||||
|   pkgs, | ||||
|   config, | ||||
|   lib, | ||||
|   ... | ||||
| }: let | ||||
|   inherit (lib.nvim.lua) expToLua; | ||||
|   inherit (lib.modules) mkIf mkMerge; | ||||
|   inherit (lib.lists) isList; | ||||
| 
 | ||||
|   cfg = config.vim.languages.markdown; | ||||
|   servers = { | ||||
|     marksman = { | ||||
|       package = pkgs.marksman; | ||||
|       lspConfig = '' | ||||
|         lspconfig.marksman.setup{ | ||||
|           capabilities = capabilities; | ||||
|           on_attach = default_on_attach; | ||||
|           cmd = ${ | ||||
|           if isList cfg.lsp.package | ||||
|           then expToLua cfg.lsp.package | ||||
|           else ''{"${cfg.lsp.package}/bin/marksman", "server"}'' | ||||
|         }, | ||||
|         } | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| in { | ||||
|   config = mkIf cfg.enable (mkMerge [ | ||||
|     (mkIf cfg.treesitter.enable { | ||||
|       vim.treesitter.enable = true; | ||||
|       vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage]; | ||||
|     }) | ||||
| 
 | ||||
|     (mkIf cfg.lsp.enable { | ||||
|       vim.lsp.lspconfig.enable = true; | ||||
|       vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig; | ||||
|     }) | ||||
|   ]); | ||||
| } | ||||
|  | @ -1,6 +0,0 @@ | |||
| {...}: { | ||||
|   imports = [ | ||||
|     ./config.nix | ||||
|     ./markdown.nix | ||||
|   ]; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue