Mercurial > vim-gutentags
comparison autoload/gutentags/ctags.vim @ 165:cbc1ebe23ef1
Rename all ctags-related options to have "ctags" in their name.
Add some stuff to handle old options so it doesn't break everybody.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 18 Feb 2017 18:21:35 -0800 |
parents | 1b980f5071a0 |
children | 34c57ad6eb45 |
comparison
equal
deleted
inserted
replaced
164:28d4dae03f2a | 165:cbc1ebe23ef1 |
---|---|
1 " Ctags module for Gutentags | 1 " Ctags module for Gutentags |
2 | 2 |
3 " Global Options {{{ | 3 " Global Options {{{ |
4 | 4 |
5 let g:gutentags_ctags_executable = get(g:, 'gutentags_ctags_executable', 'ctags') | 5 let g:gutentags_ctags_executable = get(g:, 'gutentags_ctags_executable', 'ctags') |
6 let g:gutentags_tagfile = get(g:, 'gutentags_tagfile', 'tags') | 6 let g:gutentags_ctags_tagfile = get(g:, 'gutentags_ctags_tagfile', 'tags') |
7 let g:gutentags_auto_set_tags = get(g:, 'gutentags_auto_set_tags', 1) | 7 let g:gutentags_ctags_auto_set_tags = get(g:, 'gutentags_ctags_auto_set_tags', 1) |
8 | |
8 let g:gutentags_ctags_options_file = get(g:, 'gutentags_ctags_options_file', '.gutctags') | 9 let g:gutentags_ctags_options_file = get(g:, 'gutentags_ctags_options_file', '.gutctags') |
9 let g:gutentags_ctags_check_tagfile = get(g:, 'gutentags_ctags_check_tagfile', 0) | 10 let g:gutentags_ctags_check_tagfile = get(g:, 'gutentags_ctags_check_tagfile', 0) |
10 let g:gutentags_ctags_extra_args = get(g:, 'gutentags_ctags_extra_args', []) | 11 let g:gutentags_ctags_extra_args = get(g:, 'gutentags_ctags_extra_args', []) |
11 let g:gutentags_ctags_post_process_cmd = get(g:, 'gutentags_ctags_post_process_cmd', '') | 12 let g:gutentags_ctags_post_process_cmd = get(g:, 'gutentags_ctags_post_process_cmd', '') |
12 | 13 |
14 let g:gutentags_ctags_exclude = get(g:, 'gutentags_ctags_exclude', []) | |
15 let g:gutentags_ctags_exclude_wildignore = get(g:, 'gutentags_ctags_exclude_wildignore', 1) | |
16 | |
17 " Backwards compatibility. | |
18 function! s:_handleOldOptions() abort | |
19 let l:renamed_options = { | |
20 \'gutentags_exclude': 'gutentags_ctags_exclude', | |
21 \'gutentags_tagfile': 'gutentags_ctags_tagfile', | |
22 \'gutentags_auto_set_tags': 'gutentags_ctags_auto_set_tags' | |
23 \} | |
24 for key in keys(l:renamed_options) | |
25 if exists('g:'.key) | |
26 let newname = l:renamed_options[key] | |
27 echom "gutentags: Option 'g:'".key." has been renamed to ". | |
28 \"'g:'".newname." Please update your vimrc." | |
29 let g:[newname] = g:[key] | |
30 endif | |
31 endfor | |
32 endfunction | |
33 call s:_handleOldOptions() | |
13 " }}} | 34 " }}} |
14 | 35 |
15 " Gutentags Module Interface {{{ | 36 " Gutentags Module Interface {{{ |
16 | 37 |
17 let s:runner_exe = gutentags#get_plat_file('update_tags') | 38 let s:runner_exe = gutentags#get_plat_file('update_tags') |
18 let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s' | 39 let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s' |
19 | 40 |
20 function! gutentags#ctags#init(project_root) abort | 41 function! gutentags#ctags#init(project_root) abort |
21 " Figure out the path to the tags file. | 42 " Figure out the path to the tags file. |
22 let l:tagfile = getbufvar("", 'gutentags_tagfile', g:gutentags_tagfile) | 43 " Check the old name for this option, too, before falling back to the |
44 " globally defined name. | |
45 let l:tagfile = getbufvar("", 'gutentags_ctags_tagfile', | |
46 \getbufvar("", 'gutentags_tagfile', | |
47 \g:gutentags_ctags_tagfile)) | |
23 let b:gutentags_files['ctags'] = gutentags#get_cachefile( | 48 let b:gutentags_files['ctags'] = gutentags#get_cachefile( |
24 \a:project_root, l:tagfile) | 49 \a:project_root, l:tagfile) |
25 | 50 |
26 " Set the tags file for Vim to use. | 51 " Set the tags file for Vim to use. |
27 if g:gutentags_auto_set_tags | 52 if g:gutentags_ctags_auto_set_tags |
28 execute 'setlocal tags^=' . fnameescape(b:gutentags_files['ctags']) | 53 execute 'setlocal tags^=' . fnameescape(b:gutentags_files['ctags']) |
29 endif | 54 endif |
30 | 55 |
31 " Check if the ctags executable exists. | 56 " Check if the ctags executable exists. |
32 if g:gutentags_enabled && executable(expand(g:gutentags_ctags_executable, 1)) == 0 | 57 if g:gutentags_enabled && executable(expand(g:gutentags_ctags_executable, 1)) == 0 |
62 " and we are already `chdir`'d into it. | 87 " and we are already `chdir`'d into it. |
63 " Note that if we don't do this and pass a full path, `ctags` gets | 88 " Note that if we don't do this and pass a full path, `ctags` gets |
64 " confused if the paths have spaces -- but not if you're *in* the | 89 " confused if the paths have spaces -- but not if you're *in* the |
65 " root directory. | 90 " root directory. |
66 let l:actual_proj_dir = '.' | 91 let l:actual_proj_dir = '.' |
67 let l:actual_tags_file = g:gutentags_tagfile | 92 let l:actual_tags_file = g:gutentags_ctags_tagfile |
68 else | 93 else |
69 " else: the tags file goes in a cache directory, so we need to specify | 94 " else: the tags file goes in a cache directory, so we need to specify |
70 " all the paths absolutely for `ctags` to do its job correctly. | 95 " all the paths absolutely for `ctags` to do its job correctly. |
71 let l:actual_proj_dir = a:proj_dir | 96 let l:actual_proj_dir = a:proj_dir |
72 let l:actual_tags_file = a:tags_file | 97 let l:actual_tags_file = a:tags_file |
115 if filereadable(l:proj_options_file) | 140 if filereadable(l:proj_options_file) |
116 let l:proj_options_file = s:process_options_file( | 141 let l:proj_options_file = s:process_options_file( |
117 \a:proj_dir, l:proj_options_file) | 142 \a:proj_dir, l:proj_options_file) |
118 let l:cmd .= ' -o "' . l:proj_options_file . '"' | 143 let l:cmd .= ' -o "' . l:proj_options_file . '"' |
119 endif | 144 endif |
120 for ign in split(&wildignore, ',') | 145 if g:gutentags_ctags_exclude_wildignore |
121 let l:cmd .= ' -x ' . '"' . ign . '"' | 146 for ign in split(&wildignore, ',') |
122 endfor | 147 let l:cmd .= ' -x ' . '"' . ign . '"' |
123 for exc in g:gutentags_exclude | 148 endfor |
149 endif | |
150 for exc in g:gutentags_ctags_exclude | |
124 let l:cmd .= ' -x ' . '"' . exc . '"' | 151 let l:cmd .= ' -x ' . '"' . exc . '"' |
125 endfor | 152 endfor |
126 if g:gutentags_pause_after_update | 153 if g:gutentags_pause_after_update |
127 let l:cmd .= ' -c' | 154 let l:cmd .= ' -c' |
128 endif | 155 endif |