Skip to content

Wiki root per relative project directory #78

@ZeroDragon

Description

@ZeroDragon

This is not an issue
First of all: Thanks for this awesome plugin.
I've been trying to replicate a default wiki per repository (project) and finally I was able to do it thanks to wiki.vim. It requires just a few conf lines in your .vimrc file

First create this little function

function! WikiRoot(local, root)
  let l:localDir = finddir(a:local, ';./')
  return !empty(l:localDir) ? l:localDir : a:root
endfunction

Then in your config set wiki_root as:

let g:wiki_root = WikiRoot('wiki', '~/myWiki')

Now whenever you enter into wiki mode (<leader>ww) It will look for a wiki directory in current relative directory and if it does not exists, it fallbacks to your home root wiki directory (myWiki in this case)

~/
  myWiki/
    index.wiki
  other/   <- open wiki here to load ~/other/wiki/index.wiki
    wiki/
      index.wiki
    more/ <- open wiki here to load ~/other/more/wiki/index.wiki
      wiki/
        index.wiki
  anotherDirectory/ <- open wiki here to load ~/myWiki/index.wiki
    nope

What does this do is look (recursively) from your working directory up untill / for a directory named as the first argument (in this case wiki) if it fails, it will fallback to the absolute path of your personal wiki directory.

Hope you like this hack/method :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions