I'm not an expert on vim scripting, so this may not be an ideal solution, but this is what worked for me.
First create a custom viewdoc handler in the viewdoc_pman.vim file (which can be found in the ~/.vim/bundle/viewdoc/plugin/ directory if you are using the recommended pathogen installation).
function ViewDoc_pman_custom(topic, filetype, synid, ctx)
let l:tagpath = '/etc/vim/bundle/yii-api-vim/doc/tags'
let l:shell = printf('grep %s %s', shellescape(a:topic,1), l:tagpath)
let l:output = system(l:shell)
if !v:shell_error
return g:ViewDoc_help(a:topic, a:filetype, a:synid, a:ctx)
else
let l:ViewDoc_pman_old = function('ViewDoc_pman')
return l:ViewDoc_pman_old(a:topic, a:filetype, a:synid, a:ctx)
endif
endfunction
This function uses grep to look for the specified topic string in the yii-api-vim tags file. If it finds it there, it just forwards the command to the default ViewDoc_help handler (this is assuming you've already installed the yii-api-vim documentation so that it works correctly with the standard help).
If grep doesn't find anything, then it falls back to calling the old php handler in the ViewDoc_pman function. Note that we can't just call g:ViewDoc_pman directly since that is a variable that we are about to overwrite. We need to get a handle to the old function using function('ViewDoc_pman')
and call that instead.
Finally, you need to find these two lines:
let g:ViewDoc_pman = function('ViewDoc_pman')
let g:ViewDoc_php = function('ViewDoc_pman')
And replace them with these two:
let g:ViewDoc_pman = function('ViewDoc_pman_custom')
let g:ViewDoc_php = function('ViewDoc_pman_custom')
This forces all php documentation queries to be forwarded to our new custom handler rather than the old ViewDoc_pman function.
If you prefer not to edit the viewdoc_pman.vim file, you can put the viewdoc handler in your .vimrc file instead. Then to set the g:ViewDoc_pman and g:ViewDoc_php variables, you'll need to add the following lines:
autocmd VimEnter * let g:ViewDoc_pman = function('ViewDoc_pman_custom')
autocmd VimEnter * let g:ViewDoc_php = function('ViewDoc_pman_custom')
The autocmd VimEnter
forces the assignments to happen after all plugins have been loaded, otherwise those variables would just be overwritten by the plugin and your custom handler would never be called.