Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve gtags usage #339

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion autoload/gutentags.vim
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function! gutentags#setup_gutentags() abort
if g:gutentags_generate_on_missing && !filereadable(l:tagfile)
call gutentags#trace("Generating missing tags file: " . l:tagfile)
call s:update_tags(l:bn, module, 1, 1)
elseif g:gutentags_generate_on_new
elseif g:gutentags_generate_on_new && !filereadable(l:tagfile)
call gutentags#trace("Generating tags file: " . l:tagfile)
call s:update_tags(l:bn, module, 1, 1)
endif
Expand Down Expand Up @@ -564,6 +564,7 @@ function! s:update_tags(bufno, module, write_mode, queue_mode) abort
\[l:proj_dir, l:tags_file,
\ {
\ 'write_mode': a:write_mode,
\ 'file': expand('#'.a:bufno.':p'),
\ }])
catch /^gutentags\:/
echom "Error while generating ".a:module." file:"
Expand Down
12 changes: 12 additions & 0 deletions autoload/gutentags/gtags_cscope.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ if !exists('g:gutentags_gtags_cscope_executable')
let g:gutentags_gtags_cscope_executable = 'gtags-cscope'
endif

if !exists('g:gutentags_gtags_skip_symlink')
let g:gutentags_gtags_skip_symlink = 'a'
endif

if !exists('g:gutentags_auto_add_gtags_cscope')
let g:gutentags_auto_add_gtags_cscope = 1
endif
Expand Down Expand Up @@ -78,6 +82,8 @@ function! gutentags#gtags_cscope#init(project_root) abort
endfunction

function! gutentags#gtags_cscope#generate(proj_dir, tags_file, gen_opts) abort
let l:write_mode = a:gen_opts['write_mode']

let l:cmd = [s:runner_exe]
let l:cmd += ['-e', '"' . g:gutentags_gtags_executable . '"']

Expand All @@ -97,6 +103,12 @@ function! gutentags#gtags_cscope#generate(proj_dir, tags_file, gen_opts) abort
let l:db_path = fnamemodify(a:tags_file, ':p:h')
let l:cmd += ['--incremental', '"'.l:db_path.'"']

if g:gutentags_gtags_skip_symlink != ''
let l:cmd += ['--skip-symlink='.g:gutentags_gtags_skip_symlink]
endif
if l:write_mode == 0 && has_key(a:gen_opts, 'file')
let l:cmd += ['--single-update', '"'.a:gen_opts['file'].'"']
endif
let l:cmd = gutentags#make_args(l:cmd)

call gutentags#trace("Running: " . string(l:cmd))
Expand Down
9 changes: 9 additions & 0 deletions doc/gutentags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,15 @@ g:gutentags_gtags_cscope_executable
executable to use to generate the code database.
Defaults to `"gtags-cscope"`.

*gutentags_gtags_skip_symlink*
g:gutentags_gtags_skip_symlink
When set to `""`, Gutentags will remove --skip-symlink
flag in gtags generation command, options:
- 'a' then skip all symbolic links
- 'f' then skip only symbolic links for file
- 'd' then skip only symbolic links for directory.
Defaults to `"a"`.

*gutentags_gtags_dbpath*
g:gutentags_gtags_dbpath
Path from the cache directory (|gutentags_cache_dir|
Expand Down