Skip to content

Commit

Permalink
gtags support gutentags_file_list_cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
gou4shi1 committed Oct 6, 2020
1 parent 8840473 commit 39dc3ee
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
18 changes: 13 additions & 5 deletions autoload/gutentags/gtags_cscope.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ endif

" Gutentags Module Interface {{{

let s:runner_exe = gutentags#get_plat_file('update_gtags')
let s:added_db_files = {}

function! s:add_db(db_file) abort
Expand Down Expand Up @@ -77,18 +78,25 @@ function! gutentags#gtags_cscope#init(project_root) abort
endfunction

function! gutentags#gtags_cscope#generate(proj_dir, tags_file, gen_opts) abort
" gtags doesn't honour GTAGSDBPATH and GTAGSROOT, so PWD and dbpath
" have to be set
let l:db_path = fnamemodify(a:tags_file, ':p:h')
let l:cmd = [s:runner_exe]
let l:cmd += ['-e', '"' . g:gutentags_gtags_executable . '"']

let l:proj_options_file = a:proj_dir . '/' . g:gutentags_gtags_options_file
let l:file_list_cmd = gutentags#get_project_file_list_cmd(a:proj_dir)
if !empty(l:file_list_cmd)
let l:cmd += ['-L', '"' . l:file_list_cmd . '"']
endif

let l:cmd = ['"'.g:gutentags_gtags_executable.'"']
let l:proj_options_file = a:proj_dir . '/' . g:gutentags_gtags_options_file
if filereadable(l:proj_options_file)
let l:proj_options = readfile(l:proj_options_file)
let l:cmd += l:proj_options
endif

" gtags doesn't honour GTAGSDBPATH and GTAGSROOT, so PWD and dbpath
" have to be set
let l:db_path = fnamemodify(a:tags_file, ':p:h')
let l:cmd += ['--incremental', '"'.l:db_path.'"']

let l:cmd = gutentags#make_args(l:cmd)

call gutentags#trace("Running: " . string(l:cmd))
Expand Down
48 changes: 48 additions & 0 deletions plat/unix/update_gtags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

set -e

PROG_NAME=$0
GTAGS_EXE=gtags
FILE_LIST_CMD=

ShowUsage() {
echo "Usage:"
echo " $PROG_NAME <options>"
echo ""
echo " -e [exe=gtags]: The gtags executable to run."
echo " -L [cmd=]: The file list command to run."
echo ""
}

while [[ $# -ne 0 ]]; do
case "$1" in
-h)
ShowUsage
exit 0
;;
-e)
GTAGS_EXE=$2
shift 2
;;
-L)
FILE_LIST_CMD=$2
shift 2
;;
*)
GTAGS_ARGS="$GTAGS_ARGS $1"
shift
;;
esac
done

if [ -n "$FILE_LIST_CMD" ]; then
CMD="$FILE_LIST_CMD | $GTAGS_EXE -f- $GTAGS_ARGS"
else
CMD="$GTAGS_EXE $GTAGS_ARGS"
fi

echo "Running gtags:"
echo "$CMD"
eval "$CMD"
echo "Done."

0 comments on commit 39dc3ee

Please sign in to comment.