Mercurial > vim-gutentags
annotate plugin/gutentags.vim @ 136:286e5b3095d0
Allow restricting tag generation to files listed by custom commands
This adds a new setting, g:gutentags_file_list_command, which specifies
command(s) to use to list files for which tags should be generated,
instead of recursively examining all files within the project root.
This is useful in projects using source control to restrict tag
generation to only files tracked in the repository.
This setting is conceptually similar to CtrlP's ctrlp_user_command
option.
This implements the feature requested in
https://github.com/ludovicchabant/vim-gutentags/issues/90
author | Stephen Kent <smkent@smkent.net> |
---|---|
date | Fri, 22 Jul 2016 19:25:05 -0700 |
parents | a6ef1c860d07 |
children | 7bc4df0225d1 3459a2522a3b |
rev | line source |
---|---|
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
1 " gutentags.vim - Automatic ctags management for Vim |
0 | 2 " Maintainer: Ludovic Chabant <http://ludovic.chabant.com> |
3 " Version: 0.0.1 | |
4 | |
5 " Globals {{{ | |
6 | |
92
6bbed9e4c01e
Using `:!start /b` actually requires Vim 7.4.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
7 if v:version < 704 |
6bbed9e4c01e
Using `:!start /b` actually requires Vim 7.4.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
8 echoerr "gutentags: this plugin requires vim >= 7.4." |
50
ea7780912296
Check for Vim 7.4 since bug reports indicate Gutentags may not work in 7.3.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
9 finish |
ea7780912296
Check for Vim 7.4 since bug reports indicate Gutentags may not work in 7.3.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
10 endif |
ea7780912296
Check for Vim 7.4 since bug reports indicate Gutentags may not work in 7.3.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
11 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
12 let g:gutentags_debug = get(g:, 'gutentags_debug', 0) |
0 | 13 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
14 if (exists('g:loaded_gutentags') || &cp) && !g:gutentags_debug |
0 | 15 finish |
16 endif | |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
17 if (exists('g:loaded_gutentags') && g:gutentags_debug) |
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
18 echom "Reloaded gutentags." |
0 | 19 endif |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
20 let g:loaded_gutentags = 1 |
0 | 21 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
22 let g:gutentags_trace = get(g:, 'gutentags_trace', 0) |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
23 let g:gutentags_fake = get(g:, 'gutentags_fake', 0) |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
24 let g:gutentags_background_update = get(g:, 'gutentags_background_update', 1) |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
25 let g:gutentags_pause_after_update = get(g:, 'gutentags_pause_after_update', 0) |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
26 let g:gutentags_enabled = get(g:, 'gutentags_enabled', 1) |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
27 let g:gutentags_enabled_user_func = get(g:, 'gutentags_enabled_user_func', '') |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
28 let g:gutentags_modules = get(g:, 'gutentags_modules', ['ctags']) |
11
478638833c3b
Fix Win32 update script, add option to pause it.
Ludovic Chabant <ludovic@chabant.com>
parents:
10
diff
changeset
|
29 |
128
e673026faa56
Add option to not append the default project root markers.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
30 let g:gutentags_add_default_project_roots = get(g:, 'gutentags_add_default_project_roots', 1) |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
31 let g:gutentags_project_root = get(g:, 'gutentags_project_root', []) |
128
e673026faa56
Add option to not append the default project root markers.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
32 if g:gutentags_add_default_project_roots |
e673026faa56
Add option to not append the default project root markers.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
33 let g:gutentags_project_root += ['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout'] |
e673026faa56
Add option to not append the default project root markers.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
34 endif |
132
a6ef1c860d07
Add support for custom root finders like `vim-projectroot`.
Ludovic Chabant <ludovic@chabant.com>
parents:
128
diff
changeset
|
35 let g:gutentags_project_root_finder = '' |
0 | 36 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
37 let g:gutentags_project_info = get(g:, 'gutentags_project_info', []) |
89
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
38 call add(g:gutentags_project_info, {'type': 'python', 'file': 'setup.py'}) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
39 call add(g:gutentags_project_info, {'type': 'ruby', 'file': 'Gemfile'}) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
40 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
41 let g:gutentags_exclude = get(g:, 'gutentags_exclude', []) |
120
5776acb079cf
Merge pull request #84 from GitHub.
Ludovic Chabant <ludovic@chabant.com>
diff
changeset
|
42 let g:gutentags_exclude_project_root = get(g:, 'gutentags_exclude_project_root', ['/usr/local']) |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
43 let g:gutentags_resolve_symlinks = get(g:, 'gutentags_resolve_symlinks', 0) |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
44 let g:gutentags_generate_on_new = get(g:, 'gutentags_generate_on_new', 1) |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
45 let g:gutentags_generate_on_missing = get(g:, 'gutentags_generate_on_missing', 1) |
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
46 let g:gutentags_generate_on_write = get(g:, 'gutentags_generate_on_write', 1) |
136
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
132
diff
changeset
|
47 let g:gutentags_file_list_command = get(g:, 'gutentags_file_list_command', '') |
3 | 48 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
49 if !exists('g:gutentags_cache_dir') |
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
50 let g:gutentags_cache_dir = '' |
19
d48b0e48283b
Add support for storing tags files out of the way.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
51 else |
76
fa749380e05a
Make sure we expand the cache directory before we auto-create it.
Ludovic Chabant <ludovic@chabant.com>
parents:
75
diff
changeset
|
52 " Make sure we get an absolute/resolved path (e.g. expanding `~/`), and |
fa749380e05a
Make sure we expand the cache directory before we auto-create it.
Ludovic Chabant <ludovic@chabant.com>
parents:
75
diff
changeset
|
53 " strip any trailing slash. |
fa749380e05a
Make sure we expand the cache directory before we auto-create it.
Ludovic Chabant <ludovic@chabant.com>
parents:
75
diff
changeset
|
54 let g:gutentags_cache_dir = fnamemodify(g:gutentags_cache_dir, ':p') |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
55 let g:gutentags_cache_dir = fnamemodify(g:gutentags_cache_dir, ':s?[/\\]$??') |
19
d48b0e48283b
Add support for storing tags files out of the way.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
56 endif |
d48b0e48283b
Add support for storing tags files out of the way.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
57 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
58 let g:gutentags_define_advanced_commands = get(g:, 'gutentags_define_advanced_commands', 0) |
46
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
59 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
60 if g:gutentags_cache_dir != '' && !isdirectory(g:gutentags_cache_dir) |
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
61 call mkdir(g:gutentags_cache_dir, 'p') |
19
d48b0e48283b
Add support for storing tags files out of the way.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
62 endif |
d48b0e48283b
Add support for storing tags files out of the way.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
63 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
64 if has('win32') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
65 let g:gutentags_plat_dir = expand('<sfile>:h:h:p') . "\\plat\\win32\\" |
75
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
54
diff
changeset
|
66 let g:gutentags_res_dir = expand('<sfile>:h:h:p') . "\\res\\" |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
67 let g:gutentags_script_ext = '.cmd' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
68 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
69 let g:gutentags_plat_dir = expand('<sfile>:h:h:p') . '/plat/unix/' |
75
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
54
diff
changeset
|
70 let g:gutentags_res_dir = expand('<sfile>:h:h:p') . '/res/' |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
71 let g:gutentags_script_ext = '.sh' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
72 endif |
0 | 73 |
74 " }}} | |
75 | |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
76 " Gutentags Setup {{{ |
0 | 77 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
78 augroup gutentags_detect |
0 | 79 autocmd! |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
80 autocmd BufNewFile,BufReadPost * call gutentags#setup_gutentags() |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
81 autocmd VimEnter * if expand('<amatch>')==''|call gutentags#setup_gutentags()|endif |
0 | 82 augroup end |
83 | |
84 " }}} | |
85 | |
3 | 86 " Toggles and Miscellaneous Commands {{{ |
0 | 87 |
46
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
88 command! GutentagsUnlock :call gutentags#delete_lock_files() |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
89 |
46
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
90 if g:gutentags_define_advanced_commands |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
91 command! GutentagsToggleEnabled :let g:gutentags_enabled=!g:gutentags_enabled |
54
50d2a7cbf7c8
Fix the `GutentagsToggleTrace` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
51
diff
changeset
|
92 command! GutentagsToggleTrace :call gutentags#toggletrace() |
46
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
93 endif |
0 | 94 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
95 if g:gutentags_debug |
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
96 command! GutentagsToggleFake :call gutentags#fake() |
10
b853ad0e7afd
Only define `:AutotagsToggleFake` if debug mode is on.
Ludovic Chabant <ludovic@chabant.com>
parents:
9
diff
changeset
|
97 endif |
b853ad0e7afd
Only define `:AutotagsToggleFake` if debug mode is on.
Ludovic Chabant <ludovic@chabant.com>
parents:
9
diff
changeset
|
98 |
0 | 99 " }}} |
100 |