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

git-messenger and window focus break the signs #484

Closed
ambroisie opened this issue Mar 4, 2022 · 4 comments
Closed

git-messenger and window focus break the signs #484

ambroisie opened this issue Mar 4, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@ambroisie
Copy link

Description

I use git-messenger instead of gitsigns.blame_line to open a hover window with the blame information, as I think it:

  • looks better,
  • is more readable, because the window is bigger, each information is on its own line
  • I like the UX better: being able to "move into the hover window" to toggle the diff, or navigate to older commits

However, whenever I use display git-messenger's window, the signs disappear, and only reappear once I manipulate my windows, like opening a split. My gitsigns mapping still work, so I don't think it has detached itself.

Neovim version

0.6.1

Operating system and version

NixOS unstable

Expected behavior

I would like to either:

Anecdotally, I'm not sure how to make the diff prettier, I dislike how the blame window has full (background) highlighting of changed lines and would rather it show colored text.

Actual behavior

Comparison of the looks of the windows, when the diff is enabled:
blame-comparison

I cannot record the bug where the signs disappear unfortunately.

Minimal config

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

local plugins = {
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  plenary  = 'https://github.com/nvim-lua/plenary.nvim',
  git_messenger = 'https://github.com/rhysd/git-messenger.vim',
}

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{
  on_attach = function(bufnr)
    local gs = package.loaded.gitsigns

    local function map(mode, l, r, opts)
        opts = vim.tbl_extend('force', {silent = true}, opts or {})
        vim.api.nvim_buf_set_keymap(bufnr, mode, l, r, opts)
    end

    map('n', '<leader>hb', '<cmd>lua require"gitsigns".blame_line{full=true}<CR>')
    map('n', '<leader>hm', '<Plug>(git-messenger)')
  end,
  debug_mode = true, -- You must add this to enable debug messages
}

-- If removed, the bug disappears
vim.cmd([[
    augroup signtoggle
        autocmd!
        " Only show the sign column for the current focused buffer
        autocmd BufEnter,FocusGained,WinEnter * set signcolumn=yes
        autocmd BufLeave,FocusLost,WinLeave   * set signcolumn=no
        " Disable the sign column in terminal
        autocmd TermOpen * setlocal signcolumn=no
    augroup END
]])

Steps to reproduce

  1. nvim -nu minimal.lua
  2. Open a file with unstaged modifications, the signcolumn should be filled by gitsigns
  3. Use gs.blame_line, they are still visible
  4. Use git-messenger, move the cursor, they disappear.

If you use the git-messenger mappings twice, to move into its hover window, and then do <C-w><C-q>, the sign column does reappear correctly.

Gitsigns debug messages

run_job: git --no-pager --version
setup_highlights: Deriving GitSignsAdd from DiffAdd
setup_highlights: Deriving GitSignsChange from DiffChange
setup_highlights: Deriving GitSignsDelete from DiffDelete
setup_highlights: Deriving GitSignsAddNr from GitSignsAdd
setup_highlights: Deriving GitSignsChangeNr from GitSignsChange
setup_highlights: Deriving GitSignsDeleteNr from GitSignsDelete
setup_highlights: Deriving GitSignsAddLn from DiffAdd
setup_highlights: Deriving GitSignsChangeLn from DiffChange
setup_highlights: Deriving GitSignsDeleteLn from DiffDelete
setup_highlights: Deriving GitSignsCurrentLineBlame from NonText
setup_highlights: Deriving GitSignsAddInline from TermCursor
setup_highlights: Deriving GitSignsDeleteInline from TermCursor
setup_highlights: Deriving GitSignsChangeInline from TermCursor
setup_highlights: Deriving GitSignsAddLnInline from GitSignsAddInline
setup_highlights: Deriving GitSignsChangeLnInline from GitSignsChangeInline
setup_highlights: Deriving GitSignsDeleteLnInline from GitSignsDeleteInline
setup_highlights: Deriving GitSignsAddLnVirtLn from GitSignsAddLn
setup_highlights: Deriving GitSignsChangeVirtLn from GitSignsChangeLn
setup_highlights: Deriving GitSignsDeleteVirtLn from GitSignsDeleteLn
setup_highlights: Deriving GitSignsAddLnVirtLnInLine from GitSignsAddLnInline
setup_highlights: Deriving GitSignsChangeVirtLnInLine from GitSignsChangeLnInline
setup_highlights: Deriving GitSignsDeleteVirtLnInLine from GitSignsDeleteLnInline
run_job: git --no-pager rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
attach(1): Attaching (trigger=BufRead)
run_job: git --no-pager config user.name
run_job: git --no-pager rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /home/ambroisie/git/nix-config/home/zsh/default.nix
watch_gitdir(1): Watching git dir
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git show :0:home/zsh/default.nix
update(1): updates: 1, jobs: 6
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git show :0:home/zsh/default.nix
update(1): updates: 2, jobs: 7
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git show :0:home/zsh/default.nix
update(1): updates: 3, jobs: 8
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git show :0:home/zsh/default.nix
update(1): updates: 4, jobs: 9
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git show :0:home/zsh/default.nix
update(1): updates: 5, jobs: 10
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git blame --contents - -L 12,+1 --line-porcelain /home/ambroisie/git/nix-config/home/zsh/default.nix
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git blame --contents - -L 12,+1 --line-porcelain /home/ambroisie/git/nix-config/home/zsh/default.nix
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git blame --contents - -L 13,+1 --line-porcelain /home/ambroisie/git/nix-config/home/zsh/default.nix
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git show -s --format=%B 924200bacc950d3a90097fb4d3ba60ed65a8030b
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git show 8a1f94ff3f1213229c46c92428956643b555a1c0:home/zsh/default.nix
run_job: git --no-pager --git-dir=/home/ambroisie/git/nix-config/.git show 924200bacc950d3a90097fb4d3ba60ed65a8030b:home/zsh/default.nix
@ambroisie ambroisie added the bug Something isn't working label Mar 4, 2022
@lewis6991
Copy link
Owner

lewis6991 commented Mar 4, 2022

This does not look like a bug.

Looks more like bad config.

-- If removed, the bug disappears
vim.cmd([[
    augroup signtoggle
        autocmd!
        " Only show the sign column for the current focused buffer
        autocmd BufEnter,FocusGained,WinEnter * set signcolumn=yes
        autocmd BufLeave,FocusLost,WinLeave   * set signcolumn=no
        " Disable the sign column in terminal
        autocmd TermOpen * setlocal signcolumn=no
    augroup END
]])

This is your problem. When you focus on git-messengers window, you are disabling the sign column. This doesn't happen with gitsigns blame window since gitsigns doesn't change focus from the current buffer.

Anecdotally, I'm not sure how to make the diff prettier, I dislike how the blame window has full (background) highlighting of changed lines and would rather it show colored text.

All highlights in gitsigns are configurable. For the diff in the blame window GitSignsDeleteLn and GitSignsAddLn are used.

@ambroisie
Copy link
Author

This is your problem. When you focus on git-messengers window, you are disabling the sign column. This doesn't happen with gitsigns blame window since gitsigns doesn't change focus from the current buffer.

The focus should be re-acquired, and set signcolumn=yes executed, once I get out of the window though, shouldn't it?

All highlights in gitsigns are configurable. For the diff in the blame window GitSignsDeleteLn and GitSignsAddLn are used.

Thank you ❤️.

@lewis6991
Copy link
Owner

The focus should be re-acquired, and set signcolumn=yes executed, once I get out of the window though, shouldn't it?

Not if some plugin uses :noautocmd or sets 'eventignore' which git-messenger could be doing.

@ambroisie
Copy link
Author

Alright, thank you for your time, I think you can close this issue as this appears to be a git-messenger bug.

I hope you get around to implementing the missing functionality to allow the full transition to gitsigns.

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
Development

No branches or pull requests

2 participants