Update 20150825: an improved of this now lives at http://code.arp242.net/helplink.vim. It has a number of improvements, and you can install it as a plugin :-)
I will leave the original since it's a lot simpler and might be more helpful to show how this can be done.
I've been using this function; it will (backwards) look for the first tag, and return that in Markdown link. It also puts in the clipboard...
So you can just use :help
from Vim, and when you want to link something use :echo Helplink()
.
" Make help link (markdown format)
" TODO: Find all tags, and let the user choose which one to use
fun! Helplink()
" Get the name of the tag, With help from:
" https://vi.stackexchange.com/questions/434/get-name-of-nearest-tag-to-the-cursor
if !search('\*\zs[^*]\+\*$', 'bW')
echoerr "No tag found"
endif
let l:line = getline('.')
let l:start = col('.') - 1
call search('\*', '', line('.'))
let l:len = col('.') - l:start - 1
let l:tagname = strpart(l:line, l:start, l:len)
" TODO: Also support Python 2 and maybe Ruby...
let l:tagname_esc = system('python3 -c "import sys, urllib.parse as p; empty=' . "''" . '; print(p.quote(sys.argv[1], safe=empty), end=empty)" ' . shellescape(b:tagname))
let l:file = split(expand('%'), '/')[-1]
let l:url = "http://vimhelp.appspot.com/" . l:file . ".html#" . l:tagname_esc
let l:md = '[`:help ' . l:tagname . '`](' . l:url . ')'
" Copy it to the clipboard
let @+ = l:md
return l:md
endfun
|:buffers|
. Anything inside|
's would be treated as a help tag. Not requiring the:help
keyword allows for more casual language.[help:topic]
would be nice, with a way to transform`:h [help::buffers]`
into:h :buffers
. But to automate it the doc hosting site needs to be reliable, like vimhelp probably is and this one that should be used for questions specific to Neovim. Maybe vi.SE could host some static files? :)