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

doesn't refresh signs after staging chunk #1127

Open
GopherJ opened this issue Sep 28, 2024 · 4 comments
Open

doesn't refresh signs after staging chunk #1127

GopherJ opened this issue Sep 28, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@GopherJ
Copy link

GopherJ commented Sep 28, 2024

Description

the signs remain there after StageChunk

Neovim version

NVIM v0.10.1 Build type: Debug LuaJIT 2.1.1713484068 Run "nvim -V1 -v" for more info

Operating system and version

ubuntu 22.04 (Linux Mint)

Expected behavior

signs should disapear

Actual behavior

signs doesn't disapear

	{
		"lewis6991/gitsigns.nvim",
		config = function()
			vim.cmd([[
      highlight clear GitSignsAdd
      highlight clear GitSignsChange
      highlight clear GitSignsDelete
      highlight clear GitSignsTopdelete
      highlight clear GitSignsChangedelete
      highlight clear GitSignsUntracked
    ]])

			vim.cmd([[
      highlight link GitSignsAdd GitGutterAdd
      highlight link GitSignsChange GitGutterChange
      highlight link GitSignsDelete GitGutterDelete
      highlight link GitSignsTopdelete GitGutterDelete
      highlight link GitSignsChangedelete GitGutterChange
    ]])

			require("gitsigns").setup({
				signs = {
					add = { text = "+" },
					change = { text = "~" },
					delete = { text = "_" },
					topdelete = { text = "‾" },
					changedelete = { text = "≃" },
				},
				signs_staged = {
					add = { text = "" },
					change = { text = "" },
					delete = { text = "" },
					topdelete = { text = "" },
					changedelete = { text = "" },
				},
				watch_gitdir = {
					interval = 100,
					follow_files = true,
				},
				update_debounce = 100,
				on_attach = function(bufnr)
					local gitsigns = require("gitsigns")

					local function map(mode, l, r, opts)
						opts = opts or {}
						opts.buffer = bufnr
						vim.keymap.set(mode, l, r, opts)
					end

					map("n", "++", gitsigns.stage_hunk)
					map("n", "__", gitsigns.reset_hunk)
					map("v", "++", function()
						gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
					end)
					map("v", "__", function()
						gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
					end)

					map("n", "gs", gitsigns.preview_hunk)
					map("n", "gb", function()
						gitsigns.blame_line({ full = true })
					end)

					map("n", ";j", function()
						if vim.wo.diff then
							vim.cmd.normal({ ";j", bang = true })
						else
							gitsigns.nav_hunk("next")
						end
					end)

					map("n", ";k", function()
						if vim.wo.diff then
							vim.cmd.normal({ ";k", bang = true })
						else
							gitsigns.nav_hunk("prev")
						end
					end)
				end,
			})
		end,
	},

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
} do
local install_path = vim.fn.fnamemodify('gitsigns_issue/'..name, ':p')
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
end
vim.opt.runtimepath:append(install_path)
end

require('gitsigns').setup{
 	{
		"lewis6991/gitsigns.nvim",
		config = function()
			vim.cmd([[
      highlight clear GitSignsAdd
      highlight clear GitSignsChange
      highlight clear GitSignsDelete
      highlight clear GitSignsTopdelete
      highlight clear GitSignsChangedelete
      highlight clear GitSignsUntracked
    ]])

			vim.cmd([[
      highlight link GitSignsAdd GitGutterAdd
      highlight link GitSignsChange GitGutterChange
      highlight link GitSignsDelete GitGutterDelete
      highlight link GitSignsTopdelete GitGutterDelete
      highlight link GitSignsChangedelete GitGutterChange
    ]])

			require("gitsigns").setup({
				signs = {
					add = { text = "+" },
					change = { text = "~" },
					delete = { text = "_" },
					topdelete = { text = "" },
					changedelete = { text = "" },
				},
				signs_staged = {
					add = { text = "" },
					change = { text = "" },
					delete = { text = "" },
					topdelete = { text = "" },
					changedelete = { text = "" },
				},
				watch_gitdir = {
					interval = 100,
					follow_files = true,
				},
				update_debounce = 100,
				on_attach = function(bufnr)
					local gitsigns = require("gitsigns")

					local function map(mode, l, r, opts)
						opts = opts or {}
						opts.buffer = bufnr
						vim.keymap.set(mode, l, r, opts)
					end

					map("n", "++", gitsigns.stage_hunk)
					map("n", "__", gitsigns.reset_hunk)
					map("v", "++", function()
						gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
					end)
					map("v", "__", function()
						gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
					end)

					map("n", "gs", gitsigns.preview_hunk)
					map("n", "gb", function()
						gitsigns.blame_line({ full = true })
					end)

					map("n", ";j", function()
						if vim.wo.diff then
							vim.cmd.normal({ ";j", bang = true })
						else
							gitsigns.nav_hunk("next")
						end
					end)

					map("n", ";k", function()
						if vim.wo.diff then
							vim.cmd.normal({ ";k", bang = true })
						else
							gitsigns.nav_hunk("prev")
						end
					end)
				end,
			})
		end,
	},

}

Steps to reproduce

  1. mkdir gitsigns_issue
  2. cd gitsigns_issue
  3. git init
  4. touch file
  5. git add file
  6. git commit -m 'initial commit'
  7. nvim --clean -u minimal.lua file
  8. ...

Gitsigns debug messages

No response

Gitsigns cache

No response

@GopherJ GopherJ added the bug Something isn't working label Sep 28, 2024
@GopherJ
Copy link
Author

GopherJ commented Sep 28, 2024

the file has already been staged but the sign remains there

@unisons
Copy link

unisons commented Oct 24, 2024

When adding the changes into stage in another terminal, the sign is not updated except the last current buffer.
When I moved to other buffer, the sign is still there (not updated)
Executing ":e" (reading the file again) is only the solution.

Repository owner deleted a comment from unisons Oct 24, 2024
@quantumsnowball
Copy link

I have a very similar problem to you.
I use lazygit plugin in neovim.
Sometimes when I stage and commit inside of lazygit, the stage or commit doesn't reflect in gitsigns.
I need to reload using :e, or need to run 'Gitsign reset_base' to reflect the changes.

@Quitlox
Copy link

Quitlox commented Nov 17, 2024

Be sure to use the most recent version of the plugin, i.e. the last commit on main. The last release (0.9.0) seems to have this issue.

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

4 participants