Mercurial > vim-gutentags
comparison autoload/gutentags/ctags.vim @ 173:2cf3fb66285b
Use absolute paths for `ctags` if the tags file is not local.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 21 Feb 2017 12:36:45 -0800 |
parents | 18df731b1563 |
children | 7b9c2f191e69 |
comparison
equal
deleted
inserted
replaced
172:02a94ff0db57 | 173:2cf3fb66285b |
---|---|
67 " these things. | 67 " these things. |
68 let l:prev_cwd = getcwd() | 68 let l:prev_cwd = getcwd() |
69 execute "chdir " . fnameescape(a:proj_dir) | 69 execute "chdir " . fnameescape(a:proj_dir) |
70 | 70 |
71 let l:tags_file_exists = filereadable(a:tags_file) | 71 let l:tags_file_exists = filereadable(a:tags_file) |
72 let l:tags_file_is_local = match(a:tags_file, '\v[/\\]') < 0 | |
72 | 73 |
73 if l:tags_file_exists && g:gutentags_ctags_check_tagfile | 74 if l:tags_file_exists && g:gutentags_ctags_check_tagfile |
74 let l:first_lines = readfile(a:tags_file, '', 1) | 75 let l:first_lines = readfile(a:tags_file, '', 1) |
75 if len(l:first_lines) == 0 || stridx(l:first_lines[0], '!_TAG_') != 0 | 76 if len(l:first_lines) == 0 || stridx(l:first_lines[0], '!_TAG_') != 0 |
76 call gutentags#throwerr( | 77 call gutentags#throwerr( |
79 \":GutentagsUpdate!.") | 80 \":GutentagsUpdate!.") |
80 return | 81 return |
81 endif | 82 endif |
82 endif | 83 endif |
83 | 84 |
84 if empty(g:gutentags_cache_dir) | 85 if empty(g:gutentags_cache_dir) && l:tags_file_is_local |
85 " If we don't use the cache directory, we can pass relative paths | 86 " If we don't use the cache directory, we can pass relative paths |
86 " around. | 87 " around. |
87 " | 88 " |
88 " Note that if we don't do this and pass a full path for the project | 89 " Note that if we don't do this and pass a full path for the project |
89 " root, some `ctags` implementations like Exhuberant Ctags can get | 90 " root, some `ctags` implementations like Exhuberant Ctags can get |
105 let l:cmd .= ' -e "' . s:get_ctags_executable(a:proj_dir) . '"' | 106 let l:cmd .= ' -e "' . s:get_ctags_executable(a:proj_dir) . '"' |
106 let l:cmd .= ' -t "' . l:actual_tags_file . '"' | 107 let l:cmd .= ' -t "' . l:actual_tags_file . '"' |
107 let l:cmd .= ' -p "' . l:actual_proj_dir . '"' | 108 let l:cmd .= ' -p "' . l:actual_proj_dir . '"' |
108 if a:write_mode == 0 && l:tags_file_exists | 109 if a:write_mode == 0 && l:tags_file_exists |
109 let l:cur_file_path = expand('%:p') | 110 let l:cur_file_path = expand('%:p') |
110 if empty(g:gutentags_cache_dir) | 111 if empty(g:gutentags_cache_dir) && l:tags_file_is_local |
111 let l:cur_file_path = fnamemodify(l:cur_file_path, ':.') | 112 let l:cur_file_path = fnamemodify(l:cur_file_path, ':.') |
112 endif | 113 endif |
113 let l:cmd .= ' -s "' . l:cur_file_path . '"' | 114 let l:cmd .= ' -s "' . l:cur_file_path . '"' |
114 else | 115 else |
115 let l:file_list_cmd = gutentags#get_project_file_list_cmd(l:actual_proj_dir) | 116 let l:file_list_cmd = gutentags#get_project_file_list_cmd(l:actual_proj_dir) |