vim-gutentags icon indicating copy to clipboard operation
vim-gutentags copied to clipboard

Expand documentation for g:gutentags_project_info

Open hovissimo opened this issue 4 years ago • 2 comments

I'm trying to configure gutentags for a project with both Ruby and Javascript ES6+ source and I'm can't make it work. I don't think there's an actual bug, but the documentation for g:gutentags_project_info isn't making sense to me and I think this is where my problem is.

Scenario: I'm using exuberant ctags on Ubuntu. I'm trying to use this setup to generate tags for the JS files: https://github.com/romainl/ctags-patterns-for-javascript The out-of-the-box Ruby tag generation seems fine.

I have a shell alias: alias ctags_js="ctags --options="$HOME/.ctags_js" which uses romainl's options. When I run ctags_js -f - /path/to/my/file.js I see good tags and when I run ctags -f - /path/to/my/file.js I see mostly worthless tags so I think my alias/config trick is working. (I feel like there should be a way to specify a ctags option file per language, but if there is I don't understand how to do it.)

In my .vimrc I have:

call add(g:gutentags_project_info, { "type": "javascript", "glob": "frontend/*" })
let g:gutentags_ctags_executable_javascript='ctags_js'
let g:gutentags_trace = 1

When I run :GutentagsUpdate I see:

gutentags: Running: ['/home/hovis/[REDACTED]/dotfiles/vimfiles/plugged/vim-gutentags/plat/unix/update_tags.sh', '-e', 'ctags', '-t', 'tags', '-p', '.', '-s', 'frontend/admin/js/grid/components/bulk_update.js', '-o', '/home/hovis/[REDACTED]/dotfiles/vimfiles/plugged/vim-gutentags/res/ctags_recursive.o
ptions', '-x', '*.swp', '-x', '*.pdf', '-x', '*.pyo', '-x', '*.pyc', '-x', '*.zip', '-x', '*.so', '-x', '*.dll', '-x', '*.o', '-x', '*.DS_Store', '-x', '*.obj', '-x', '*.bak', '-x', '*.exe', '-x', '*.jpg', '-x', '*.gif', '-x', '*.png', '-x', '*.a', '-x', '*node_modules/*', '-x', '*public/webpack/*', '-x', '*public/ass
ets/*', '-x', '*public*images/*', '-x', '*public/www/*', '-x', '*coverage/*', '-x', 'config.ru', '-x', '*_BACKUP_*', '-x', '*_BASE_*', '-x', '*_LOCAL_*', '-x', '*_REMOTE_*', '-x', '*/log/*', '-x', '*tmp/*', '-x', '*vendor/*', '-x', '*/.git/*', '-x', '*/.hg/*', '-x', '*/.svn/*', '-x', '*/bin/*', '-x', '*/pkg/*', '-l',
'tags.log']
gutentags: Finished ctags job.

I assume that '-e', 'ctags' means that it's using ctags and not ctags_js like I expected. I think this is my issue and that I'm not adding to g:gutentags_project_info correctly.

hovissimo avatar Dec 16 '19 20:12 hovissimo

I was also trying to find a way to do something like :echo gutentags#show_file_info("path/to/file.js") and have it spit out details like what project it thinks this file belongs to and what language it's configured to use. I don't think this is implemented though.

hovissimo avatar Dec 16 '19 20:12 hovissimo

This works fine for me:

let g:gutentags_project_info = []
call add(g:gutentags_project_info, { "type": "javascript", "glob": "frontend/*" })
let g:gutentags_ctags_executable_javascript='ctags_js'

When you open a file in your project, and if gutentags_trace is enabled, you should see something like:

gutentags: Scanning buffer '<file>' for gutentags setup...
gutentags: Setting project type to javascript

If you don't see it reporting that it detected a javascript project, you're probably not opening a file from a project whose root directory contains a frontend/ directory.

Note that this will mean gutentags will use ctags_js for all files in that project -- including the Ruby files. I'm not quite sure how to handle different ctags for different parts of a given project (without making it 2 projects), or even if that makes sense.

ludovicchabant avatar Feb 05 '20 07:02 ludovicchabant