michal-h21 / vimwiki-sync

Automaticaly synchronize vimwiki at startup and exit using git
98 stars 25 forks source link

Makes autocommits in every git repository #4

Closed akademic closed 3 years ago

akademic commented 3 years ago

Hi. I have setup vim-zettel and vimwiki-sync. And it works.

But after a while I realized that I have autocommits in my working project. Not in zettelkasten directory.

After some investigation I have realized that function vimwiki#vars#get_wikilocal('path') always returns $HOME/vimwiki path.

This path is from default_wiki_settings variable in vimwiki plugin. And this path does not exist.

So when vimwiki-sync does pushd it does nothing and makes commit in current directory. Which is directory of my project.

Also I have realized that git_action executes on every save of every file I am editing.

Environment: I have Linux Debian 5.9.11-1 and VIM 8.2

michal-h21 commented 3 years ago

Thanks for the report. I've added code that tests if the opened file is placed in a directory known to Vimwiki. Does it fix your issue?

akademic commented 3 years ago

Thanks for fast reaction. But this fix does not work for me.

What I did:

  1. Update vimwiki-sync and ensure that I have fix
  2. mkdir /tmp/test && cd /tmp/test && git init .
  3. touch README.md && git add . & git commit -m 'initial commit'
  4. vim README.md, edit and save
  5. git log shows new autocommit messages
michal-h21 commented 3 years ago

Ah, it seems that Vimwiki creates temporary wiki in this case and adds it to the list of wiki paths, so the new code still thinks that it is normal Vimwiki directory. I've added test for temporary wikis, I hope it fixes this issue.

akademic commented 3 years ago

Now it works perfectly. Thanx!