jupytext.vim icon indicating copy to clipboard operation
jupytext.vim copied to clipboard

Incompatible with fugitive, git-gutter, and git-signify

Open goerz opened this issue 5 years ago • 4 comments

This plugin does not play nice with various git-related plugins such as fugitive, gitgutter and signify.

For gitgutter, bogus signs are shown, based on the output of

git diff --no-color --no-ext-diff -U0 -- <ipynbfile>

Personally, I already use nbdime as a diff tool for notebooks, but its output is (obviously) not valid for jupytext. Probably, the only solution is to create a diff tool based on jupytext that is used in the context of git-gutter only. This would probably depend on https://github.com/airblade/vim-gitgutter/issues/568 as well.

Alternatively, one would probably want to just disable git-gutter for notebook files.

For signfiy, no signs are shown at all (presumably because it can detect that the generated patch is bogus?). In principle, the solution should be the same as for gitgutter, except that signfiy appears to be better set up to handle using a custom diff-tool for notebook files. However, that diff-tool would still need to exist.

The fugitive plugin appears simply inoperative (e.g. the Gdiff command is "not an editor command"). I'm not sure what it would take to fix this, but it seems like something that should be possible. For now, "inoperative" is a better place to be in than "broken".

goerz avatar Jan 07 '19 02:01 goerz

Related question on Stackoverflow: https://stackoverflow.com/questions/54068308/override-gitattributes-from-command-line

goerz avatar Jan 07 '19 03:01 goerz

A problem with git-gutter that will prevent this approach is the presence of --no-ext-diff in https://github.com/airblade/vim-gitgutter/blob/1d422b9f98194e38bc56e54192c9bc66d95c21f1/autoload/gitgutter/diff.vim#L135

Edit: actually, this can help in some way, as it disables the standard nbdime command, making place for a --textconv.

goerz avatar Jan 07 '19 08:01 goerz

In theory, assuming nbdime is installed, the following settings should make it work with git-gutter:

let g:gitgutter_git_args = "-c diff.jupyternotebook.textconv='jupytext --from=ipynb --to=md -o -'"
let g:gitgutter_diff_args = "--textconv"

Except that git-gutter tries to convert both the current buffer and the index to md, but this fails because the current buffer is already in md!

goerz avatar Jan 07 '19 08:01 goerz

I think the better solution might be, instead of opening and writing the ipnb as different to the buffer, you auto-open the equivalent .py etc. That's the desired VCed file anyway in most cases, and prevents accidentally overwriting the ipynb file.

BlueDrink9 avatar Apr 06 '20 00:04 BlueDrink9