Code Monkey home page Code Monkey logo

vimwiki-sync's Introduction

vimwiki-sync

This plugin:

  • automatically synchronize Vimwiki notes directory on Vimwiki startup and exit using Git.
  • it also synchronizes Task Warrior automatically
  • changed files are auto-committed.

Install

Use your Vim plugin manager, for example using Vundle, add this line to your .vimrc:

Plugin '[email protected]:michal-h21/vimwiki-sync.git'

vim-plug

Plug 'michal-h21/vimwiki-sync'

Usage

This plugin automatically commit changes in Vimwiki directories. You need to initialize Git repository in these directories by hand.

Vimwiki directories can be configured using these g:vimwiki_list variable in .vimrc, for example:

let g:vimwiki_list = [{'path':'$HOME/notes'}]

This configuration declares the $HOME/notes as Vimwiki directory. You can initialize Git directory using:

$ cd ~/notes
$ git init

You can add remote repository for your project. Vimwiki-sync will push all changes to your remote on Vim exit, and pull changes on Vimwiki startup.

$ git remote add origin [email protected]:username/repo.git 

Configuration

Git branch

By default, we push and pull from the current branch of the remove Git repository. You can set the g:vimwiki_sync_branch to select specific branch:

let g:vimwiki_sync_branch = "main"

Commit message

You can change the commig message using g:vimwiki_sync_commit_message variable. It uses the strftime function for the formatting, so it supports insertion of time stamps. The default value is following:

let g:vimwiki_sync_commit_message = 'Auto commit + push. %c'

Taskwiki support

Vimwiki-sync automatically synchronize Taskwiki using Taskwarrior. To disable it, set the following variable:

let g:sync_taskwarrior = 0

vimwiki-sync's People

Contributors

chickensoupwithrice avatar mattymay avatar michal-h21 avatar usmanity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vimwiki-sync's Issues

job_start is not available on neovim

I'm assuming this plugin is designed for vim and not neovim?

Neovim job control has jobstart and I've seen plugins that embed async.vim to provide a consistent API, although from skimming the plugin it looks like you aren't doing anything after spawning the jobs, so maybe just an alias to starting a job that supports either would work?

I may fiddle with this to see if I can get a working solution.

Vimwiki Diary

Since the command to add is simply git -C " . g:zettel_dir . " add . , it will only add files at the top level of the vimwiki. Vimwiki diaries by default live in the diary/ folder at the top level, and therefore do not get added. Would be great if this could be incorporated. It is an easy fix (probably including testing if a folder at diary_rel_path exists, then add everything in it. I can submit a PR if you want.

FR: Customizable commit messages

For those of us that use semantic commit to generate changelogs / keep track of things, it's often helpful to have template-able commits for sync operations

Minimal viable version can be achieved by just allowing people to include a prefix for the current commit message (e.g. chore: Auto commit...)

I don't have a lot of bandwidth atm, but can take this on in the semi-near future and PR

Don't push when in conflict

I have had a couple instances where there is a conflict on more than one file. So I open a file in vim, fix the conflict, and then close back to the cli. But then vimwiki-sync does a commit and push, which removes other files from conflict state by adding them, and then commits them even though they have the conflict markers in them.

Can you make it where it doesn't do anything if the branch is in conflict state?

User manual needed

Hi, sorry for noob questions/requests. Would you mind explaining how to use this plugin ? I installed it but I do not know how to use it ( I am new to Neovim). Thanks

Makes autocommits in every git repository

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

Added, but not committed

Reproduce

  1. Open a wiki file
  2. Edit that file
  3. :wq

Expected behavior

Commit the added file on nvim exit.

Neovim Information

% nvim -v
NVIM v0.7.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/x86_64-pc-linux-gnu-gcc -O2 -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/var/tmp/portage/app-editors/neovim-0.7.2/work/neovim-0.7.2_build/config -I/var/tmp/portage/app-editors/neovim-0.7.2/work/neovim-0.7.2/src -I/usr/include -I/var/tmp/portage/app-editors/neovim-0.7.2/work/neovim-0.7.2_build/src/nvim/auto -I/var/tmp/portage/app-editors/neovim-0.7.2/work/neovim-0.7.2_build/include
Compiled by portage@localhost

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "/etc/vim/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Additional Information

" ~/.config/nvim/init.vim
set 
  \ nu 
  \ nuw=5
  \ tgc 
  \ et 
  \ ea 
  \ noswf
  \ nohls 
  \ lz
  \ nowb
  \ smc=180
  \ wig=*.o,*.pyc,*pycache*
  \ nosmd
  \ nowrap
  \ vif=NONE
  \ ls=0
  \ nobk 
  \ noru
  \ bg=dark
  \ cb=unnamedplus
  \ ut=1000
  \ so=10
  \ shm=aIF
  \ ts=4
  \ sts=4
  \ sw=4
  \ fcs=eo  \ ut=1000
  \ so=10
  \ shm=aIF
  \ ts=4
  \ sts=4
  \ sw=4
  \ fcs=eob:\ ,


let g:vimwiki_list = [{
	\ 'path': '/home/nzv/.config/nvim/wiki',
	\ 'template_path': '~/.config/nvim/wiki/tpl',
	\ 'template_default': 'default',
	\ 'syntax': 'markdown',
	\ 'ext': '.md',
	\ 'path_html': '~/.cache/vimwiki_html',
	\ 'template_ext': '.tpl'
\}]

au FileType vimwiki 
    \ setl spell wrap nonu ch=2

" Easy buffer navigation
nn <C-J> <C-W><C-J>
nn <C-K> <C-W><C-K>
nn <C-L> <C-W><C-L>
nn <C-H> <C-W><C-H>

" Remove arrow keys in some modes
for key in [
    \  '<Down> <Nop>',
    \  '<Left> <Nop>',
    \ '<Right> <Nop>',
    \    '<Up> <Nop>',
\]
    for mod in ['no', 'no!', 'vn', 'ino', 'cno']
        exe mod key
    endfor
endfor

for p in [
    \ '2html_plugin',
    \ 'getscript',
    \ 'getscriptPlugin',
    \ 'gzip',
    \ 'logipat',
    \ 'matchparen',
    \ 'netrw',
    \ 'netrwFileHandlers',
    \ 'netrwPlugin',
    \ 'netrwSettings',
    \ 'rrhelper',
    \ 'spellfile_plugin',
    \ 'sql_completion',
    \ 'syntax_completion',
    \ 'tar',
    \ 'tarPlugin',
    \ 'vimball',
    \ 'vimballPlugin',
    \ 'zip',
    \ 'zipPlugin',
    \ 'vimsyn_embed',
\]
    exe 'let g:loaded_' . p . '= 1'
endfor

call plug#begin()
    Plug 'hashivim/vim-terraform'
    Plug 'weakish/rcshell.vim'
    Plug 'tpope/vim-commentary'
    Plug 'vimwiki/vimwiki'
    Plug 'tpope/vim-fugitive'
    Plug 'michal-h21/vimwiki-sync'
call plug#end()
syn enable | colo ocean

# cwd: /home/nzv/.config/nvim/wiki
% git remote show origin
* remote origin
  Fetch URL: [email protected]:nnzv/wiki.git
  Push  URL: [email protected]:nnzv/wiki.git
  HEAD branch: main
  Remote branch:
    main tracked
  Local ref configured for 'git push':
    main pushes to main (up to date)

Shell is assumed to be bash

When shell variable is not set to bash (fish in my case), the commit log message leaves just the date
string without expanding it.

It pushes but doesnt pull

Hi, thanks for the great work!

I have vimwiki on my linux-machine and on my macbook. To sync I use Gitlab.

When I manually push and pull it works ok, but when I use your plugin, it only pushes.

I start vimwiki within vim: ww

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.