Author: Michael Klier
License: GPL
last Update: 2010-08-06
Download: dokuvimki.tgz
Github http://github.com/chimeric/dokuvimki
Donate:
DokuVimKi is a Vim plugin which allows you to edit wiki:DokuWiki pages of DokuWikis XML-RPC interface. It also does syntax highlighting for DokuWiki syntax.
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) 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.
:set syntax=dokuwiki when editing pages of a local wiki just put this in your ~/.vimrc to make VIM auto-detect DokuWiki files:" 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
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 your set and done you can launch DokuVimKi:
:DokuVimKi
For a detailed list of available commands please consult the dokuvimki help:
:help dokuvimki-commands
To speed up the editing you could add some aliases to your $SHELLrc1):
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.
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
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
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.
Hi Hugh,
thanks for the feedback
. First you need a really recent development snapshot of DokuWiki (either check it out via darcs or use at least the daily snapshot from yesterday
) because this plugin doesn't work this the XML-RPC interface of the current stable release. The devel version already provides a configuration option to enable the XML-RPC interface (no need to remove the die() call anymore).
I've also made some further modifications to the plugin and plan to release a new version later today. And please consider that both, this plugin and the XML-RPC interface of DokuWiki, are still in an experimental state
.
Hi, Michael,
Thanks for your quick reply. I have tried the snapshot from yesterday. It still doesn't work.
But I think I found the reason: There are some Chinese characters in the file name, which makes the XML-RPC don't work. I just renamed all the files in English.
This time it works. But if the Chinese characters can be recognized, that will be cool!
2008/03/05 16:47Hmmm, ok, I'll have to look into this limitation. Thanks for the feedback.
BTW: The double/triple comment submitting happens when you reload the page, but your browser still contains the post data of your comment and you hit OK
.
Ok, I have to re-schedule the next release of the plugin a couple of days. I made some additional changes to the XML-RPC interface of DokuWiki the plugin relies on. These changes aren't checked into DokuWikis main repository yet, because splitbrain is on vacation this week.
2008/03/05 23:21
Ok, there's a new version online. You'll need at least the DokuWiki devel snapshot from 2008-03-10 to use all commands. But I fear the issue with the Chinese characters is still unresolved. Just give me some more time. I am working on it .
![]()
Edit: I think it should be working now. I force vim to use utf-8 encoding, that should do the trick
. Would be great if you could give it a try and tell me if it's working for you now
.
Edit2: Hmmm, Chinese characters seem to lead to problems with :DWList, I'll have to do some further tests
.
I was able to resolve the :DWList issue in the latest version. Everything should now work as expect (in an UTF-8 environment).
Another nice feature would be some kind of namespace/file completation like you normaly can do by pressing:
^X ^F
May be I could help you a little bit.
2008/03/17 00:38Hi, Michael
I have tested the new version with Chinese characters, and I found there are still some problems:
1. :DWEdit can be used to create pages no matter when the Chinese characters exist in the pagename or page content. It works fine. But if you wanna edit a page that already exists, errors is report!
2. :DWList can be used to list pages when there are Chinsese characters in the page content, but it doesn't work when Chinese charactera are in the pagename.
3. After list the pages, if I use ENTER to edit one of the pages, error is report! So something is wrong with the dwListEdit() function. And I suppose this is the same problem as what I mentioned in the first item about :DWEdit. Right?
4. :DWList can list the pages, but not all of them, why? Have you tried that?
I wish I can help to improve the code, but I am a beginner in vim so that I can only do the testing job. Thank you!
Hi Hugh,
thanks for your feedback
, it's a great help. It seems I've overlooked a couple of things. I didn't occur to me yet that not all pages are listed with :DWList, but then, I have a lot of pages in my test Wiki, I might just overlooked this.
When I set autoconnect to false in .vimrc, and try to connect from vim with :DWAuth, i get no Connection (and no error message). Setting autoconnect to true in .vimrc works as expected …
The syntax-file has a bug. Try this one:
this is a URL: http://vimplugin.org this is more text
A workaround would be “skip”:
syn region DokuItalic start=#//# end=#//# skip=#http://# contains=DokuBold,DokuUnderlined,DokuLink oneline
But in fact one would need some kind of laziness for the regexes. No idea how to do that in vim syntax files.
Regards, Bastl.
found why DWAuth do not work
missing importing xmlrpclib
move the import xmlrpclib from the main to dwXMLRPCInit() just before xmlrpc = xmlrpclib.ServerProxy(URL)
Hello:
I have downloaded the last version of dokuvimki, and I got the following error messages:
Error detected while processing /home/jvillate/.vim/plugin/dokuvimki.vim: line 34: E319: Sorry, the command is not available in this version: python «EOF line 35: E488: Trailing characters: # -*- coding: utf-8 -*- line 37: E492: Not an editor command: version = '2008-04-19'; line 38: E492: Not an editor command: author = 'Michael Klier chi@chimeric.de' line 40: E492: Not an editor command: import sys, re, datetime, vim line 41: E492: Not an editor command: from urllib import urlencode line 44: E492: Not an editor command: def dwEdit(wp, rev=''): line 46: E492: Not an editor command: Edit a Wiki page, tries to fetch the page content beforehand if the page line 47: E492: Not an editor command: exists. The function requires a valid page name ie.: a:valid:pagename line 50: E121: Undefined variable: not E15: Invalid expression: not dwXMLRPCCheck(): return line 213: E133: :return not inside a function line 281: E133: :return not inside a function line 334: E133: :return not inside a function line 361: E133: :return not inside a function line 462: E133: :return not inside a function line 494: E133: :return not inside a function line 512: E133: :return not inside a function line 516: E133: :return not inside a function line 559: E171: Missing :endif Press ENTER or type command to continue
Best regards, Javier
Looks like the vim version you're running doesn't have python support enabled. Some distributions have different packages for that, for example for Debian it's vim-python.
2008/05/12 21:14I love this plugin, excellent work. The less I have to leave vim the better. For my local dokuwiki installation I use the color plugin. It's nice eyecandy to also have these highlighted in vim. Here's a diff to $VIMDIR/syntax/dokuwiki.vim that sets up the colors to match those indicated on the plugin page. Hope someone finds it useful.
oops! overlooked that other </code> tag well the actually diff file can be loaded here: http://www.webframp.com/files/syntax.dokuwiki.vim.diff
Hi,
hope you don't mind I removed the not working diff you've posted. But anyway, great work
!
Thanks! Glad you removed the old diff, no sense in having the b0rk'd stuff around.
the obvious limitation of my changes is that if you use the background color syntax it won't be highlighted. so for example:
<color red> this would be matched red in vim</color> <color red/black> this would not be matched at all</color>
If I have time to play with it and find a flexible solution I'll be sure to update, but in any case the link above should always work.
I love this idea and it will be much more comfortable to write wiki in vim than editing within webpage. However, my host provider godaddy add a javascript snippet to every php file. With a trailing javascript snippet, it seems that xmlrpc library just doesn't work with xml-rpc.php anymore. Is there a way to solve it? THanks! Maybe I should modify the code of xmlrpc library, but I am no expert of python or php…
2008/07/21 09:32Hi najj,
yes there's a way. Ask your provider to stop doing this, at least for <dokuwiki>/lib/exe/xmlrpc.php (I actually wonder that everything else like CSS/Javascript is working as expected).
Yeah the css.php also caused some trouble, and I had to force the css to be static in order to make it work as expected. (eyes rolling) I'll try to ask my host provider to stop this.
Thanks a lot for dokuvimki. It works as expected, but I ask me if it is possible to use a local template for wikipages which do not exist and put the filename into the first headline of the template?
2008/10/07 21:41
I have something like that on my todo list already. The XML-RPC backend of DokuWiki is changing heavily and should allow something like that without problems. Expect a new version of dokuvimki as soon as I am online again (just moved into a new flat and have no connection yet - so I can't work on it atm
).
I'm trying to use the plugin with Fedora Core 10 and “DokuWiki Release 2009-02-14” and am getting an error
“Traceback (most recent call last):
File "<string>", line 1, in <module> File "<string>", line 144, in dwList
NameError: global name 'xmlrpclib' is not defined”
though vim seems to connect without errors. From what I can tell vim has python support compiled in - any ideas what could be causing the problem?
Just to add, if I try to create a new page with DWEdit, it gives me an error of “e382: Cannot write, 'buftype' option is set”.
”:verbose setlocal buftype?” shows that my buftype is set to nofile.
Your error indicates that you don't have the python xmlrpclib module installed on your system.
However, atm I cannot guarantee that the plugin works because of changes of the XML-RPC backend on DokuWikis' side. I'm working on it, but it'll take some time.
2009/03/04 07:44I wondered if that might be the case but trying to import it in Python doesn't cause any errors.
Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38) [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2 Type “help”, “copyright”, “credits” or “license” for more information.
import xmlrpclib
I see, well then it's probably related to the changes in the DokuWiki XML-RPC backend and it doesn't work anymore
. However, as I said, I'm working on it, but due to time constraints I'm unable to give an exact ETA. I think maybe in two to three weeks from now I have an update ready.
Hey, I LOVE the idea of editing dokuwiki with vim!
I'm still young in the ways of vim, and have a question about installation… I use gvim on Vista. Does it support python out of the box? Or is there something that I have to install like this - http://www.python.org/download/windows/ ?
Also, where can I download the “xmlrpclib” module?
Thanks so much, and pardon my ignorance!
Walter
2009/03/07 03:36This is a great plugin. I've added a check for python support in vim. I just changed
python <<EOF
to
if has("python")
python <<PYTHONEOF
and then add
PYTHONEOF endif
to the very end of the file. Perhaps the next version coming out already has this?
Is the folowing error message because of a missing xmlrpclib python module or related to the changes in the DokuWiki XML-RPC backend?
—8←– Fehler beim Ausführen von ”/home/username/.vim/plugin/dokuvimki.vim”: Zeile 637: E121: Undefinierte Variable: g:DokuVimKi_AUTOCONNECT E15: ungültiger Ausdruck: g:DokuVimKi_AUTOCONNECT Traceback (most recent call last):
File "<string>", line 601, in <module>
vim.error: ungültiger Ausdruck Betätigen Sie die EINGABETASTE oder geben Sie einen Befehl ein —8←–
Thank you for all your efforts. Is there any news about next version? I really want to test it against my dokuwiki installation.
Meanwhile, I am obtaining benefits already combining “it's all text” firefox plugin with your syntax rules for vim and dokuwiki. However, as another one said before, it would be better if I could maintain myself inside vim environment
I also would like to ask what Walter did: Is it very difficult to install dokuvimki in a Vista environment? Would it be enough with a proper Python installation?
TIA
Juan
2009/04/08 19:23
This actually looks like a problem with your .vimrc, anyway, it doesn't make sense to try to fix this because DokuVimKi currently doesn't work with the latest DokuWiki version (I'm working on it).
Regarding the next version: I've managed to rip out all XML-RPC related python code and created a general purpose python-dokuwiki-xmlrpc module (which could be used with other programms as well). I'm now about to rewrite DokuVimKi to use this library (it's partly working already) and to apply the changes of the latest DokuWiki release. I really can't give a ETA right now as to when I'm finished, because I'm terribly busy, but I hope to be able to release a new version in the upcoming 3-5 weeks.
I've never tried it on Windows so I don't know how Vim and Python go together in this environment, but I believe it should be possible with a normal python install and telling vim where to find the python interpreter.
2009/04/09 08:58Well, thanks a lot for all your work, Michael. As soon as next version works, I'll betatest it. If you are interested, I could write a short tuto for installing dokuvimki in a windows environment
2009/04/09 14:51Hi,
Nice idea ! Congratulations.
Nevertheless I note a little bug : If I create a new page by <enter> on page a page like
page_category1:category2:page
is created (end thus also the corresponding directory)
Best Regards
Nadyl
(I work with gvim 7.2.79 under ubuntu 9.04 with dkuwiki 2008)
Holy Cow I wish this worked with the most recent version. It would be quite incredible!
You rock. I've had your blog in my rss reader eagerly awaiting a new release. This works beautifully! Thanks so much for writing it :)
Hi ! First of all thank You ! i've used your plugin to edit my wiki and all worked well :) ! But now … each time i try to execute :DokuVimKi i've got this error : Connection to wikiAddresse established! Traceback (most recent call last):
File "<string>", line 1, in <module> File "<string>", line 981, in dokuvimki File "<string>", line 65, in __init__ File "<string>", line 940, in __init__
IndexError: Ce tampon n'existe pas And i can not use the plugin anymore …
Any Idea ?
Regards
Mimiz
2010/08/22 23:33@mimiz: Hmmm, things don't usually stop working out of the blue. Did you change anything in between the last time it worked and the moment it stopped (i.e. updated your DokuWiki install, python, changed sth. on the server side etc.).?
2010/08/23 10:48@Michael Klier: Hi, no i did not change anything … The only thing that i remember is that the last time it worked, i had an error while i was exiting vi ('im not able to give you the exact error).
The error was about changes not saved, that's all i remember …
i did not change anything on the server side nor on my computer.
seems to be a buffer problem … but don't know why and how to reset this buffer …
regards mimiz
2010/08/23 10:56@mimiz: The error about unsaved changes only occurs if you didn't save all buffers yet, so that's perfectly normal. Does this happen with all pages? Did it stop after you added a page with a special character in the page name?
@Michael Klier: Ok for the error of unsaved pages. It stoped working after that error, and no all pages name are regular
mimiz
2010/08/23 14:39Hmm, okay, could you open a bug report at http://github.com/chimeric/dokuvimki/issues including as much information as you have (OS, python version, vim version, wiki version, installed plugins etc). So I can maybe reproduce your issue.
2010/08/24 09:35Hi ! I solved my problem … I had to empty file : ./.vim/.netrwhist then launch vi et do :confirm delete (and also :confirm bd) to empty buffers. Then restart vi (maybe not necessary) and then i'm able to connect again …
Hope that will help you ! regards
Mimiz
2010/08/26 22:16Hi ! I solved my problem … I had to empty file : ./.vim/.netrwhist then launch vi et do :confirm delete (and also :confirm bd) to empty buffers. Then restart vi (maybe not necessary) and then i'm able to connect again …
Hope that will help you ! regards
Mimiz
2010/08/26 22:33
This plugin rocks. I always wish to have such a plugin. But I met some troubles when I use it, and This is what I did: - Firstly, comment the die call in xmlrpc.php - Edit the ~/.vim/plugin/dokuvimki.vim, and insert the user, password and URL When I try to use :DWList, this is what I got from vim:
Trackback (most recent call last): File "<string>", line 1, in <module> File "<string>", line 67, in dwList TypeError: bad argument type for built-in operationI don't what I should do. I am a newbie, thank you:)