lewis6991 / gitsigns.nvim

Git integration for buffers
MIT License
5.13k stars 192 forks source link

Signs fail to parse if using an external diffing tool #724

Closed chrisnojima closed 1 year ago

chrisnojima commented 1 year ago

Description

I use this external viewer for diffs https://github.com/Wilfred/difftastic and have it setup in my gitconfig as a global external differ tool with

[diff]
     external = difft
     tool = difftastic

I assume the different format of the diff isn't parsable so it fails to show the signs. I think it would be safe to just git diff --no-ext-diff always , but if not it'd be nice to be able to override the diff command

Neovim version

0.8.2

Operating system and version

macOS 13.1

Expected behavior

Signs show up on a diff

Actual behavior

No signs show up. It took a few for me to figure out what was going on

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
  -- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
}

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

Steps to reproduce

  1. Setup any external diff viewer (i use https://github.com/Wilfred/difftastic)
  2. Setup your gitconfig as above
  3. Try and get signs to show
  4. Comment out gitconfig diff section
  5. Signs now show

Gitsigns debug messages

No response

lewis6991 commented 1 year ago

Difftastic does not support patch formats:

Patching. Difftastic output is intended for human consumption, and it does not generate patches that you can apply later. Use diff if you need a patch.

So by design, it is unable to work with other tools, including GitSigns.

lewis6991 commented 1 year ago

I think it would be safe to just git diff --no-ext-diff always , but if not it'd be nice to be able to override the diff command

Sorry, missed this.

chrisnojima commented 1 year ago

Yes, i'm not asking to have it work. i'm asking to disable this tool

lewis6991 commented 1 year ago

Do you not have internal set in set dittopt?

chrisnojima commented 1 year ago

I'm using lunarvims setup with the defaults https://github.com/LunarVim/LunarVim/blob/master/lua/lvim/core/gitsigns.lua

lewis6991 commented 1 year ago

What does :set diffopt? show?

chrisnojima commented 1 year ago

diffopt=vertical

chrisnojima commented 1 year ago

setting internal fixes it, tnx!

lewis6991 commented 1 year ago

internal is apart of the default value of diffopt. I suggest in your config to have either:

set diffopt+=vertical

or

vim.opt.diffopt:append('veritcal')

My personal setting is:

  vim.opt.diffopt:append{
    'linematch:50',  -- needs neovim nightly
    'vertical',
    'foldcolumn:0',
    'indent-heuristic',
  }
chrisnojima commented 1 year ago

cool thanks for the info, really appreciate the plugin!