Skip to content

mb6611/inline-deleted.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

inline-deleted.nvim

A Neovim plugin that shows deleted git lines as inline virtual text below the deletion point.

Features

  • Inline Display: Shows deleted lines as red virtual text directly in your buffer
  • Gitsigns Integration: Uses gitsigns.nvim as the diff data source (unstaged changes only)
  • Smart Collapsing: Automatically collapses hunks with >100 deleted lines
  • Easy Navigation: Toggle display and expand collapsed hunks with simple keybindings
  • Minimal Configuration: Works out of the box with sensible defaults

UI Example

│   3 │ function M.setup(opts)                    │  <- real line
│ ╌╌╌ │ - function M.setup()                      │  <- virtual (red)
│   4 │   M.config = opts or {}                   │  <- real line
│ ╌╌╌ │ - M.config = {}                           │  <- virtual (red)

Requirements

Installation

lazy.nvim

{
  "username/inline-deleted.nvim",
  dependencies = { "lewis6991/gitsigns.nvim" },
  event = { "BufReadPost", "BufNewFile" },
  opts = {},
  keys = {
    { "<leader>gi", function() require("inline-deleted").toggle() end, desc = "Toggle inline deleted" },
    { "<leader>ge", function() require("inline-deleted").expand() end, desc = "Expand deleted hunk" },
  },
}

packer.nvim

use {
  "username/inline-deleted.nvim",
  requires = { "lewis6991/gitsigns.nvim" },
  config = function()
    require("inline-deleted").setup()
  end
}

Configuration

Default configuration:

require("inline-deleted").setup({
  enabled = true,                -- Enable on startup
  prefix = "- ",                 -- Prefix for deleted lines
  line_marker = "╌╌╌ ",          -- Marker shown in line number column area
  max_lines_expanded = 100,      -- Collapse hunks larger than this
  debounce_ms = 150,             -- Debounce refresh to avoid excessive updates
  keymaps = {
    toggle = "<leader>gi",       -- Toggle inline deleted display
    expand = "<leader>ge",       -- Expand collapsed hunk at cursor
  },
  exclude_filetypes = {          -- Don't activate in these filetypes
    "NvimTree",
    "neo-tree",
    "help",
    "fugitive",
    "git",
  },
})

Usage

Commands

Command Description
:InlineDeletedToggle Toggle display on/off
:InlineDeletedRefresh Force refresh
:InlineDeletedExpand Expand hunk at cursor

Keybindings

Key Action
<leader>gi Toggle inline deleted display
<leader>ge Expand collapsed hunk at cursor

Workflow

  1. Make changes to a git-tracked file
  2. Deleted lines automatically appear as red virtual text below the deletion point
  3. If a hunk has >100 deleted lines, it shows a collapsed indicator
  4. Press <leader>ge while on a collapsed hunk to expand it
  5. Toggle the entire feature with <leader>gi

Highlight Groups

Customize colors by setting these highlight groups:

vim.api.nvim_set_hl(0, "InlineDeleted", { fg = "#ff6b6b" })
vim.api.nvim_set_hl(0, "InlineDeletedMarker", { fg = "#666666" })
vim.api.nvim_set_hl(0, "InlineDeletedCollapsed", { fg = "#888888", italic = true })

How It Works

  1. Diff Source: Integrates with gitsigns.nvim to get unstaged changes
  2. Virtual Text: Uses Neovim's extmark API with virt_lines to render deleted lines
  3. Auto-Refresh: Automatically updates on buffer changes, saves, and gitsigns updates
  4. State Management: Tracks collapsed/expanded state per buffer and hunk

Architecture

lua/inline-deleted/
├── init.lua        # Public API, commands, keymaps
├── constants.lua   # Highlight groups, namespace
├── state.lua       # Per-buffer state management
├── hunks.lua       # Gitsigns integration
├── render.lua      # Extmark rendering
└── health.lua      # :checkhealth support

Health Check

Run :checkhealth inline-deleted to verify your setup. This checks:

  • Neovim version (>= 0.10 required)
  • gitsigns.nvim installation
  • gitsigns cache API availability

API

local inline_deleted = require("inline-deleted")

-- Setup with custom config
inline_deleted.setup(opts)

-- Toggle display on/off
inline_deleted.toggle()


-- Expand collapsed hunk at cursor
inline_deleted.expand()

License

MIT

About

Inline deleted lines for Neovim - shows git deletions as virtual text

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages