mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 19:12:38 +00:00 
			
		
		
		
	feat: lazygit integration
This commit is contained in:
		
					parent
					
						
							
								9e224d710c
							
						
					
				
			
			
				commit
				
					
						24b631f343
					
				
			
		
					 2 changed files with 43 additions and 19 deletions
				
			
		|  | @ -6,31 +6,47 @@ | ||||||
| with lib; | with lib; | ||||||
| with builtins; let | with builtins; let | ||||||
|   cfg = config.vim.terminal.toggleterm; |   cfg = config.vim.terminal.toggleterm; | ||||||
|  |   toggleKey = "<c-t>"; | ||||||
| in { | in { | ||||||
|   config = mkIf cfg.enable { |   config = mkIf cfg.enable { | ||||||
|     vim.startPlugins = [ |     vim.startPlugins = [ | ||||||
|       "toggleterm-nvim" |       "toggleterm-nvim" | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere '' |     vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ('' | ||||||
|       require("toggleterm").setup({ |         require("toggleterm").setup({ | ||||||
|         open_mapping = [[<c-t>]], |           open_mapping = [[${toggleKey}]], | ||||||
|         direction = '${toString cfg.direction}', |           direction = '${toString cfg.direction}', | ||||||
|         -- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it |           -- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it | ||||||
|         size = function(term) |           size = function(term) | ||||||
|           if term.direction == "horizontal" then |             if term.direction == "horizontal" then | ||||||
|             return 15 |               return 15 | ||||||
|           elseif term.direction == "vertical" then |             elseif term.direction == "vertical" then | ||||||
|             return vim.o.columns * 0.4 |               return vim.o.columns * 0.4 | ||||||
|  |             end | ||||||
|  |           end, | ||||||
|  |           winbar = { | ||||||
|  |             enabled = '${toString cfg.enable_winbar}', | ||||||
|  |             name_formatter = function(term) --  term: Terminal | ||||||
|  |               return term.name | ||||||
|  |             end | ||||||
|  |           }, | ||||||
|  |         }) | ||||||
|  |       '' | ||||||
|  |       + optionalString cfg.lazygit.enable '' | ||||||
|  | 
 | ||||||
|  |         local terminal = require 'toggleterm.terminal' | ||||||
|  |         local lazygit = terminal.Terminal:new({ | ||||||
|  |           cmd = "lazygit", | ||||||
|  |           direction = '${cfg.lazygit.direction}', | ||||||
|  |           hidden = true, | ||||||
|  |           on_open = function(term) | ||||||
|  |             vim.cmd("startinsert!") | ||||||
|  |             vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr}) | ||||||
|           end |           end | ||||||
|         end, |         }) | ||||||
|         winbar = { | 
 | ||||||
|           enabled = '${toString cfg.enable_winbar}', |         vim.keymap.set( 'n', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true}) | ||||||
|           name_formatter = function(term) --  term: Terminal |       ''); | ||||||
|             return term.name |  | ||||||
|           end |  | ||||||
|         }, |  | ||||||
|       }) |  | ||||||
|     ''; |  | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -17,5 +17,13 @@ with builtins; { | ||||||
|       default = false; |       default = false; | ||||||
|       description = "Enable winbar"; |       description = "Enable winbar"; | ||||||
|     }; |     }; | ||||||
|  |     lazygit = { | ||||||
|  |       enable = mkEnableOption "Enable LazyGit integration"; | ||||||
|  |       direction = mkOption { | ||||||
|  |         type = types.enum ["horizontal" "vertical" "tab" "float"]; | ||||||
|  |         default = "float"; | ||||||
|  |         description = "Direction of the lazygit window"; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ching Pei Yang
				Ching Pei Yang