fix(pack): move plugins out from lua runtime path
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
local function open_git_status()
|
||||
local previous_win = vim.api.nvim_get_current_win()
|
||||
vim.cmd("leftabove vertical G")
|
||||
vim.api.nvim_win_set_width(0, 50)
|
||||
vim.api.nvim_set_option_value("winfixwidth", true, { scope = "local" })
|
||||
vim.api.nvim_set_current_win(previous_win)
|
||||
end
|
||||
|
||||
local function get_git_status_win()
|
||||
local current_tabpage = vim.api.nvim_get_current_tabpage()
|
||||
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(current_tabpage)) do
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
local buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
|
||||
if
|
||||
buftype == "nowrite"
|
||||
and vim.api.nvim_buf_get_name(buf):match("^fugitive://.*%.git//$")
|
||||
then
|
||||
return win
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function toggle_git_status()
|
||||
local win = get_git_status_win()
|
||||
if win then
|
||||
vim.api.nvim_win_close(win, false)
|
||||
return
|
||||
end
|
||||
|
||||
open_git_status()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("Glog", function(opts)
|
||||
local mods = opts.mods ~= "" and (opts.mods .. " ") or ""
|
||||
vim.cmd(
|
||||
mods
|
||||
.. "Git log --graph --all --decorate --date=short "
|
||||
.. "--format=format:'%h %ad {%an}%d %s' "
|
||||
.. opts.args
|
||||
)
|
||||
end, { nargs = "*", desc = "Pretty git log via fugitive" })
|
||||
|
||||
vim.keymap.set("n", "<leader>gl", vim.cmd.Glog)
|
||||
vim.keymap.set("n", "<leader>gd", vim.cmd.Gvdiffsplit)
|
||||
vim.keymap.set("n", "<leader>gD", function()
|
||||
vim.cmd.Gvdiffsplit("HEAD")
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gh", vim.cmd.Ghdiffsplit)
|
||||
vim.keymap.set("n", "<leader>gH", function()
|
||||
vim.cmd.Ghdiffsplit("HEAD")
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gc", function()
|
||||
vim.cmd.G("commit")
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>ga", function()
|
||||
vim.cmd.G("commit --amend")
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gp", function()
|
||||
vim.cmd.G("push")
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gg", toggle_git_status)
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "GitRefresh",
|
||||
group = vim.api.nvim_create_augroup("ow.fugitive", { clear = true }),
|
||||
callback = function()
|
||||
vim.fn["fugitive#ReloadStatus"]()
|
||||
end,
|
||||
})
|
||||
Reference in New Issue
Block a user