fabijanzulj / blame.nvim Goto Github PK
View Code? Open in Web Editor NEWNeovim fugitive style git blame plugin
License: MIT License
Neovim fugitive style git blame plugin
License: MIT License
I can use the virtual mode view, but attempting to open the window view gives the following error:
stack traceback:
...are/nvim/lazy/blame.nvim/lua/blame/views/window_view.lua:67: in function 'lines_with_hl_to_text_lines'
...are/nvim/lazy/blame.nvim/lua/blame/views/window_view.lua:103: in function 'open'
Here is my config (using lazy.nvim):
{
"FabijanZulj/blame.nvim",
keys = {
{
"<leader>b",
"<cmd>BlameToggle virtual<CR>",
mode = "n",
desc = "Toggle Blame",
},
},
config = function()
require("blame").setup({
colors = {
"#d93377",
"#af4390",
"#7f4f97",
"#51538c",
"#335075",
"#2f4858",
},
})
end,
},
Note that this error was occurring when the setup function was called with no parameters.
Cool plugin! Thanks.
Currently commit detail view doesn't wrap long lines. Please add a config to enable wrapping long lines.
ππ»
I'm not sure if there's something I need to configure to make this work correctly, but showing the full commit info (as documented here: https://github.com/FabijanZulj/blame.nvim?tab=readme-ov-file#full-commit-info) doesn't work for me (see screenshot).
My configuration is:
https://github.com/Integralist/nvim/blob/main/lua/plugins/git.lua#L2-L20
It would be nice if there was direct enable and disable commands/functions.
For me I bind a bunch of clearing visual commands to like nohlsearch
so DisableBlame would go there.
Focus on the blame view instead of the file content when it is opened and after going to the previous commit. (might be configurable)
Go to the correct line after going to the previous commit. The line number is provided in the line porcelain.
Alternatively, implement something like fugitive: https://github.com/tpope/vim-fugitive/blob/dac8e5c2d85926df92672bf2afb4fc48656d96c7/doc/fugitive.txt#L75-L83
use to open up the commit, select the corresponding
-
line that you care about, and press twice more to reblame at that line. Viewing the commit also gives you additional context as to why the line changed.
Hi, on commit 9c92d03
I get the following error when I launch Neovim.
Failed to run `config` for blame.nvim
...ocal/share/nvim/lazy/blame.nvim/lua/blame/highlights.lua:14: Invalid highlight color: 'bg'
# stacktrace:
- /blame.nvim/lua/blame/highlights.lua:14 _in_ **setup_highlights**
- /blame.nvim/lua/blame.lua:37 _in_ **setup**
- ~/.config/nvim/lua/jawi/plugins/blame.lua:4 _in_ **config**
- ~/.config/nvim/lua/jawi/init.lua:26
- ~/.config/nvim/init.lua:1
My config:
return {
"FabijanZulj/blame.nvim",
config = function ()
require("blame").setup({
virtual_style = "float",
merge_consecutive = true,
})
end
}
Any ideas how to fix it?
Yea just a nice to have, instead of toggling the thing on and off everytime, when we switch buffers.
Hi, I really like the plugin's virtual mode, but I have a very wide monitor and so the "blames" are very far from the code. I have a few ideas:
What do you think?
I'm using WezTerm with rebecca
color scheme, if I don't have set termguicolors
in my init.vim
all the commits and commits' dates are white.
Is there anyway to support the color scheme from the terminal without using set termguicolors
?
When running :ToggleBlame
or :EnableBlame virtual
.te/pack/packer/start/blame.nvim/lua/blame/highlights.lua:22: bad argument #1 to 'sub' (string expected, got nil)
stack traceback:
^I[C]: in function 'sub'
^I...te/pack/packer/start/blame.nvim/lua/blame/highlights.lua:22: in function 'map_highlights_per_hash'
^I...are/nvim/site/pack/packer/start/blame.nvim/lua/blame.lua:45: in function <...are/nvim/site/pack/packer/start/blame.nvim/lua/blame.lua:39>
β― nvim -v
NVIM v0.10.0-dev-9afbfb4
Build type: RelWithDebInfo
LuaJIT 2.1.1695653777
Run "nvim -V1 -v" for more info
When using an ssh tunnel with nvim scp://user@host:/
, for some reason blame doesn't see that it is inside a git repository.
Same goes for usage of sshfs
.
I tried to show blame for the same repository locally and it works.
The message I get is Could not execute blame, might not be a git repository
.
Now it tries the parent commit when the previous blame is not available and relies on the error to detect the initial commit.
blame.nvim/lua/blame/blame_stack.lua
Lines 292 to 294 in 314398f
I'm not sure how this is useful. Can we just show the "no previous commit" info when the previous blame is not available?
BTW, when not using a notification plugin, now the debug error message overrides (hides) the "no previous commit" info:
blame.nvim/lua/blame/blame_stack.lua
Lines 77 to 83 in 314398f
Please use lists instead of strings for command arguments so that they are properly escaped.
PoC: nvim '";notify-send injected"' +BlameToggle
e.g.
local blame_command = {"git", "--no-pager", "blame", "--line-porcelain",
commit or "@",
"--", filename,
}
I suggest even those not vulnerable to command injection should also use lists.
Hello there, firstly, thank you for this plugin, really appreciate that!
Here's a bug I found:
When I try to open a git blame window after several manipulations, it throws an error:
Repro:
blame.nvim
there (as a window):q
. Blame window should be opened fullscreen now.:q
. Neovim won't be closed since we have one edited buffer left, you'll be redirected to the very first buffer.blame.nvim
there. You'll get the error I provided.My neovim version: 0.9.1
hello. Blame is hardly visible in case some lsp error is displayed on the same string.
The "blame stack" feature should use the commit.filename
instead of the initial filename on pushing, in case that the file was renamed in older commits.
Basically, we need this change:
@@ -216,6 +216,8 @@ function BlameStack:push(commit)
})
end
+ self.file_path = commit.filename
+
vim.api.nvim_set_current_win(self.original_window)
vim.api.nvim_set_current_buf(self.stack_buffer
However, I'm messed up with cwd and other commands and haven't figured out how to properly handle them.
Feature request: Automatically focus blame window.
Manual alternative:
execute "BlameToggle window" | sleep 200m | call feedkeys("\<C-w>l")
Just some initial impressions:
<esc>
and q
to close it.BufUnload
to ensure https://github.com/FabijanZulj/blame.nvim/blob/main/lua/blame/window_blame.lua#L40
gets called.<cr>
on the specific lineGreat work - looking forward to seeing this progress :)
Add an option to merge consecutive blame lines that are a part of the same commit (like on github etc.)
I am using nvim-scrollbar and when I activate the virtual style blame it's mixed together. It would be nice to leave out a space for the scrollbar.
Would it be possible to support the -CCC
as this is super useful to ignore format/move changes and really see who had changed the line?
Edit: I also found out that when i quit blame window with blame created keybinding like 'q' the error persist, which does not happen when i quit with BlameToggle
Basically, telescope is working normally till i open git blame then it:
each of telescope command i run as such:
{ "<leader>sg", "<cmd>Telescope live_grep<CR>", desc = "Grep files", icon = "σ°±Ό" },
{ "<leader>f", "<cmd>Telescope find_files<CR>", desc = "Find File" },
{ "<leader>b", "<cmd>lua require("telescope.builtin").buffers()<CR>", desc = "List Buffers", icon = "ξΎ" },
{
"FabijanZulj/blame.nvim",
cmd = "BlameToggle",
lazy = true,
opts = {
blame_options = { '-w' },
date_format = "%d.%m.%Y",
virtual_style = "right",
merge_consecutive = false,
max_summary_width = 40,
colors = nil,
commit_detail_view = "split",
-- format_fn = formats.commit_date_author_fn,
mappings = {
commit_info = "K",
stack_push = "<TAB>",
stack_pop = "<BS>",
show_commit = "<CR>",
close = { "q" },
}
},
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
dependencies = {
{ 'nvim-telescope/telescope-media-files.nvim' },
{
"nvim-telescope/telescope-fzf-native.nvim",
build =
"cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
},
},
tag = "0.1.7",
config = function()
local _, actions = pcall(require, "telescope.actions")
local function filenameFirst(_, path)
local tail = vim.fs.basename(path)
local parent = vim.fs.dirname(path)
if parent == "." then return tail end
return string.format("%s\t\t%s", tail, parent)
end
vim.api.nvim_create_autocmd("FileType", {
pattern = "TelescopeResults",
callback = function(ctx)
vim.api.nvim_buf_call(ctx.buf, function()
vim.fn.matchadd("TelescopeParent", "\t\t.*$")
vim.api.nvim_set_hl(0, "TelescopeParent", { link = "Comment" })
end)
end,
})
require("telescope").setup({
defaults = require("telescope.themes").get_ivy {
path_display = filenameFirst,
selection_strategy = "reset",
selection_caret = "ο€ ",
dynamic_preview_title = true,
-- layout_strategy = "flex",
color_devicons = true,
prompt_prefix = " ο ",
file_previewer = require("telescope.previewers").vim_buffer_cat.new,
grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
layout_config = {
-- anchor = "C",
prompt_position = "bottom",
-- height = 0.90,
-- width = 0.99,
},
mappings = {
i = {
["<esc>"] = actions.close,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-n>"] = actions.send_to_qflist + actions.open_qflist,
},
-- n = {
-- ["<C-j>"] = actions.move_selection_next,
-- ["<C-k>"] = actions.move_selection_previous,
-- ["gq"] = actions.send_to_qflist + actions.open_qflist,
-- },
},
},
extensions_list = { "themes", "terms" },
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
},
},
-- other configuration values here
})
require('telescope').load_extension('fzf')
require('telescope').load_extension('media_files')
end,
}
Now it may throw an error when the original file window has been closed: blame.nvim/lua/blame/views/window_view.lua:309: Invalid window id
"it doesn't support showing the full commit. With fugitive you can hit on a commit and it'll bring up the full diff (I think it just runs git show and dumps the output). Do you have any plans for adding something similar?"
Comment
I noticed that the patterns of command name is different from other plugins.
Specifically, "FooToggle" is more common than "ToggleFoo". This seems a typical convention.
Example:
https://github.com/folke/trouble.nvim?tab=readme-ov-file#commands
So my proposal is to rename "Enable" to "BlameEnable". What do you think?
Hi :) The rewrite is looking really good. I recently tried it out, and I saw a minor bug with the info popup when pressing i
inside the the blame window. When pressing i
twice, it enters the windows, and it will set cursorline, scrollbind and maybe some other options.
I tracked it down to some places where you are using vim.api.nvim_set_option_value
. For example on line 150 in window_view.lua
. I tried to change those places to vim.wo[winnr][0][option] = value
, and it seemed to fix the problem. This is because it only sets the option on the current buffer in the current window when providing the second indexing into vim.wo
.
I see that there is a lot of other places where you use vim.wo
, and it might actually be vim.wo[winnr][0]
that should be used. I didn't have time yet to dig into where it might be safe to do this change, but thought I would at least open an issue so you know :) I am not sure if I will have time to dig into this and make a PR. I will ofc do it if I get time for it :)
When I try to run the plugin using :ToggleBlame
, :ToggleBlame window
or :EnableBlame
. Nothing happens and I get the following :messages
stack traceback:
^I[C]: in function 'nvim_get_hl'
^I...user/.vim/plugged/blame.nvim/lua/blame/highlights.lua:25: in function 'map_highlights_per_hash'
^I/home/user/.vim/plugged/blame.nvim/lua/blame.lua:54: in function </home/user/.vim/plugged/blame.nvim/lua/blame.lua:48> function: builtin#18 ...user/.vim/plugged/blame.nvim/lua/bla
me/highlights.lua:25: invalid key: create
stack traceback:
^I[C]: in function 'nvim_get_hl'
^I...user/.vim/plugged/blame.nvim/lua/blame/highlights.lua:25: in function 'map_highlights_per_hash'
^I/home/user/.vim/plugged/blame.nvim/lua/blame.lua:54: in function </home/user/.vim/plugged/blame.nvim/lua/blame.lua:48>
Hello π
Would a pop-up to show the blame and (optional) diff fit as a feature of this plug-in?
Something like https://github.com/rhysd/git-messenger.vim.
Please add the -w option to git blame.
Update: please take a look at JanosSarkoezi@7081043
This is my solution to my ticket and possibly other tickets too. If you like this, do the customization or merge.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.