nvim: add plugin 'FabijanZulj/blame.nvim'
This commit is contained in:
parent
a69a39fde7
commit
44f977d2da
4 changed files with 62 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" },
|
||||
"blame.nvim": { "branch": "main", "commit": "dedbcdce857f708c63f261287ac7491a893912d0" },
|
||||
"catppuccin": { "branch": "main", "commit": "9703f227bfab20d04bcee62d2f08f1795723b4ae" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
|
||||
|
|
58
config/nvim/lua/fschauen/plugins/blame.lua
Normal file
58
config/nvim/lua/fschauen/plugins/blame.lua
Normal file
|
@ -0,0 +1,58 @@
|
|||
return {
|
||||
"FabijanZulj/blame.nvim",
|
||||
|
||||
cmd = "BlameToggle",
|
||||
|
||||
keys = {
|
||||
{
|
||||
"<leader>gb",
|
||||
"<cmd>BlameToggle<cr>",
|
||||
desc = require("fschauen.util.icons").ui.Git .. " [g]it [b]lame (blame.nvim)",
|
||||
},
|
||||
},
|
||||
|
||||
opts = {
|
||||
-- Using (0xEACC) instead of - (0x2D) in `date_format` because `blame.nvim`
|
||||
-- constructs each line and then uses `string.find({s}, {pattern})` to find
|
||||
-- the position of the date in order to set the highlight. The normal dash
|
||||
-- (0x2D) is a magic character in {pattern} and prevents the date from being
|
||||
-- found and thus the highlight fails. Escaping the dash doesn't work because
|
||||
-- the escape sequence would be visible in the final output, so my
|
||||
-- workaround is to use a symbol that _looks like_ a dash, but isn't one.
|
||||
date_format = "%Y%m%d",
|
||||
|
||||
commit_detail_view = "tab", -- Open commits in a new tab.
|
||||
|
||||
mappings = {
|
||||
commit_info = { "i", "K" },
|
||||
},
|
||||
|
||||
-- The default format uses _committer_ time, but I want _author_ time
|
||||
-- (when I do rebases, I am interested in the original commit). A custom
|
||||
-- formatting function also allows me to slightly tweak the final output.
|
||||
format_fn = function(commit, config, idx)
|
||||
local hash = string.sub(commit.hash, 1, 7)
|
||||
|
||||
if hash == "0000000" then
|
||||
return {
|
||||
idx = idx,
|
||||
values = {
|
||||
{ textValue = "·······", hl = "Comment" },
|
||||
{ textValue = "Not commited", hl = "Comment" },
|
||||
},
|
||||
format = "%s %s",
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
idx = idx,
|
||||
values = {
|
||||
{ textValue = hash, hl = hash },
|
||||
{ textValue = os.date(config.date_format, commit.author_time), hl = hash },
|
||||
{ textValue = commit.author, hl = hash },
|
||||
},
|
||||
format = "%s %s %s",
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -7,8 +7,8 @@ return {
|
|||
local icon = require("fschauen.util.icons").ui.Git
|
||||
return {
|
||||
-- stylua: ignore start
|
||||
{ "<leader>gS", "<cmd>tab Git<cr>", desc = icon.." [S]status (fugitive)" },
|
||||
{ "<leader>gb", "<cmd>Git blame<cr>", desc = icon.." [b]lame (fugitive)" },
|
||||
{ "<leader>gS", "<cmd>tab Git<cr>", desc = icon.." [g]it [S]status (fugitive)" },
|
||||
{ "<leader>gB", "<cmd>Git blame<cr>", desc = icon.." [g]it [B]lame (fugitive)" },
|
||||
-- stylua: ignore end
|
||||
}
|
||||
end,
|
||||
|
|
|
@ -8,7 +8,7 @@ return {
|
|||
dependencies = "nvim-lua/plenary.nvim",
|
||||
|
||||
keys = {
|
||||
{ "<leader>gs", "<cmd>Neogit<cr>", desc = ui.Git .. " [s]tatus (Neogit)" },
|
||||
{ "<leader>gs", "<cmd>Neogit<cr>", desc = ui.Git .. " [g]it [s]tatus (Neogit)" },
|
||||
},
|
||||
|
||||
opts = {
|
||||
|
|
Loading…
Add table
Reference in a new issue