Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
speelbarrow opened this issue May 25, 2023 · 7 comments · Fixed by #799
Closed

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

speelbarrow opened this issue May 25, 2023 · 7 comments · Fixed by #799
Labels
bug Something isn't working

Comments

@speelbarrow
Copy link

speelbarrow commented May 25, 2023

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\" }"
]
@speelbarrow speelbarrow added the bug Something isn't working label May 25, 2023
@lewis6991
Copy link
Owner

What are the highlights of GitSignsStagedAdd and GitSignsAdd?

@speelbarrow
Copy link
Author

speelbarrow commented May 25, 2023

What are the highlights of GitSignsStagedAdd and GitSignsAdd?

Screenshot 2023-05-25 at 10 06 07 AM Screenshot 2023-05-25 at 10 15 50 AM

Using minimal.lua as defined above with vim --clean:
Screenshot 2023-05-25 at 10 21 18 AM
Screenshot 2023-05-25 at 10 21 42 AM

(NOTE: while taking the screenshots for this I realized that the GitSignsStaged... highlights weren't displaying in the output of :hi at all, I've updated minimal.lua in my original comment to enable termguicolors. Did not change the behaviour described in this issue.)

@lewis6991
Copy link
Owner

Hmm Ok.

I have no idea ¯_(ツ)_/¯

@lewis6991
Copy link
Owner

I can reproduce. I'll debug.

@speelbarrow
Copy link
Author

I can reproduce. I'll debug.

Thanks! I'll look into it myself as well (to the extent that I can) and let you know if I find anything.

@lewis6991
Copy link
Owner

Can you try #799?

@speelbarrow
Copy link
Author

Confirmed, fixed the issue. Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants