Skip to content

Enabling staged signs doesn't switch the highlight group when a hunk is staged #798

@speelbarrow

Description

@speelbarrow

Description

With staged signs enabled, the signs will still show after changes are staged. However, the highlight group for the signs will not change to the alternate highlight group.

Screen.Recording.2023-05-24.at.10.35.20.PM.mov

Neovim version

0.9.0

Operating system and version

macOS Ventura (13.4)

Expected behavior

Expected signs to use the alternate GitSignsStaged[Add|Change|Delete] when a hunk is staged.

Actual behavior

The signs still display (instead of disappearing after being staged), but the highlight group does not change

Minimal config

vim.o.packpath = '/tmp/nvim/site'

local plugins = {
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
}

for name, url in pairs(plugins) do
  local install_path = '/tmp/nvim/site/pack/test/start/'..name
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
end

require('gitsigns').setup{
  debug_mode = true, -- You must add this to enable debug messages
  _signs_staged_enable = true,
}

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

vim.go.termguicolors = true

Steps to reproduce

  1. nvim --clean -u minimal.lua
  2. Open a file with unstaged changes
  3. Stage the changes (either the whole buffer or just a hunk)

Gitsigns debug messages

[
  "signs.init: Using vimfn signs",
  "signs.init: Using vimfn signs",
  "dprintf: Deriving GitSignsAdd from DiffAdd",
  "dprintf: Deriving GitSignsChange from DiffChange",
  "dprintf: Deriving GitSignsDelete from DiffDelete",
  "dprintf: Deriving GitSignsChangedelete from GitSignsChange",
  "dprintf: Deriving GitSignsTopdelete from GitSignsDelete",
  "dprintf: Deriving GitSignsUntracked from GitSignsAdd",
  "dprintf: Deriving GitSignsAddNr from GitSignsAdd",
  "dprintf: Deriving GitSignsChangeNr from GitSignsChange",
  "dprintf: Deriving GitSignsDeleteNr from GitSignsDelete",
  "dprintf: Deriving GitSignsChangedeleteNr from GitSignsChangeNr",
  "dprintf: Deriving GitSignsTopdeleteNr from GitSignsDeleteNr",
  "dprintf: Deriving GitSignsUntrackedNr from GitSignsAddNr",
  "dprintf: Deriving GitSignsAddLn from DiffAdd",
  "dprintf: Deriving GitSignsChangeLn from DiffChange",
  "dprintf: Deriving GitSignsChangedeleteLn from GitSignsChangeLn",
  "dprintf: Deriving GitSignsUntrackedLn from GitSignsAddLn",
  "dprintf: Deriving GitSignsStagedAdd from GitSignsAdd",
  "dprintf: Deriving GitSignsStagedChange from GitSignsChange",
  "dprintf: Deriving GitSignsStagedDelete from GitSignsDelete",
  "dprintf: Deriving GitSignsStagedChangedelete from GitSignsChangedelete",
  "dprintf: Deriving GitSignsStagedTopdelete from GitSignsTopdelete",
  "dprintf: Deriving GitSignsStagedAddNr from GitSignsAddNr",
  "dprintf: Deriving GitSignsStagedChangeNr from GitSignsChangeNr",
  "dprintf: Deriving GitSignsStagedDeleteNr from GitSignsDeleteNr",
  "dprintf: Deriving GitSignsStagedChangedeleteNr from GitSignsChangedeleteNr",
  "dprintf: Deriving GitSignsStagedTopdeleteNr from GitSignsTopdeleteNr",
  "dprintf: Deriving GitSignsStagedAddLn from GitSignsAddLn",
  "dprintf: Deriving GitSignsStagedChangeLn from GitSignsChangeLn",
  "dprintf: Could not derive GitSignsStagedDeleteLn",
  "dprintf: Deriving GitSignsStagedChangedeleteLn from GitSignsChangedeleteLn",
  "dprintf: Could not derive GitSignsStagedTopdeleteLn",
  "dprintf: Deriving GitSignsAddPreview from DiffAdd",
  "dprintf: Deriving GitSignsDeletePreview from DiffDelete",
  "dprintf: Deriving GitSignsCurrentLineBlame from NonText",
  "dprintf: Deriving GitSignsAddInline from TermCursor",
  "dprintf: Deriving GitSignsDeleteInline from TermCursor",
  "dprintf: Deriving GitSignsChangeInline from TermCursor",
  "dprintf: Deriving GitSignsAddLnInline from GitSignsAddInline",
  "dprintf: Deriving GitSignsChangeLnInline from GitSignsChangeInline",
  "dprintf: Deriving GitSignsDeleteLnInline from GitSignsDeleteInline",
  "dprintf: Deriving GitSignsDeleteVirtLn from DiffDelete",
  "dprintf: Deriving GitSignsDeleteVirtLnInLine from GitSignsDeleteLnInline",
  "dprintf: Deriving GitSignsVirtLnum from GitSignsDeleteVirtLn",
  "attach(1): Attaching (trigger=setup)",
  "run_job: git --version",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 config user.name",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /Users/speelbarrow/Git/dotfiles/nvim/lua/setup/lazy.lua",
  "watch_gitdir(1): Watching git dir",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show :0:nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show HEAD:nvim/lua/setup/lazy.lua",
  "update(1): updates: 1, jobs: 6",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD",
  "cli.run: Running action 'stage_hunk' with arguments {}",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git apply --whitespace=nowarn --cached --unidiff-zero -",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show :0:nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show HEAD:nvim/lua/setup/lazy.lua",
  "update(1): updates: 2, jobs: 10",
  "watcher_cb(1): Git dir update",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /Users/speelbarrow/Git/dotfiles/nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show :0:nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show HEAD:nvim/lua/setup/lazy.lua",
  "update(1): updates: 3, jobs: 14",
  "cli.run: Running action 'stage_buffer' with arguments {}",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git apply --whitespace=nowarn --cached --unidiff-zero -",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show :0:nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show HEAD:nvim/lua/setup/lazy.lua",
  "update(1): updates: 4, jobs: 17",
  "watcher_cb(1): Git dir update",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /Users/speelbarrow/Git/dotfiles/nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show :0:nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show HEAD:nvim/lua/setup/lazy.lua",
  "update(1): updates: 5, jobs: 21",
  "watcher_cb(1): Git dir update",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /Users/speelbarrow/Git/dotfiles/nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show :0:nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show HEAD:nvim/lua/setup/lazy.lua",
  "update(1): updates: 6, jobs: 25",
  "watcher_cb(1): Git dir update",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /Users/speelbarrow/Git/dotfiles/nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show :0:nvim/lua/setup/lazy.lua",
  "run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/speelbarrow/Git/dotfiles/.git show HEAD:nvim/lua/setup/lazy.lua",
  "update(1): updates: 7, jobs: 29",
  "cli.run: Running action 'debug_messages' with arguments { \"|\", \"redir\", \"END\" }"
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions