ledger / vim-ledger

Vim plugin for Ledger
GNU General Public License v2.0
372 stars 55 forks source link

"Unknown option: NT" when running :Gdiff with vim-fugitive #115

Closed Flimm closed 3 years ago

Flimm commented 3 years ago

When I run :Gdiff from vim fugitive in order to see a diff in Git, I get this error:

Error detected while processing /home/flimm/.vim/pack/my-dotfiles/start/ledger/compiler/ledger.vim:
line   31:
E518: Unkown option: NT
Press ENTER or type command to continue

I've never experienced an error like this with Vim Fugitive, and the error mentions vim-ledger, so I'm pretty sure the bug is with vim-ledger.

I'm using hledger and I don't have a ledger binary installed. I'm using the latest version of vim-fugitive from the GitHub repo at the time of writing.

alerque commented 3 years ago

I use Fugitive litterally every day and :Gdiff together with Ledger for every penny that moves in my finances and I've never seen this error or anything like it. Can you still replicate this? Can you replicate it with a MWE with just these two plugins involved?

This ZSH script should do the heavy lifting to setup such an environment, but it works for me with both VIM and NeoVIM:

#!/usr/bin/env zsh
set -e

: ${1:=nvim}

mktemp -d | read TMPDIR
pwd | read WD
trap 'rm -rf $TMPDIR' EXIT SIGHUP SIGTERM

test -f fugitive.zip ||
    wget https://github.com/tpope/vim-fugitive/archive/master.zip -O fugitive.zip

test -f vim-ledger.zip ||
    wget https://github.com/ledger/vim-ledger/archive/master.zip -O vim-ledger.zip

cd $TMPDIR
unzip $WD/fugitive.zip
unzip $WD/vim-ledger.zip

git init

cat << LEDGER > test.ledger
2020-01-01 Person
  Expenses  \$6.00
  Cash
LEDGER

git add test.ledger
git commit -m "Original state"

sed -i -e 's/6/8/' test.ledger

cat << VIMRC | $1 -Nu /dev/stdin test.ledger "+Gdiff"
filetype off
set rtp+=vim-fugitive-master
set rtp+=vim-ledger-master
filetype plugin indent on
syntax enable
VIMRC
Flimm commented 3 years ago

Thanks for this response. It is helpful. I only rarely experience this issue any more. I wish I could say it's gone away completely but it hasn't. I experience it now maybe once a week. I'm not sure what is happening, but if I figure it out, I'll get back to you.