Giter VIP home page Giter VIP logo

dokuvimki's Introduction

Description

DokuVimKi is a Vim plugin which allows you to edit DokuWiki pages via DokuWikis XML-RPC interface. It also does syntax highlighting for DokuWiki syntax.

Installation

The recommended way to install DokuVimKi is via a Vim plugin manager like vim-plug or pathogen.vim.

For vim-plug, add the following to the vim-plug section of your ~/.vimrc, which enables the DokuVimKi plugin only when first connecting to a DokuWiki:

Plug 'kynan/dokuvimki', {'on': 'DokuVimKi'}

For pathogen.vim, simply run the following:

cd ~/.vim/bundle
git clone git://github.com/kynan/dokuvimki

Alternatively, just download it and unpack it in ~/.vim/. You also have to make sure that vim is compiled with python support (should be the case for most distributions e.g. vim-gnome or vim-gtk on Debian/Ubuntu) and that you have the xmlrpclib and dokuwikixmlrpc python modules installed. You'll also have to install a recent development version of DokuWiki itself in order to use this plugin! For details on how to setup XMLRPC for DokuWiki please refer to config:xmlrpc.

If you want to enable syntax highlighting without issuing :set syntax=dokuwiki when editing pages of a local wiki just put this in your ~/.vimrc to make VIM auto-detect DokuWiki files (this is not required for editing remote wikis via DWedit):

" looks for DokuWiki headlines in the first 20 lines
" of the current buffer
fun IsDokuWiki()
  if match(getline(1,20),'^ \=\(=\{2,6}\).\+\1 *$') >= 0
    set textwidth=0
    set wrap
    set linebreak
    set filetype=dokuwiki
  endif
endfun

" check for dokuwiki syntax
autocmd BufWinEnter *.txt call IsDokuWiki()

syntax on

Configuration

To configure the plugin just add the following to your ~/.vimrc and change the values to your needs.

" user name with which you want to login at the remote wiki
let g:DokuVimKi_USER = 'username'

" password
let g:DokuVimKi_PASS = 'password'

" url of the remote wiki (without trailing '/')
let g:DokuVimKi_URL  = 'https://yourwikidomain.org'

" width of the index window (optional, defaults to 30)
let g:DokuVimKi_INDEX_WINWIDTH = 40

" set a default summary for :w (optional, defaults to [xmlrpc dokuvimki edit])
let g:DokuVimKi_DEFAULT_SUM = 'fancy default summary'

Once you are set and done you can launch DokuVimKi:

:DokuVimKi

Commands

For a detailed list of available commands please consult the dokuvimki help:

:help dokuvimki-commands

Tips

Shell aliases

To speed up the editing you could add some aliases to your $SHELLrc:

alias vidoku='viDokuVimKi() { vim +DokuVimKi +"DWedit $1" }; viDokuVimKi'
alias gvidoku='gviDokuVimKi() { gvim +DokuVimKi +"DWedit $1" }; gviDokuVimKi'

Usage example:

vidoku playground:DokuVimKi

This will create a DokuVimKi document within the playground namespace.

Outsource DokuVimKi Configuration

A good idea is to outsource your DokuVimKi configuration. To do so, store your settings in a seperate file like ~/.vim/dokuvimkirc. You can increase security be setting the file permission properly

chmod 600 ~/.vim/dokuvimkirc

To include this file in your ~/.vimrc use following code:

" Include DokuVimKi Configuration
if filereadable($HOME."/.vim/dokuvimkirc")
  source $HOME/.vim/dokuvimkirc
endif

Create separate aliases for different dokuwikis

One way of keeping your .vimrc lean and mean is to avoid loading dokuvimki specific configuration file unless you want to edit the wiki, while retaining all your other .vimrc magic. To do this simply create a separate configuration directory called ~/.dokuwiki which should contain mywiki.vim:

source ~/.dokuwiki/macros_dokuvimki.vim
let g:DokuVimKi_USER = 'mywikiuser'
let g:DokuVimKi_PASS = 'mywikipassword'
let g:DokuVimKi_URL  = 'http://mywiki.org'
source ~/.dokuwiki/dokuvimki.vim

The last bit displays the list of wiki pages by default. Then you are free to define a custom macros_dokuvimki.vim that applies to all your dokuwiki vim bindings:

" ensures you retain your normal .vimrc magic
source ~/.vimrc
" remap save commands for convenience
nmap <S-z><S-z> :DWsave<CR>

" looks for DokuWiki headlines in the first 20 lines
" of the current buffer
fun IsDokuWiki()
   if match(getline(1,20),'^ \=\(=\{2,6}\).\+\1 *$') >= 0
      set textwidth=0
      set wrap
      set linebreak
      set filetype=dokuwiki
   endif
endfun

" check for dokuwiki syntax
autocmd BufWinEnter *.txt call IsDokuWiki()

"Authentication has been moved to "~/.dokuwiki/mywiki.vim" specific files

" optional Cursorline, I feel makes editing a bit easier on the eye
"highlight CursorLine guibg=lightgreen cterm=bold ctermbg=17

Invoking dokuvimki via shell alias

Set a distinct alias in your bash shell (usually your ~/.bashrc file) to edit mywiki using dokuvimki:

alias vidmywiki='vi -u ~/.dokuwiki/mywiki.vim

Now all you need to do on your bash shell prompt is issue:

vidmywiki

and you'll be automatically authenticated into mywiki while retaining all dokuvimki specific settings within macros_dokuvim.vim for sharing amongst all your dokuwikis. All you have to do is copy the contents of mywiki.vim to mywiki2.vim, edit the credentials and create a matching new alias for mywiki2.vim invocation.

Changelog

dokuvimki's People

Contributors

kepi avatar kynan avatar peizh avatar

Watchers

 avatar  avatar  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.