update git diff

This commit is contained in:
Alexander Navarro 2025-02-27 11:55:54 -03:00
parent 769700b5ec
commit da22992983
4 changed files with 77 additions and 37 deletions

View file

@ -5,6 +5,8 @@
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
vim.o.diffopt = "vertical,closeoff,filler"
local opt = vim.opt local opt = vim.opt
-- stylua: ignore -- stylua: ignore

View file

@ -2,18 +2,20 @@ return { -- Change colors.none if not using a transparent background
"catppuccin/nvim", "catppuccin/nvim",
name = "catppuccin", name = "catppuccin",
priority = 1000, priority = 1000,
opts = { config = function()
local utils = require("catppuccin.utils.colors")
local opts = {
flavour = "macchiato", flavour = "macchiato",
transparent_background = true, transparent_background = true,
integrations = { integrations = {
aerial = true, aerial = true,
blink_cmp = true, blink_cmp = true,
cmp = true, cmp = true,
harpoon = false, gitsigns = true,
indent_blankline = { enabled = true, scope_color = "text", }, indent_blankline = { enabled = true, scope_color = "text", },
lsp_trouble = true, lsp_trouble = true,
mason = true, mason = true,
neogit = true,
noice = true, noice = true,
notify = true, notify = true,
}, },
@ -27,11 +29,28 @@ return { -- Change colors.none if not using a transparent background
NotificationInfo = { bg = colors.none, fg = colors.text }, NotificationInfo = { bg = colors.none, fg = colors.text },
NotificationWarning = { bg = colors.none, fg = colors.yellow }, NotificationWarning = { bg = colors.none, fg = colors.yellow },
NotificationError = { bg = colors.none, fg = colors.red }, NotificationError = { bg = colors.none, fg = colors.red },
-- for word diff in previews
GitSignsAddInline = {
fg = colors.teal,
bg = utils.darken(colors.teal, 0.4),
style = { "bold" },
},
GitSignsDeleteInline = {
fg = colors.red,
bg = utils.darken(colors.red, 0.4),
style = { "bold" },
},
GitSignsChangeInline = {
fg = colors.mauve,
bg = utils.darken(colors.mauve, 0.4),
style = { "bold" },
},
GitSignsDeleteVirtLn = { bg = colors.none, fg = colors.red },
} }
end, end,
}, }
config = function(_, opts)
require("catppuccin").setup(opts) require("catppuccin").setup(opts)
vim.cmd.colorscheme("catppuccin-macchiato") vim.cmd.colorscheme("catppuccin-macchiato")
end, end,

View file

@ -1,15 +1,29 @@
local const = require("aleidk.constants")
return { return {
{ {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" }, event = { "BufReadPre", "BufNewFile" },
opts = { opts = {
-- See `:help gitsigns.txt` -- See `:help gitsigns.txt`
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = true, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
signs = { signs = {
add = { text = "" }, add = { text = const.icons.git.added },
change = { text = "" }, change = { text = const.icons.git.modified },
delete = { text = "" }, delete = { text = const.icons.git.removed },
topdelete = { text = "" }, topdelete = { text = const.icons.git.removed },
changedelete = { text = "" }, changedelete = { text = const.icons.git.removed },
untracked = { text = "" },
},
signs_staged = {
add = { text = const.icons.git.added },
change = { text = const.icons.git.modified },
delete = { text = const.icons.git.removed },
topdelete = { text = const.icons.git.removed },
changedelete = { text = const.icons.git.removed },
untracked = { text = "" }, untracked = { text = "" },
}, },
on_attach = function(buffer) on_attach = function(buffer)
@ -28,7 +42,10 @@ return {
map("n", "R", gs.reset_buffer, "Reset Buffer") map("n", "R", gs.reset_buffer, "Reset Buffer")
map("n", "<TAB>", gs.preview_hunk, "Preview Hunk") map("n", "<TAB>", gs.preview_hunk, "Preview Hunk")
map("n", "l", function() gs.blame_line({ full = true }) end, "Blame Line") map("n", "l", function() gs.blame_line({ full = true }) end, "Blame Line")
map("n", "d", gs.diffthis, "Diff This") map("n", "L", gs.toggle_current_line_blame, "Toggle current line blame")
map("n", "d", gs.toggle_word_diff, "Toggle word diff")
map("n", "h", "<CMD>diffget<CR>", "Diff This with last commit")
map("n", "l", "<CMD>diffput<CR>", "Diff This with last commit")
end, end,
}, },
}, },

View file

@ -41,6 +41,8 @@ prepend_keymap = [
{ on = ["g", "<Space>"], run = "cd --interactive", desc = "Go to a directory interactively" }, { on = ["g", "<Space>"], run = "cd --interactive", desc = "Go to a directory interactively" },
] ]
[input]
keymap = [{ on = ["<Esc>"], run = "escape --all", desc = "Go back the normal mode, or cancel input" }]
[help] [help]
prepend_keymap = [{ on = "q", run = "escape", desc = "Clear the filter, or hide the help" }] prepend_keymap = [{ on = "q", run = "escape", desc = "Clear the filter, or hide the help" }]