nvim: after/plugin/mini: Switch to mini.diff from gitsigns

This commit is contained in:
Sanchayan Maity 2024-03-31 16:29:21 +05:30
parent 81aeeb634f
commit 703d23c76e
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3
2 changed files with 25 additions and 8 deletions

View file

@ -3,6 +3,22 @@ local opts = { noremap=true, silent=true, unique=true }
-- Comment lines -- Comment lines
require('mini.comment').setup() require('mini.comment').setup()
-- Diff hunks
require('mini.diff').setup({
view = {
style = 'sign',
signs = { add = '+', change = '~', delete = '-' },
},
mappings = {
textobject = 'gh',
goto_prev = '[c',
goto_next = ']c',
goto_first = '<Leader>hf',
goto_last = '<Leader>hl',
apply = '<Leader>hs',
reset = '<Leader>hr',
},
})
-- File System -- File System
require('mini.files').setup({ require('mini.files').setup({
mappings = { mappings = {

View file

@ -136,19 +136,18 @@ M.get_git_branch = function(self)
end end
M.get_git_status = function(self) M.get_git_status = function(self)
local signs = vim.b.gitsigns_status_dict local is_git = fn.FugitiveHead() ~= ""
or { head = "", added = 0, changed = 0, removed = 0 } local signs = vim.b.minidiff_summary or { add = 0, change = 0, delete = 0 }
local is_head_empty = signs.head ~= ""
return is_head_empty return is_git
and string.format( and string.format(
" %s+%s %s~%s %s-%s", " %s+%s %s~%s %s-%s",
"%#DiffAdded#", "%#DiffAdded#",
signs.added or 0, signs.add,
"%#DiffChanged#", "%#DiffChanged#",
signs.changed or 0, signs.change,
"%#DiffRemoved#", "%#DiffRemoved#",
signs.removed or 0 signs.delete
) )
or "" or ""
end end
@ -204,8 +203,10 @@ M.progress = function()
end end
M.git_ahead_behind_status = function() M.git_ahead_behind_status = function()
local is_git = fn.FugitiveHead() ~= ""
return return
vim.b.gitsigns_status_dict is_git
and and
string.format(" %s%s%d%s%d", '%#GitStatus#', '', gstatus.behind, '', gstatus.ahead) string.format(" %s%s%d%s%d", '%#GitStatus#', '', gstatus.behind, '', gstatus.ahead)
or "" or ""