mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
Updated keymaps, not everyone likes lazygit.
This commit is contained in:
parent
12818a6cb4
commit
5859d9d914
2 changed files with 25 additions and 3 deletions
|
|
@ -130,22 +130,32 @@ if vim.lsp.inlay_hint then
|
|||
end
|
||||
|
||||
-- lazygit
|
||||
local status, gitcheck = pcall(require, "lazyvim.util.gitcheck")
|
||||
if not status then
|
||||
print("Failed to load gitcheck.")
|
||||
else
|
||||
local is_lazygit_available = gitcheck.is_lazygit_available
|
||||
-- Setting keymaps only if the user has it installed:
|
||||
if is_lazygit_available() then
|
||||
map("n", "<leader>gg", function() LazyVim.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" })
|
||||
map("n", "<leader>gG", function() LazyVim.lazygit() end, { desc = "Lazygit (cwd)" })
|
||||
map("n", "<leader>gb", LazyVim.lazygit.blame_line, { desc = "Git Blame Line" })
|
||||
map("n", "<leader>gB", LazyVim.lazygit.browse, { desc = "Git Browse" })
|
||||
|
||||
map("n", "<leader>gf", function()
|
||||
local git_path = vim.api.nvim_buf_get_name(0)
|
||||
LazyVim.lazygit({args = { "-f", vim.trim(git_path) }})
|
||||
end, { desc = "Lazygit Current File History" })
|
||||
|
||||
map("n", "<leader>gl", function()
|
||||
LazyVim.lazygit({ args = { "log" }, cwd = LazyVim.root.git() })
|
||||
end, { desc = "Lazygit Log" })
|
||||
map("n", "<leader>gL", function()
|
||||
LazyVim.lazygit({ args = { "log" } })
|
||||
end, { desc = "Lazygit Log (cwd)" })
|
||||
else
|
||||
print("Lazygit is not installed.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- quit
|
||||
map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit All" })
|
||||
|
|
|
|||
12
lua/lazyvim/util/gitcheck.lua
Normal file
12
lua/lazyvim/util/gitcheck.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- Simple check to see if the user has lazygit installed. Only then use keymaps.
|
||||
gitcheck = {}
|
||||
function gitcheck.is_lazygit_available()
|
||||
local handle = io.popen("lazygit --version")
|
||||
if handle then
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
return result ~= ""
|
||||
end
|
||||
return false
|
||||
end
|
||||
return gitcheck
|
||||
Loading…
Add table
Reference in a new issue