20

I have a few packages installed in my ~/.vim/pack/default/start directory, for example Tabular and Unicode. After starting up vim I can use these packages but cannot access their help information. Issuing helptags ~/.vim/pack/default/start/tabular.vim/doc doesn't resolve this; neither does helptags ALL.

I've been starting vim with the same session file (i.e. vim -S path/to/session.vim) for a few years. When I start vim without specifying a session file, I can access documentation for these packages. It would be nice to be able to keep my session and still access docs for packages but starting a new session is a usable workaround.

EDIT

Originally posted the below solution as an answer but for reasons unclear to me it was deleted. It's not optimal but it fixed my problem, unlike the only other posted answer.

I've been starting vim with the same session file (i.e. vim -S path/to/session.vim) for a few years. When I start vim without specifying a session file, I can access documentation for these packages. It would be nice to be able to keep my session and still access docs for packages but starting a new session is a usable workaround.

2 Answers 2

25

Using :helptags ALL should re-generate all helptags for all doc directories in runtimepath; which should include the ~/.vim/pack/default/start/* directories.

You will probably get an error similar to:

E152: Cannot open /usr/share/vim/vim81/doc/tags for writing

Which is safe to ignore. Vim will continue generating helptags after this error (check the output of :100verbose :helptags ALL if you don't believe me).

For adding packages in the opt directory as well, you can use (based on Peter Rincker's comment):

command! -nargs=0 -bar Helptags
    \  for p in glob('~/.vim/pack/bundle/opt/*', 1, 1)
    \|     exe 'packadd ' . fnamemodify(p, ':t')
    \| endfor
    \| helptags ALL
6
  • 2
    In case you want helptags for opt directories as well. command! -nargs=0 -bar Helptags for p in glob('~/.vim/pack/bundle/opt/*', 1, 1) | exe 'packadd '.fnamemodify(p, ':t') | endfor | helptags ALL This assumes a path of ~/.vim/pack/bundle Aug 29, 2018 at 17:28
  • Ah yes, I had forgotten that this excludes the opt directory. Amended the answer @PeterRincker; thanks! Aug 29, 2018 at 18:04
  • Whoops, forgot to mention that :helptags ALL didn't do anything. Still, if specifying the actual directory of the plugin also doesn't work, why would helptags ALL work?
    – intuited
    Sep 4, 2018 at 19:16
  • This answer worked for me! I did however get two errors: 151: No match: /home/user/.vim/doc/** and E151: No match: /usr/share/vim/vimfiles/after/doc/**. I imagine it's because those are empty or don't exist?
    – FilBot3
    Jun 3, 2020 at 13:02
  • I noticed that my /usr/share/vim/vim81/doc/tags and /usr/share/vim/vim81/pack/dist/opt/matchit/doc/tags are owned by root. Could this explain why it can't get updated? Jul 13, 2020 at 4:27
1

:helptags ALL should work in most cases. But may not work or not be desirable in the following scenarios

  1. When the package path is readonly. This is usually the case when the actual package is in a shared network drive and is symlinked i.e ln -snf /shared/readonly/path/vim-package ~/.vim/pack/default/start/vim-package
  2. When the package is a git repo which does not ignore 'tags' and you don't want to add 'tags' to global gitignore file. It may not be desirable to add the tags file to actual repo where it will show as un-tracked file

For the above cases, use the following bash function.

    updatevimhelptags () {
            mkdir -p ~/.vim/doc
            pushd ~/.vim/doc
            for ppath in ../pack/*/*/*
            do
                    ln -snf "$ppath/doc" "$(basename "$ppath")"
            done
            vim "+helptags ~/.vim/doc | q"
            popd
    }

This is similar to this answer. The problem with the linked answer is that the helptags tries to generate tags for all *txt files in a package. Only the txt files under doc/ should be considered as vim's help files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.