Mercurial > vim-gutentags
annotate plugin/gutentags.vim @ 280:c33b43915b41 default tip master
cscope_maps: overwrite cscope_maps' db_file with tag_file
author | Dhananjay <dhananjay.latkar@gmail.com> |
---|---|
date | Fri, 14 Apr 2023 12:58:56 +0530 |
parents | edd757c1e28d |
children |
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> |
202
b50b6d0f82dd
Refactor for Vim8/Neovim job support.
Ludovic Chabant <ludovic@chabant.com>
parents:
182
diff
changeset
|
3 " Version: 2.0.0 |
0 | 4 |
5 " Globals {{{ | |
6 | |
149
f915393ff68d
Add `g:gutentags_dont_load` setting.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
7 if (&cp || get(g:, 'gutentags_dont_load', 0)) |
f915393ff68d
Add `g:gutentags_dont_load` setting.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
8 finish |
f915393ff68d
Add `g:gutentags_dont_load` setting.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
9 endif |
f915393ff68d
Add `g:gutentags_dont_load` setting.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
10 |
208
18dbf8d02b4c
Lower Vim version requirement since we also check for the job API directly.
Ludovic Chabant <ludovic@chabant.com>
parents:
202
diff
changeset
|
11 if v:version < 704 |
18dbf8d02b4c
Lower Vim version requirement since we also check for the job API directly.
Ludovic Chabant <ludovic@chabant.com>
parents:
202
diff
changeset
|
12 echoerr "gutentags: this plugin requires vim >= 7.4." |
202
b50b6d0f82dd
Refactor for Vim8/Neovim job support.
Ludovic Chabant <ludovic@chabant.com>
parents:
182
diff
changeset
|
13 finish |
b50b6d0f82dd
Refactor for Vim8/Neovim job support.
Ludovic Chabant <ludovic@chabant.com>
parents:
182
diff
changeset
|
14 endif |
b50b6d0f82dd
Refactor for Vim8/Neovim job support.
Ludovic Chabant <ludovic@chabant.com>
parents:
182
diff
changeset
|
15 |
b50b6d0f82dd
Refactor for Vim8/Neovim job support.
Ludovic Chabant <ludovic@chabant.com>
parents:
182
diff
changeset
|
16 if !(has('job') || (has('nvim') && exists('*jobwait'))) |
b50b6d0f82dd
Refactor for Vim8/Neovim job support.
Ludovic Chabant <ludovic@chabant.com>
parents:
182
diff
changeset
|
17 echoerr "gutentags: this plugin requires the job API from Vim8 or Neovim." |
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
|
18 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
|
19 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
|
20 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
21 let g:gutentags_debug = get(g:, 'gutentags_debug', 0) |
0 | 22 |
149
f915393ff68d
Add `g:gutentags_dont_load` setting.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
23 if (exists('g:loaded_gutentags') && !g:gutentags_debug) |
0 | 24 finish |
25 endif | |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
26 if (exists('g:loaded_gutentags') && g:gutentags_debug) |
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
27 echom "Reloaded gutentags." |
0 | 28 endif |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
29 let g:loaded_gutentags = 1 |
0 | 30 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 |
141
7bc4df0225d1
Add support for specifying buffer-specific tagfiles.
Ludovic Chabant <ludovic@chabant.com>
parents:
136
diff
changeset
|
38 let g:gutentags_init_user_func = get(g:, 'gutentags_init_user_func', |
7bc4df0225d1
Add support for specifying buffer-specific tagfiles.
Ludovic Chabant <ludovic@chabant.com>
parents:
136
diff
changeset
|
39 \get(g:, 'gutentags_enabled_user_func', '')) |
7bc4df0225d1
Add support for specifying buffer-specific tagfiles.
Ludovic Chabant <ludovic@chabant.com>
parents:
136
diff
changeset
|
40 |
243
050d0549ecf3
Add `g:gutentags_add_ctrlp_root_markers` option.
Ludovic Chabant <ludovic@chabant.com>
parents:
229
diff
changeset
|
41 let g:gutentags_add_ctrlp_root_markers = get(g:, 'gutentags_add_ctrlp_root_markers', 1) |
128
e673026faa56
Add option to not append the default project root markers.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 endif |
146
3459a2522a3b
Enable Project Root Finder
thecontinium <thecontinium@outlook.com>
parents:
136
diff
changeset
|
47 |
3459a2522a3b
Enable Project Root Finder
thecontinium <thecontinium@outlook.com>
parents:
136
diff
changeset
|
48 let g:gutentags_project_root_finder = get(g:, 'gutentags_project_root_finder', '') |
0 | 49 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 |
270
edd757c1e28d
Update default excluded project roots
Ludovic Chabant <ludovic@chabant.com>
parents:
267
diff
changeset
|
54 let g:gutentags_exclude_project_root = get(g:, 'gutentags_exclude_project_root', |
edd757c1e28d
Update default excluded project roots
Ludovic Chabant <ludovic@chabant.com>
parents:
267
diff
changeset
|
55 \['/usr/local', '/opt/homebrew', '/home/linuxbrew/.linuxbrew']) |
edd757c1e28d
Update default excluded project roots
Ludovic Chabant <ludovic@chabant.com>
parents:
267
diff
changeset
|
56 |
229
34bee0477b51
Add `g:gutentags_exclude_filetypes` setting.
Ludovic Chabant <ludovic@chabant.com>
parents:
208
diff
changeset
|
57 let g:gutentags_exclude_filetypes = get(g:, 'gutentags_exclude_filetypes', []) |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 let g:gutentags_generate_on_write = get(g:, 'gutentags_generate_on_write', 1) |
182
2489b4b54d5c
Add `g:gutentags_generate_on_empty_buffer` setting.
Ludovic Chabant <ludovic@chabant.com>
parents:
165
diff
changeset
|
62 let g:gutentags_generate_on_empty_buffer = get(g:, 'gutentags_generate_on_empty_buffer', 0) |
136
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
132
diff
changeset
|
63 let g:gutentags_file_list_command = get(g:, 'gutentags_file_list_command', '') |
3 | 64 |
202
b50b6d0f82dd
Refactor for Vim8/Neovim job support.
Ludovic Chabant <ludovic@chabant.com>
parents:
182
diff
changeset
|
65 let g:gutentags_use_jobs = get(g:, 'gutentags_use_jobs', has('job')) |
b50b6d0f82dd
Refactor for Vim8/Neovim job support.
Ludovic Chabant <ludovic@chabant.com>
parents:
182
diff
changeset
|
66 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
67 if !exists('g:gutentags_cache_dir') |
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
68 let g:gutentags_cache_dir = '' |
159
41fa23706d9c
Don't use the cache directory if it's set as an empty string.
Ludovic Chabant <ludovic@chabant.com>
parents:
149
diff
changeset
|
69 elseif !empty(g:gutentags_cache_dir) |
76
fa749380e05a
Make sure we expand the cache directory before we auto-create it.
Ludovic Chabant <ludovic@chabant.com>
parents:
75
diff
changeset
|
70 " 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
|
71 " 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
|
72 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
|
73 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
|
74 endif |
d48b0e48283b
Add support for storing tags files out of the way.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
75 |
119
a66d90fd758b
expand() g:gutentags_ctags_executable
Justin M. Keyes <justinkz@gmail.com>
parents:
92
diff
changeset
|
76 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
|
77 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
78 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
|
79 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
|
80 endif |
d48b0e48283b
Add support for storing tags files out of the way.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
81 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
82 if has('win32') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
87 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
|
88 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
|
89 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
|
90 endif |
0 | 91 |
254
52be4cf89810
Don't complain when the job gets killed when Vim exits.
Ludovic Chabant <ludovic@chabant.com>
parents:
243
diff
changeset
|
92 let g:__gutentags_vim_is_leaving = 0 |
52be4cf89810
Don't complain when the job gets killed when Vim exits.
Ludovic Chabant <ludovic@chabant.com>
parents:
243
diff
changeset
|
93 |
0 | 94 " }}} |
95 | |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
96 " Gutentags Setup {{{ |
0 | 97 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
98 augroup gutentags_detect |
0 | 99 autocmd! |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
40
diff
changeset
|
100 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
|
101 autocmd VimEnter * if expand('<amatch>')==''|call gutentags#setup_gutentags()|endif |
254
52be4cf89810
Don't complain when the job gets killed when Vim exits.
Ludovic Chabant <ludovic@chabant.com>
parents:
243
diff
changeset
|
102 autocmd VimLeavePre * call gutentags#on_vim_leave_pre() |
267
6030953258fe
On Windows, kill ongoing jobs before leaving so we can clean-up temp files
Ludovic Chabant <ludovic@chabant.com>
parents:
254
diff
changeset
|
103 autocmd VimLeave * call gutentags#on_vim_leave() |
0 | 104 augroup end |
105 | |
106 " }}} | |
107 | |
3 | 108 " Toggles and Miscellaneous Commands {{{ |
0 | 109 |
46
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
110 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
|
111 command! GutentagsToggleEnabled :let g:gutentags_enabled=!g:gutentags_enabled |
54
50d2a7cbf7c8
Fix the `GutentagsToggleTrace` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
51
diff
changeset
|
112 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
|
113 endif |
0 | 114 |
22
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
115 if g:gutentags_debug |
4e1b0253f71a
Renamed project to "Gutentags" (thanks Sylvain!).
Ludovic Chabant <ludovic@chabant.com>
parents:
21
diff
changeset
|
116 command! GutentagsToggleFake :call gutentags#fake() |
10
b853ad0e7afd
Only define `:AutotagsToggleFake` if debug mode is on.
Ludovic Chabant <ludovic@chabant.com>
parents:
9
diff
changeset
|
117 endif |
b853ad0e7afd
Only define `:AutotagsToggleFake` if debug mode is on.
Ludovic Chabant <ludovic@chabant.com>
parents:
9
diff
changeset
|
118 |
0 | 119 " }}} |
120 |