Skip to content

Latest commit

 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inline-git-blame.nvim

VSCode-style inline git blame for Neovim, written in Lua.

Shows commit author, relative time, and commit message at the end of the current line, just like VSCode. Handles unsaved and uncommitted changes, and only activates on normal files (not on explorer, help, etc).


Screenshots

Inline blame example Unsaved change Uncommited change

Features

  • Inline blame for the current line
  • Shows: Author, relative time, commit message
  • Displays "You" (or a custom label) if the commit author matches your git user (you_label option)
  • Handles unsaved and uncommitted changes gracefully
  • Skips non-file buffers (NvimTree, Telescope, help, etc.)
  • Configurable: Extend the list of excluded filetypes via excluded_filetypes option
  • Configurable: Set your own label for your commits with the you_label option
  • Toggle: Quickly show/hide blame annotation for the current line with a single function

Motivation

This plugin provides a VSCode-style, always-on inline blame annotation for the current line, updating automatically as you move your cursor.

Why not just use gitsignsq.nvim?

  • LazyVim's default config uses mini.diff and disables gitsigns, and does not provide inline git blame.
  • Even with gitsigns enabled, you do not get automatic, persistent inline blame on the current line as you move the cursor.
  • This plugin is designed to fill that gap: automatic, VSCode-style inline blame for the current line, with customization for filetypes and your own author label.

Installation

lazy.nvim:

Minimal:

return {
  "yt20chill/inline_git_blame.nvim",
  event = "BufReadPost",
  opts = {}
}

All settings:

-- plugins/inline_git_blame.nvim
return {
  "yt20chill/inline_git_blame.nvim",
  event = "BufReadPost",
  -- optional, default settings
  opts = {
    -- excluded_filetypes will be extended from default
    excluded_filetypes = { "NvimTree", "neo-tree", "TelescopePrompt", "help" },
    debounce_ms = 150,
    autocmd = true,
    you_label = "You", -- can be any string, or false to disable replacement
  },
  -- optional, default no keybindings because autocmds are preferred
keys = {
  { "<leader>gb", "<cmd>lua require('inline_git_blame').inline_blame_current_line()<CR>", desc = "Show inline git blame" },
  { "<leader>gB", "<cmd>lua require('inline_git_blame').clear_blame()<CR>", desc = "Clear inline git blame" },
  { "<leader>gt", "<cmd>lua require('inline_git_blame').toggle_blame_current_line()<CR>", desc = "Toggle inline git blame" },
},
}

packer.nvim

use {
  "yt20chill/inline_git_blame.nvim",
  event = "BufReadPost",
  config = function()
    require("inline_git_blame").setup({
      -- excluded_filetypes will be extended from default
      excluded_filetypes = { "NvimTree", "neo-tree", "TelescopePrompt", "help" },
      debounce_ms = 150,
      autocmd = true,
      you_label = "You", -- can be any string, or false to disable replacement
    })
  end,
  -- optional, default no keybindings because autocmds are preferred
  keys = {
    { "<leader>gb", function() require("inline_git_blame").inline_blame_current_line() end, desc = "Show inline git blame" },
    { "<leader>gB", function() require("inline_git_blame").clear_blame() end, desc = "Clear inline git blame" },
    { "<leader>gt", function() require("inline_git_blame").toggle_blame_current_line() end, desc = "Toggle inline git blame" },
  },
}

Usage

Out of the box

No setup required!
By default, inline blame will appear automatically on CursorHold and clear on cursor move, thanks to the built-in autocmds.
Just install and call:

require("inline_git_blame").setup()

You can also add keymaps if you want:

vim.keymap.set("n", "<leader>gb", require("inline_git_blame").inline_blame_current_line)
vim.keymap.set("n", "<leader>gB", require("inline_git_blame").clear_blame)
vim.keymap.set("n", "<leader>gt", require("inline_git_blame").toggle_blame_current_line)

Toggle blame for the current line

You can use the toggle function to quickly show or hide the blame annotation for the current line:

require("inline_git_blame").toggle_blame_current_line()

Or map it to a key (as above):

vim.keymap.set("n", "<leader>gt", require("inline_git_blame").toggle_blame_current_line)

Custom autocmds (optional)

If you want to set up autocmds yourself (for custom debounce or behavior), set autocmd = false in your config and use:

local blame = require("inline_git_blame")
local timer
vim.api.nvim_create_autocmd("CursorHold", {
  callback = function()
    if timer then timer:stop() timer:close() end
    timer = vim.loop.new_timer()
    timer:start(150, 0, vim.schedule_wrap(function()
      blame.inline_blame_current_line()
    end))
  end,
  desc = "Show inline git blame for current line (debounced)",
})

vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
  callback = function()
    blame.clear_blame()
  end,
  desc = "Clear inline git blame on cursor move",
})

Options

Option Type Default Description
debounce_ms number 150 Debounce time for blame in ms
excluded_filetypes table { "NvimTree", "neo-tree", "TelescopePrompt", "help" } Filetypes to exclude (your values are appended)
autocmd boolean true Whether to set up built-in autocmds
you_label string/false "You" Label to use for your own commits (or false to disable)

Requirements

  • Neovim 0.8+
  • git in your PATH
  • Your files must be in a git repository

TODO

  • Customizable file type to include or exclude
  • Toggle inline git blame
  • Customizable you label
  • Fix plural time
  • Fix file outside of git repo error message

License

MIT


About

Neovim Plugin for VSCode style inline git blame

Resources

Stars

13 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages