mirror of
				https://github.com/folke/lazy.nvim.git
				synced 2025-11-04 08:21:13 +00:00 
			
		
		
		
	feat(ui): added custom commands for lazygit and opening a terminal for a plugin
This commit is contained in:
		
					parent
					
						
							
								7d02da2ff0
							
						
					
				
			
			
				commit
				
					
						be3909c544
					
				
			
		
					 4 changed files with 61 additions and 7 deletions
				
			
		
							
								
								
									
										25
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								README.md
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -327,6 +327,31 @@ return {
 | 
			
		|||
      task = "✔ ",
 | 
			
		||||
    },
 | 
			
		||||
    throttle = 20, -- how frequently should the ui process render events
 | 
			
		||||
    custom_keys = {
 | 
			
		||||
      -- you can define custom key maps here.
 | 
			
		||||
      -- To disable one of the defaults, set it to false
 | 
			
		||||
 | 
			
		||||
      -- open lazygit log
 | 
			
		||||
      ["<localleader>l"] = function(plugin)
 | 
			
		||||
        require("lazy.util").open_cmd({ "lazygit", "log" }, {
 | 
			
		||||
          cwd = plugin.dir,
 | 
			
		||||
          terminal = true,
 | 
			
		||||
          close_on_exit = true,
 | 
			
		||||
          enter = true,
 | 
			
		||||
        })
 | 
			
		||||
      end,
 | 
			
		||||
 | 
			
		||||
      -- open a terminal for the plugin dir
 | 
			
		||||
      ["<localleader>t"] = function(plugin)
 | 
			
		||||
        require("lazy.util").open_cmd({ vim.go.shell }, {
 | 
			
		||||
          cwd = plugin.dir,
 | 
			
		||||
          terminal = true,
 | 
			
		||||
          close_on_exit = true,
 | 
			
		||||
          enter = true,
 | 
			
		||||
        })
 | 
			
		||||
      end,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  diff = {
 | 
			
		||||
    -- diff command <d> can be one of:
 | 
			
		||||
    -- * browser: opens the github compare view. Note that this is always mapped to <K> as well,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								TODO.md
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								TODO.md
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
## ✅ TODO
 | 
			
		||||
# ✅ TODO
 | 
			
		||||
 | 
			
		||||
- [x] fancy UI to manage all your Neovim plugins
 | 
			
		||||
- [x] auto lazy-loading of lua modules
 | 
			
		||||
| 
						 | 
				
			
			@ -46,6 +46,8 @@
 | 
			
		|||
 | 
			
		||||
- [ ] document highlight groups
 | 
			
		||||
- [ ] document user events
 | 
			
		||||
- [ ] document API, like lazy.plugins()
 | 
			
		||||
- [ ] icons
 | 
			
		||||
 | 
			
		||||
- [x] check in cache if rtp files match
 | 
			
		||||
- [x] I think the installation section, specifically the loading part, could use an
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,6 +50,31 @@ M.defaults = {
 | 
			
		|||
      task = "✔ ",
 | 
			
		||||
    },
 | 
			
		||||
    throttle = 20, -- how frequently should the ui process render events
 | 
			
		||||
    custom_keys = {
 | 
			
		||||
      -- you can define custom key maps here.
 | 
			
		||||
      -- To disable one of the defaults, set it to false
 | 
			
		||||
 | 
			
		||||
      -- open lazygit log
 | 
			
		||||
      ["<localleader>l"] = function(plugin)
 | 
			
		||||
        require("lazy.util").open_cmd({ "lazygit", "log" }, {
 | 
			
		||||
          cwd = plugin.dir,
 | 
			
		||||
          terminal = true,
 | 
			
		||||
          close_on_exit = true,
 | 
			
		||||
          enter = true,
 | 
			
		||||
        })
 | 
			
		||||
      end,
 | 
			
		||||
 | 
			
		||||
      -- open a terminal for the plugin dir
 | 
			
		||||
      ["<localleader>t"] = function(plugin)
 | 
			
		||||
        require("lazy.util").open_cmd({ vim.go.shell }, {
 | 
			
		||||
          cwd = plugin.dir,
 | 
			
		||||
          terminal = true,
 | 
			
		||||
          close_on_exit = true,
 | 
			
		||||
          enter = true,
 | 
			
		||||
        })
 | 
			
		||||
      end,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  diff = {
 | 
			
		||||
    -- diff command <d> can be one of:
 | 
			
		||||
    -- * browser: opens the github compare view. Note that this is always mapped to <K> as well,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,12 +96,14 @@ function M.create(opts)
 | 
			
		|||
  end)
 | 
			
		||||
 | 
			
		||||
  for key, handler in pairs(Config.options.ui.custom_keys) do
 | 
			
		||||
    self:on_key(key, function()
 | 
			
		||||
      local plugin = self.render:get_plugin()
 | 
			
		||||
      if plugin then
 | 
			
		||||
        handler(plugin)
 | 
			
		||||
      end
 | 
			
		||||
    end)
 | 
			
		||||
    if handler then
 | 
			
		||||
      self:on_key(key, function()
 | 
			
		||||
        local plugin = self.render:get_plugin()
 | 
			
		||||
        if plugin then
 | 
			
		||||
          handler(plugin)
 | 
			
		||||
        end
 | 
			
		||||
      end)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  self:setup_patterns()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue