I'm not an expert on vim script, so this may not be the perfect solution, but this is what worked for me.
First, create a custom viewdoc handler in the file viewdoc_pman.vim (which can be found in the ~ / .vim / bundle / viewdoc / plugin / directory if you are using the recommended pathogen setting).
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 find the specified subject line in the yii-api-vim tag file. If he finds this, he simply redirects the command to the default ViewDoc_help handler (it is assumed that you have already installed the yii-api-vim documentation so that it works correctly with standard help).
If grep finds nothing, it returns to calling the old php handler in the ViewDoc_pman function. Note that we cannot just call g: ViewDoc_pman directly, as this is the variable we are going to overwrite. We need to get the descriptor of the old function using function('ViewDoc_pman') and call it 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 causes all php documentation requests to be redirected to our new custom handler, and not to the old ViewDoc_pman function.
If you do not want to edit the viewdoc_pman.vim file, you can put the viewdoc handler in your .vimrc file. Then, to set the g: ViewDoc_pman and g: ViewDoc_php variables, you 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')
autocmd VimEnter forces the assignments to be executed after all plugins have been loaded, otherwise these variables are simply overwritten by the plugin and your custom handler will never be called.