feat(git): add custom status sidebar and diff viewer
This commit is contained in:
@@ -111,8 +111,8 @@ require("nvim-tree").setup({
|
||||
full_name = true,
|
||||
root_folder_label = function(path)
|
||||
local label = vim.fn.fnamemodify(path, ":~")
|
||||
local git_head = vim.fn.FugitiveHead()
|
||||
if git_head ~= "" then
|
||||
local git_head = require("git").head(path)
|
||||
if git_head then
|
||||
label = label .. (" %s"):format(git_head)
|
||||
end
|
||||
return label
|
||||
|
||||
+3
-3
@@ -50,9 +50,9 @@ local highlights = {
|
||||
DiffAdd = { bg = "#1a2f22" },
|
||||
DiffChange = { bg = "#15304a" },
|
||||
DiffDelete = { bg = "#311c1e" },
|
||||
GitDeleted = { fg = c.red },
|
||||
GitDirty = { fg = c.yellow },
|
||||
GitNew = { fg = c.green },
|
||||
-- GitDeleted = { fg = c.red },
|
||||
-- GitUnstaged = { fg = c.yellow },
|
||||
-- GitUntracked = { fg = c.green },
|
||||
}
|
||||
for kind, color in pairs(completion_kind_colors) do
|
||||
highlights["LspKind" .. kind] = { fg = color }
|
||||
|
||||
@@ -1,35 +1,3 @@
|
||||
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(
|
||||
@@ -58,7 +26,6 @@ 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",
|
||||
|
||||
Reference in New Issue
Block a user