mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 11:02:37 +00:00 
			
		
		
		
	feat: enable and remap glow preview
This commit is contained in:
		
					parent
					
						
							
								cccc7f5bda
							
						
					
				
			
			
				commit
				
					
						d817b27405
					
				
			
		
					 3 changed files with 46 additions and 9 deletions
				
			
		|  | @ -8,13 +8,26 @@ with lib; let | ||||||
|   cfg = config.vim.markdown.glow; |   cfg = config.vim.markdown.glow; | ||||||
| in { | in { | ||||||
|   config = (mkIf cfg.enable) { |   config = (mkIf cfg.enable) { | ||||||
|     vim.startPlugins = ["glow-nvim"]; |     vim.startPlugins = [ | ||||||
|  |       "glow-nvim" | ||||||
|  |     ]; | ||||||
|  | 
 | ||||||
|     vim.globals = { |     vim.globals = { | ||||||
|       "glow_binary_path" = "${pkgs.glow}/bin"; |       "glow_binary_path" = "${pkgs.glow}/bin"; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     vim.configRC.glow = nvim.dag.entryAnywhere '' |     vim.configRC.glow-nvim = nvim.dag.entryAnywhere '' | ||||||
|       autocmd FileType markdown noremap <leader>p :Glow<CR> |       autocmd FileType markdown noremap <leader>pm :Glow<CR> | ||||||
|  |     ''; | ||||||
|  | 
 | ||||||
|  |     vim.luaConfigRC.glow-nvim = nvim.dag.entryAnywhere '' | ||||||
|  |       require('glow').setup({ | ||||||
|  |         -- use glow path from vim.globals | ||||||
|  |         path = vim.g.glow_binary_path, | ||||||
|  |         border = "${toString cfg.border}", | ||||||
|  |         pager = ${boolToString cfg.pager}, | ||||||
|  |         width = 120, | ||||||
|  |       }) | ||||||
|     ''; |     ''; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -6,13 +6,31 @@ | ||||||
| }: | }: | ||||||
| with lib; | with lib; | ||||||
| with builtins; let | with builtins; let | ||||||
|   cfg = config.vim.markdown; |   cfg = config.vim.markdown.glow; | ||||||
| in { | in { | ||||||
|   options.vim.markdown = { |   options.vim.markdown.glow = { | ||||||
|     glow.enable = mkOption { |     enable = mkOption { | ||||||
|       type = types.bool; |       type = types.bool; | ||||||
|       default = false; |       default = false; | ||||||
|       description = "Enable markdown preview in neovim with glow"; |       description = "Enable markdown preview in neovim with glow"; | ||||||
|     }; |     }; | ||||||
|  |     border = mkOption { | ||||||
|  |       type = types.enum ["shadow" "rounded" "single" "double" "none"]; | ||||||
|  |       default = "double"; | ||||||
|  |       description = "Border style for glow preview"; | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     # style should be either light or dark | ||||||
|  |     style = mkOption { | ||||||
|  |       type = types.enum ["light" "dark"]; | ||||||
|  |       default = "dark"; | ||||||
|  |       description = "Style for glow preview"; | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     pager = mkOption { | ||||||
|  |       type = types.bool; | ||||||
|  |       default = false; | ||||||
|  |       description = "Enable pager for glow preview"; | ||||||
|  |     }; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -107,9 +107,15 @@ in { | ||||||
|         '' |         '' | ||||||
|         else "" |         else "" | ||||||
|       } |       } | ||||||
| 
 |       ${ | ||||||
|        }) |         if config.vim.markdown.glow.enable | ||||||
| 
 |         then '' | ||||||
|  |           -- Markdown | ||||||
|  |           ["<leader>pm"] = { name = "+Preview Markdown" }, | ||||||
|  |         '' | ||||||
|  |         else "" | ||||||
|  |       } | ||||||
|  |       }) | ||||||
|     ''; |     ''; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 NotAShelf
				NotAShelf