mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-30 12:34:37 +02:00
fix(lazygit): make sure we start lazygit in a valid git root
This commit is contained in:
parent
864c58cae6
commit
d8d380a60e
2 changed files with 8 additions and 1 deletions
|
@ -126,7 +126,7 @@ map("n", "<leader>uT", function() if vim.b.ts_highlight then vim.treesitter.stop
|
||||||
map("n", "<leader>ub", function() Util.toggle("background", false, {"light", "dark"}) end, { desc = "Toggle Background" })
|
map("n", "<leader>ub", function() Util.toggle("background", false, {"light", "dark"}) end, { desc = "Toggle Background" })
|
||||||
|
|
||||||
-- lazygit
|
-- lazygit
|
||||||
map("n", "<leader>gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" })
|
map("n", "<leader>gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root.git(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" })
|
||||||
map("n", "<leader>gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" })
|
map("n", "<leader>gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" })
|
||||||
|
|
||||||
map("n", "<leader>gf", function()
|
map("n", "<leader>gf", function()
|
||||||
|
|
|
@ -173,6 +173,13 @@ function M.get(opts)
|
||||||
return Util.is_win() and ret:gsub("/", "\\") or ret
|
return Util.is_win() and ret:gsub("/", "\\") or ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.git()
|
||||||
|
local root = M.get()
|
||||||
|
local git_root = vim.fs.find(".git", { path = root, upward = true })[1]
|
||||||
|
local ret = git_root and vim.fn.fnamemodify(git_root, ":h") or root
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
---@param opts? {hl_last?: string}
|
---@param opts? {hl_last?: string}
|
||||||
function M.pretty_path(opts)
|
function M.pretty_path(opts)
|
||||||
return ""
|
return ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue