From da229929831c98f202c5c22737a6fc850d604a38 Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 27 Feb 2025 11:55:54 -0300 Subject: [PATCH] update git diff --- config/nvim/lua/aleidk/options.lua | 2 + .../lua/aleidk/plugins-core/colorscheme.lua | 77 ++++++++++++------- config/nvim/lua/aleidk/plugins-ide/git.lua | 33 ++++++-- config/yazi/keymap.toml | 2 + 4 files changed, 77 insertions(+), 37 deletions(-) diff --git a/config/nvim/lua/aleidk/options.lua b/config/nvim/lua/aleidk/options.lua index d8d6d1e..c51504c 100644 --- a/config/nvim/lua/aleidk/options.lua +++ b/config/nvim/lua/aleidk/options.lua @@ -5,6 +5,8 @@ vim.g.mapleader = " " vim.g.maplocalleader = " " +vim.o.diffopt = "vertical,closeoff,filler" + local opt = vim.opt -- stylua: ignore diff --git a/config/nvim/lua/aleidk/plugins-core/colorscheme.lua b/config/nvim/lua/aleidk/plugins-core/colorscheme.lua index 92a58d4..af5c7fc 100644 --- a/config/nvim/lua/aleidk/plugins-core/colorscheme.lua +++ b/config/nvim/lua/aleidk/plugins-core/colorscheme.lua @@ -2,36 +2,55 @@ return { -- Change colors.none if not using a transparent background "catppuccin/nvim", name = "catppuccin", priority = 1000, - opts = { - flavour = "macchiato", - transparent_background = true, - integrations = { - aerial = true, - blink_cmp = true, - cmp = true, - harpoon = false, - indent_blankline = { enabled = true, scope_color = "text", }, - lsp_trouble = true, - mason = true, - neogit = true, - noice = true, - notify = true, - }, - custom_highlights = function(colors) - return { - -- Fix colors for cmp - Pmenu = { bg = colors.none, blend = 0 }, - FloatBorder = { bg = colors.none }, - CmpItemMenu = { fg = colors.text, bg = colors.none }, - -- dadbod-ui - NotificationInfo = { bg = colors.none, fg = colors.text }, - NotificationWarning = { bg = colors.none, fg = colors.yellow }, - NotificationError = { bg = colors.none, fg = colors.red }, - } - end, - }, + config = function() + local utils = require("catppuccin.utils.colors") + + local opts = { + flavour = "macchiato", + transparent_background = true, + integrations = { + aerial = true, + blink_cmp = true, + cmp = true, + gitsigns = true, + indent_blankline = { enabled = true, scope_color = "text", }, + lsp_trouble = true, + mason = true, + noice = true, + notify = true, + }, + custom_highlights = function(colors) + return { + -- Fix colors for cmp + Pmenu = { bg = colors.none, blend = 0 }, + FloatBorder = { bg = colors.none }, + CmpItemMenu = { fg = colors.text, bg = colors.none }, + -- dadbod-ui + NotificationInfo = { bg = colors.none, fg = colors.text }, + NotificationWarning = { bg = colors.none, fg = colors.yellow }, + 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, + } - config = function(_, opts) require("catppuccin").setup(opts) vim.cmd.colorscheme("catppuccin-macchiato") end, diff --git a/config/nvim/lua/aleidk/plugins-ide/git.lua b/config/nvim/lua/aleidk/plugins-ide/git.lua index 4cc6a38..f34672f 100644 --- a/config/nvim/lua/aleidk/plugins-ide/git.lua +++ b/config/nvim/lua/aleidk/plugins-ide/git.lua @@ -1,18 +1,32 @@ +local const = require("aleidk.constants") + return { { "lewis6991/gitsigns.nvim", event = { "BufReadPre", "BufNewFile" }, opts = { -- See `:help gitsigns.txt` - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "" }, - topdelete = { text = "" }, - changedelete = { text = "▎" }, + 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 = { + 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 = "▎" }, }, - on_attach = function(buffer) + 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 = "▎" }, + }, + on_attach = function(buffer) local gs = package.loaded.gitsigns local function map(mode, l, r, desc) @@ -28,7 +42,10 @@ return { map("n", "R", gs.reset_buffer, "Reset Buffer") map("n", "", gs.preview_hunk, "Preview Hunk") 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", "diffget", "Diff This with last commit") + map("n", "l", "diffput", "Diff This with last commit") end, }, }, diff --git a/config/yazi/keymap.toml b/config/yazi/keymap.toml index f2b259c..6cd54c2 100644 --- a/config/yazi/keymap.toml +++ b/config/yazi/keymap.toml @@ -41,6 +41,8 @@ prepend_keymap = [ { on = ["g", ""], run = "cd --interactive", desc = "Go to a directory interactively" }, ] +[input] +keymap = [{ on = [""], run = "escape --all", desc = "Go back the normal mode, or cancel input" }] [help] prepend_keymap = [{ on = "q", run = "escape", desc = "Clear the filter, or hide the help" }]