Git Product home page Git Product logo

vimwiki-git's Introduction

Vimwiki dir in a git repo

Contents

  1. General Flow
  2. Current limitations and specific
  3. Installation and setup
  4. Sample vimwiki config

If you use vim as your general editor, then vimwiki could be a great personal, or even public wiki tool for you.

Although vimwiki is great to use on a single machine, it would be better to have your wiki available on any machine or environment you work on. This is not supported out of the box by vimwiki, but since the wiki files and data are plain text files kept in disk based directories, making your wiki available anywhere you go is simply a git repo away.

The ideas here are not all my own, so many thanks to Mark Dennehy, Jarvist Moore Frost, Daniel Moerner, Manuel Dewald and some others for the ideas and inspiration.

General Flow

  1. Initialize a git repo inside your ~/vimwiki directory, and add some remote that you have acces to from other machines like a a Gitub, GitLab, Bitbucket, etc. repo.
  2. Whenever the main wiki index file is opened with vimwiki, we want to automatically do a git pull in the wiki directory to ensure we have the latest content from the remote. Opening the main index file will always take a bit longer due to this.
  3. Whenever a file in the wiki changes, we want to:
    • add it to the git index
    • do a commit with a preset commit message
    • push the repo to the remote

This vim plugin does the above by adding additional vim auto commands for opening the main wiki index, and writing any wiki files inside the wiki dir.

Current limitations and specific

I'm not very familiar with vimscript so for now this plugin is fairly much hardcoded for my environment, specifically:

  • I use vimwiki's markdown format for my wiki files, and specifically, I link my wiki to a GitLab wiki repo, similar to what Manuel Dewald describes on his page. This gives me the best of both world as far being able to use markdown, and also having my wiki directly abvailable and editable as both a GitLab and local vim wiki.
    Since GitLab's main wiki entry page is called home instead of index like for vimwiki, I change my vimwiki setup to make my index page be called home, and this plugin is also hardcoded for that name.
  • My wiki dir is the default ~/vimwiki and this is also harcoded in the plugin.

Since both the vimwiki index name and installation dir is avaialble from the vimwiki config, this plugin should in theory be able to pick it up from there without having to hardcode these values. Unfortunately, my knowledge of is vimscript does not yet cover how to do this. Please feel free to send me a PR with these changes if you know how to do it.

Installation and setup

  1. Make sure you have vimwiki installed using your favourite vim plugin manager.
  2. Configure vimwiki as per the docs. See my sample vimwiki config for ideas.
  3. Manually create your vimwiki base dir as per your vimwiki setup.
  4. Initialize a git repo in this dir, add a remote and make sure you can push/pull to the remote. As a simple test, add a .gitignore to ignore any vim swap files, add this to the repo and push.
  5. Install this plugin using your favourite vim plugin manager.
  6. Restart vim and press \ww or \wt to open the wiki index. You should see a pause as a git pull is done. When saving any file in the wiki, you should see it add, commit and push the change. I have purposefully not made the git commands silent since I prefer to see them work than fail silently without notice. Change this if you prefer.

Sample vimwiki config

This is a sample of my vimwiki config:

" Setup for vimwiki
"
" This file should be sourced from your .vimrc
"
"
" Set or override all/any options for personal wiki.
let wiki = {
\           'path': '~/vimwiki/',
\           'path_html': '~/vimwiki/HTML/',
\           'auto_export': 0,
\           'index': 'home',
\           'syntax': 'markdown',
\           'ext': '.md',
\           'auto_toc': 1,
\           'maxhi': 1,
\           'nested_syntaxes': {'python': 'python', 'js': 'javascript', 'c++': 'cpp'},
\           'list_margin': -1
\           }

" Make wiki the default vimwiki setup
let g:vimwiki_list = [wiki]
" When opening a directory containing a file with this name and default wiki
" extention, assume it is a vimwiki
let g:vimwiki_dir_link = ''
" Only treat .md files under a path in vimwiki_list as wiki files
let g:vimwiki_global_ext = 0

vimwiki-git's People

Contributors

audente avatar fitzterra avatar rwhutchison avatar

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.