Giter VIP home page Giter VIP logo

blame.nvim's People

Contributors

balderholst avatar ckolkey avatar fabijanzulj avatar jcosmao avatar ouuan avatar thesandybridge avatar zoriya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

blame.nvim's Issues

bad argument #1 to sub

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

Plugin not starting

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>

Odd issue with telescope

bug - yt

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:

  • telescope grep files, when inserting some chars(not every one!) it works as if im in keyboard insert
  • telescope files works normally
  • telescope buffer works as grep files, which is bad

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 = "" },
  • nvim v0.10.1
  • config for blame.nvim:
  {
    "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" },
      }
    },
  • telescope config:
{
    "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,
  }

feat: `EnableBlame`, `DisableBlame`

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.

Detect initial commit directly instead of relying on error

Now it tries the parent commit when the previous blame is not available and relies on the error to detect the initial commit.

else
previous = commit.hash .. "^"
end

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:

end, function(err)
vim.notify(
"Cannot go to previous commit, might be the initial commit for the file",
vim.log.levels.INFO
)
vim.notify(err, vim.log.levels.DEBUG)
end)

Commits are not colored when using terminal color scheme

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?

Support file renaming in older commits

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.

Properly escape command arguments

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.

Auto-focus

Feature request: Automatically focus blame window.


Manual alternative:

execute "BlameToggle window" | sleep 200m | call feedkeys("\<C-w>l")

Full commit when <CR> on a line

"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

Error: cannot close last window

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:

WezTerm 2023-09-04 at 17-56

Repro:

  1. Open any git file
  2. Edit it but do not save
  3. Go to another git file
  4. Open blame.nvim there (as a window)
  5. Close the window with the second git file with :q. Blame window should be opened fullscreen now.
  6. Close the blame window with :q. Neovim won't be closed since we have one edited buffer left, you'll be redirected to the very first buffer.
  7. Try to open blame.nvim there. You'll get the error I provided.

My neovim version: 0.9.1

Window view error - attempt to call field 'unpack' (a nil value)

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.

Project Ideas

Just some initial impressions:

  • In the blame window, I would expect <esc> and q to close it.
  • You can use an autocommand on the BufUnload to ensure https://github.com/FabijanZulj/blame.nvim/blob/main/lua/blame/window_blame.lua#L40 gets called.
  • Navigation through the blame-stack a-la github by hitting <cr> on the specific line

Great work - looking forward to seeing this progress :)

Alignment in virtual mode

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:

  • Add a feature to set a padding from the right.
  • Put the blames directly after every line. They wouldn't be aligned, but that's fine by me.
  • Align the blames by the longest line in the file (possibly with some padding, as in the window mode).

image

What do you think?

Focus on blame view and correct line

  • 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.

Invalid option for highlights.lua

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?

Add support for blame through SSH

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.

Robust error handling / better error messages

  1. It crashes when blaming an empty file.
  2. It reports "Could not execute blame, might not be a git repository" when blaming an untracked file. Maybe should show the stderr "fatal: no such path in HEAD" instead.

git blame -CCC

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?

Options for blame window bleeds to info popup

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 :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.