Mercurial > vim-gutentags
annotate autoload/gutentags.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 | 28d4dae03f2a |
children | 1fe62e7f1fae |
rev | line source |
---|---|
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 " gutentags.vim - Automatic ctags management for Vim |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 " Utilities {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 " Throw an exception message. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 function! gutentags#throw(message) |
148
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
7 throw "gutentags: " . a:message |
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
8 endfunction |
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
9 |
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
10 " Throw an exception message and set Vim's error message variable. |
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
11 function! gutentags#throwerr(message) |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 let v:errmsg = "gutentags: " . a:message |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 throw v:errmsg |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 " Prints a message if debug tracing is enabled. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 function! gutentags#trace(message, ...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 if g:gutentags_trace || (a:0 && a:1) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 let l:message = "gutentags: " . a:message |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 echom l:message |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 " Strips the ending slash in a path. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 function! gutentags#stripslash(path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 return fnamemodify(a:path, ':s?[/\\]$??') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
27 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
28 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
29 " Normalizes the slashes in a path. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 function! gutentags#normalizepath(path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
31 if exists('+shellslash') && &shellslash |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 return substitute(a:path, '\v/', '\\', 'g') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
33 elseif has('win32') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
34 return substitute(a:path, '\v/', '\\', 'g') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
36 return a:path |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
37 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
38 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
40 " Shell-slashes the path (opposite of `normalizepath`). |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
41 function! gutentags#shellslash(path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
42 if exists('+shellslash') && !&shellslash |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
43 return substitute(a:path, '\v\\', '/', 'g') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
44 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
45 return a:path |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
46 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
47 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
48 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
49 " Gets a file path in the correct `plat` folder. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
50 function! gutentags#get_plat_file(filename) abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
51 return g:gutentags_plat_dir . a:filename . g:gutentags_script_ext |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
52 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
53 |
75
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
70
diff
changeset
|
54 " Gets a file path in the resource folder. |
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
70
diff
changeset
|
55 function! gutentags#get_res_file(filename) abort |
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
70
diff
changeset
|
56 return g:gutentags_res_dir . a:filename |
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
70
diff
changeset
|
57 endfunction |
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
70
diff
changeset
|
58 |
164
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
59 " Returns whether a path is rooted. |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
60 if has('win32') || has('win64') |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
61 function! gutentags#is_path_rooted(path) abort |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
62 return len(a:path) >= 2 && a:path[1] == ':' |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
63 endfunction |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
64 else |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
65 function! gutentags#is_path_rooted(path) abort |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
66 return !empty(a:path) && a:path[0] == '/' |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
67 endfunction |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
68 endif |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
69 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
70 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
71 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
72 " Gutentags Setup {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
73 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
74 let s:known_files = [] |
89
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
75 let s:known_projects = {} |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
76 |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
77 function! s:cache_project_root(path) abort |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
78 let l:result = {} |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
79 |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
80 for proj_info in g:gutentags_project_info |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
81 let l:filematch = get(proj_info, 'file', '') |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
82 if l:filematch != '' && filereadable(a:path . '/'. l:filematch) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
83 let l:result = copy(proj_info) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
84 break |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
85 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
86 |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
87 let l:globmatch = get(proj_info, 'glob', '') |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
88 if l:globmatch != '' && glob(a:path . '/' . l:globmatch) != '' |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
89 let l:result = copy(proj_info) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
90 break |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
91 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
92 endfor |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
93 |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
94 let s:known_projects[a:path] = l:result |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
95 endfunction |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
96 |
136
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
97 function! gutentags#validate_cmd(cmd) abort |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
98 if !empty(a:cmd) && executable(split(a:cmd)[0]) |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
99 return a:cmd |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
100 endif |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
101 return "" |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
102 endfunction |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
103 |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
104 function! gutentags#get_project_file_list_cmd(path) abort |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
105 if type(g:gutentags_file_list_command) == type("") |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
106 return gutentags#validate_cmd(g:gutentags_file_list_command) |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
107 elseif type(g:gutentags_file_list_command) == type({}) |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
108 let l:markers = get(g:gutentags_file_list_command, 'markers', []) |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
109 if type(l:markers) == type({}) |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
110 for [marker, file_list_cmd] in items(l:markers) |
157
6b00f4383708
Support project root markers that are wildcard patterns.
Ludovic Chabant <ludovic@chabant.com>
parents:
148
diff
changeset
|
111 if !empty(globpath(a:path, marker, 1)) |
136
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
112 return gutentags#validate_cmd(file_list_cmd) |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
113 endif |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
114 endfor |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
115 endif |
157
6b00f4383708
Support project root markers that are wildcard patterns.
Ludovic Chabant <ludovic@chabant.com>
parents:
148
diff
changeset
|
116 return get(g:gutentags_file_list_command, 'default', "") |
136
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
117 endif |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
118 return "" |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
119 endfunction |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
120 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
121 " Finds the first directory with a project marker by walking up from the given |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
122 " file path. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
123 function! gutentags#get_project_root(path) abort |
146
3459a2522a3b
Enable Project Root Finder
thecontinium <thecontinium@outlook.com>
parents:
136
diff
changeset
|
124 if g:gutentags_project_root_finder != '' |
132
a6ef1c860d07
Add support for custom root finders like `vim-projectroot`.
Ludovic Chabant <ludovic@chabant.com>
parents:
131
diff
changeset
|
125 return call(g:gutentags_project_root_finder, [a:path]) |
a6ef1c860d07
Add support for custom root finders like `vim-projectroot`.
Ludovic Chabant <ludovic@chabant.com>
parents:
131
diff
changeset
|
126 endif |
a6ef1c860d07
Add support for custom root finders like `vim-projectroot`.
Ludovic Chabant <ludovic@chabant.com>
parents:
131
diff
changeset
|
127 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
128 let l:path = gutentags#stripslash(a:path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
129 let l:previous_path = "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
130 let l:markers = g:gutentags_project_root[:] |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
131 if exists('g:ctrlp_root_markers') |
134 | 132 for crm in g:ctrlp_root_markers |
133 if index(l:markers, crm) < 0 | |
134 call add(l:markers, crm) | |
135 endif | |
136 endfor | |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
137 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
138 while l:path != l:previous_path |
80
51c1a57811b3
Use full list of root markers in get_project_root.
Greg Hensley <greg.hensley@gmail.com>
parents:
75
diff
changeset
|
139 for root in l:markers |
157
6b00f4383708
Support project root markers that are wildcard patterns.
Ludovic Chabant <ludovic@chabant.com>
parents:
148
diff
changeset
|
140 if !empty(globpath(l:path, root)) |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
141 let l:proj_dir = simplify(fnamemodify(l:path, ':p')) |
90
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
142 let l:proj_dir = gutentags#stripslash(l:proj_dir) |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
143 if l:proj_dir == '' |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
144 call gutentags#trace("Found project marker '" . root . |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
145 \"' at the root of your file-system! " . |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
146 \" That's probably wrong, disabling " . |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
147 \"gutentags for this file...", |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
148 \1) |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
149 call gutentags#throw("Marker found at root, aborting.") |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
150 endif |
118
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
151 for ign in g:gutentags_exclude_project_root |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
152 if l:proj_dir == ign |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
153 call gutentags#trace( |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
154 \"Ignoring project root '" . l:proj_dir . |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
155 \"' because it is in the list of ignored" . |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
156 \" projects.") |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
157 call gutentags#throw("Ignore project: " . l:proj_dir) |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
158 endif |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
159 endfor |
90
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
160 return l:proj_dir |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
161 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
162 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
163 let l:previous_path = l:path |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
164 let l:path = fnamemodify(l:path, ':h') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
165 endwhile |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
166 call gutentags#throw("Can't figure out what tag file to use for: " . a:path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
167 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
168 |
89
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
169 " Get info on the project we're inside of. |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
170 function! gutentags#get_project_info(path) abort |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
171 return get(s:known_projects, a:path, {}) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
172 endfunction |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
173 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
174 " Generate a path for a given filename in the cache directory. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
175 function! gutentags#get_cachefile(root_dir, filename) abort |
164
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
176 if gutentags#is_path_rooted(a:filename) |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
177 return a:filename |
28d4dae03f2a
If a user init function specified an absolute path, don't mess with it.
Ludovic Chabant <ludovic@chabant.com>
parents:
157
diff
changeset
|
178 endif |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
179 let l:tag_path = gutentags#stripslash(a:root_dir) . '/' . a:filename |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
180 if g:gutentags_cache_dir != "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
181 " Put the tag file in the cache dir instead of inside the |
121
8310e4602de9
minor: fix typos / unbalanced quotes
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
182 " project root. |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
183 let l:tag_path = g:gutentags_cache_dir . '/' . |
98
d645125192aa
Fix more problems with paths and spaces in them.
Ludovic Chabant <ludovic@chabant.com>
parents:
90
diff
changeset
|
184 \tr(l:tag_path, '\/: ', '---_') |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
185 let l:tag_path = substitute(l:tag_path, '/\-', '/', '') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
186 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
187 let l:tag_path = gutentags#normalizepath(l:tag_path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
188 return l:tag_path |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
189 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
190 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
191 " Setup gutentags for the current buffer. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
192 function! gutentags#setup_gutentags() abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
193 if exists('b:gutentags_files') && !g:gutentags_debug |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
194 " This buffer already has gutentags support. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
195 return |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
196 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
197 |
63
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
198 " Don't setup gutentags for anything that's not a normal buffer |
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
199 " (so don't do anything for help buffers and quickfix windows and |
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
200 " other such things) |
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
201 if &buftype != '' |
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
202 return |
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
203 endif |
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
204 |
88
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
205 " Let the user specify custom ways to disable Gutentags. |
141
7bc4df0225d1
Add support for specifying buffer-specific tagfiles.
Ludovic Chabant <ludovic@chabant.com>
parents:
136
diff
changeset
|
206 if g:gutentags_init_user_func != '' && |
7bc4df0225d1
Add support for specifying buffer-specific tagfiles.
Ludovic Chabant <ludovic@chabant.com>
parents:
136
diff
changeset
|
207 \!call(g:gutentags_init_user_func, [expand('%:p')]) |
88
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
208 call gutentags#trace("Ignoring '" . bufname('%') . "' because of " . |
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
209 \"custom user function.") |
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
210 return |
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
211 endif |
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
212 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
213 " Try and find what tags file we should manage. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
214 call gutentags#trace("Scanning buffer '" . bufname('%') . "' for gutentags setup...") |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
215 try |
85
0424970d81f8
Add a `g:gutentags_resolve_symlinks` option to resolve symlinks at setup time.
Ludovic Chabant <ludovic@chabant.com>
parents:
84
diff
changeset
|
216 let l:buf_dir = expand('%:p:h', 1) |
0424970d81f8
Add a `g:gutentags_resolve_symlinks` option to resolve symlinks at setup time.
Ludovic Chabant <ludovic@chabant.com>
parents:
84
diff
changeset
|
217 if g:gutentags_resolve_symlinks |
0424970d81f8
Add a `g:gutentags_resolve_symlinks` option to resolve symlinks at setup time.
Ludovic Chabant <ludovic@chabant.com>
parents:
84
diff
changeset
|
218 let l:buf_dir = fnamemodify(resolve(expand('%:p', 1)), ':p:h') |
0424970d81f8
Add a `g:gutentags_resolve_symlinks` option to resolve symlinks at setup time.
Ludovic Chabant <ludovic@chabant.com>
parents:
84
diff
changeset
|
219 endif |
123
76a4822aab76
Use existing b:gutentags_root
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
220 if !exists('b:gutentags_root') |
76a4822aab76
Use existing b:gutentags_root
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
221 let b:gutentags_root = gutentags#get_project_root(l:buf_dir) |
76a4822aab76
Use existing b:gutentags_root
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
222 endif |
47
7b419abf7fba
Add ability to disable Gutentags if a `.notags` file is at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
223 if filereadable(b:gutentags_root . '/.notags') |
121
8310e4602de9
minor: fix typos / unbalanced quotes
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
224 call gutentags#trace("'.notags' file found... no gutentags support.") |
47
7b419abf7fba
Add ability to disable Gutentags if a `.notags` file is at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
225 return |
7b419abf7fba
Add ability to disable Gutentags if a `.notags` file is at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
226 endif |
7b419abf7fba
Add ability to disable Gutentags if a `.notags` file is at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
227 |
89
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
228 if !has_key(s:known_projects, b:gutentags_root) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
229 call s:cache_project_root(b:gutentags_root) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
230 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
231 if g:gutentags_trace |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
232 let l:projnfo = gutentags#get_project_info(b:gutentags_root) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
233 if l:projnfo != {} |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
234 call gutentags#trace("Setting project type to ".l:projnfo['type']) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
235 else |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
236 call gutentags#trace("No specific project type.") |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
237 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
238 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
239 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
240 let b:gutentags_files = {} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
241 for module in g:gutentags_modules |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
242 call call("gutentags#".module."#init", [b:gutentags_root]) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
243 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
244 catch /^gutentags\:/ |
118
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
245 call gutentags#trace("No gutentags support for this buffer.") |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
246 return |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
247 endtry |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
248 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
249 " We know what tags file to manage! Now set things up. |
121
8310e4602de9
minor: fix typos / unbalanced quotes
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
250 call gutentags#trace("Setting gutentags for buffer '".bufname('%')."'") |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
251 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
252 " Autocommands for updating the tags on save. |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
253 " We need to pass the buffer number to the callback function in the rare |
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
254 " case that the current buffer is changed by another `BufWritePost` |
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
255 " callback. This will let us get that buffer's variables without causing |
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
256 " errors. |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
257 let l:bn = bufnr('%') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
258 execute 'augroup gutentags_buffer_' . l:bn |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
259 execute ' autocmd!' |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
260 execute ' autocmd BufWritePost <buffer=' . l:bn . '> call s:write_triggered_update_tags(' . l:bn . ')' |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
261 execute 'augroup end' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
262 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
263 " Miscellaneous commands. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
264 command! -buffer -bang GutentagsUpdate :call s:manual_update_tags(<bang>0) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
265 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
266 " Add these tags files to the known tags files. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
267 for module in keys(b:gutentags_files) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
268 let l:tagfile = b:gutentags_files[module] |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
269 let l:found = index(s:known_files, l:tagfile) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
270 if l:found < 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
271 call add(s:known_files, l:tagfile) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
272 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
273 " Generate this new file depending on settings and stuff. |
87
afe113047204
Don't generate tags on file opened if `gutentags_enabled` is false.
Ludovic Chabant <ludovic@chabant.com>
parents:
85
diff
changeset
|
274 if g:gutentags_enabled |
afe113047204
Don't generate tags on file opened if `gutentags_enabled` is false.
Ludovic Chabant <ludovic@chabant.com>
parents:
85
diff
changeset
|
275 if g:gutentags_generate_on_missing && !filereadable(l:tagfile) |
afe113047204
Don't generate tags on file opened if `gutentags_enabled` is false.
Ludovic Chabant <ludovic@chabant.com>
parents:
85
diff
changeset
|
276 call gutentags#trace("Generating missing tags file: " . l:tagfile) |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
277 call s:update_tags(l:bn, module, 1, 1) |
87
afe113047204
Don't generate tags on file opened if `gutentags_enabled` is false.
Ludovic Chabant <ludovic@chabant.com>
parents:
85
diff
changeset
|
278 elseif g:gutentags_generate_on_new |
afe113047204
Don't generate tags on file opened if `gutentags_enabled` is false.
Ludovic Chabant <ludovic@chabant.com>
parents:
85
diff
changeset
|
279 call gutentags#trace("Generating tags file: " . l:tagfile) |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
280 call s:update_tags(l:bn, module, 1, 1) |
87
afe113047204
Don't generate tags on file opened if `gutentags_enabled` is false.
Ludovic Chabant <ludovic@chabant.com>
parents:
85
diff
changeset
|
281 endif |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
282 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
283 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
284 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
285 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
286 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
287 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
288 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
289 " Tags File Management {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
290 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
291 " List of queued-up jobs, and in-progress jobs, per module. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
292 let s:update_queue = {} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
293 let s:maybe_in_progress = {} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
294 for module in g:gutentags_modules |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
295 let s:update_queue[module] = [] |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
296 let s:maybe_in_progress[module] = {} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
297 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
298 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
299 " Make a given file known as being currently generated or updated. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
300 function! gutentags#add_progress(module, file) abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
301 let s:maybe_in_progress[a:module][a:file] = localtime() |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
302 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
303 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
304 " Get how to execute an external command depending on debug settings. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
305 function! gutentags#get_execute_cmd() abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
306 if has('win32') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
307 let l:cmd = '!start ' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
308 if g:gutentags_background_update |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
309 let l:cmd .= '/b ' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
310 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
311 return l:cmd |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
312 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
313 return '!' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
314 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
315 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
316 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
317 " Get the suffix for how to execute an external command. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
318 function! gutentags#get_execute_cmd_suffix() abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
319 if has('win32') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
320 return '' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
321 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
322 return ' &' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
323 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
324 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
325 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
326 " (Re)Generate the tags file for the current buffer's file. |
48
c1b33dc55b1c
Fix bug with `GutentagsUpdate` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
47
diff
changeset
|
327 function! s:manual_update_tags(bang) abort |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
328 let l:bn = bufnr('%') |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
329 for module in g:gutentags_modules |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
330 call s:update_tags(l:bn, module, a:bang, 0) |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
331 endfor |
101
32e3d047e54e
add user autocmds for after tags updated
David O'Trakoun <me@davidosomething.com>
parents:
90
diff
changeset
|
332 silent doautocmd User GutentagsUpdated |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
333 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
334 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
335 " (Re)Generate the tags file for a buffer that just go saved. |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
336 function! s:write_triggered_update_tags(bufno) abort |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
337 if g:gutentags_enabled && g:gutentags_generate_on_write |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
338 for module in g:gutentags_modules |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
339 call s:update_tags(a:bufno, module, 0, 2) |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
340 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
341 endif |
101
32e3d047e54e
add user autocmds for after tags updated
David O'Trakoun <me@davidosomething.com>
parents:
90
diff
changeset
|
342 silent doautocmd User GutentagsUpdated |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
343 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
344 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
345 " Update the tags file for the current buffer's file. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
346 " write_mode: |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
347 " 0: update the tags file if it exists, generate it otherwise. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
348 " 1: always generate (overwrite) the tags file. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
349 " |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
350 " queue_mode: |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
351 " 0: if an update is already in progress, report it and abort. |
83
e7e392be4141
Only show message about an existing update job for user-initiated actions.
Ludovic Chabant <ludovic@chabant.com>
parents:
82
diff
changeset
|
352 " 1: if an update is already in progress, abort silently. |
e7e392be4141
Only show message about an existing update job for user-initiated actions.
Ludovic Chabant <ludovic@chabant.com>
parents:
82
diff
changeset
|
353 " 2: if an update is already in progress, queue another one. |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
354 function! s:update_tags(bufno, module, write_mode, queue_mode) abort |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
355 " Figure out where to save. |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
356 let l:buf_gutentags_files = getbufvar(a:bufno, 'gutentags_files') |
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
357 let l:tags_file = l:buf_gutentags_files[a:module] |
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
358 let l:proj_dir = getbufvar(a:bufno, 'gutentags_root') |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
359 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
360 " Check that there's not already an update in progress. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
361 let l:lock_file = l:tags_file . '.lock' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
362 if filereadable(l:lock_file) |
83
e7e392be4141
Only show message about an existing update job for user-initiated actions.
Ludovic Chabant <ludovic@chabant.com>
parents:
82
diff
changeset
|
363 if a:queue_mode == 2 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
364 let l:idx = index(s:update_queue[a:module], l:tags_file) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
365 if l:idx < 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
366 call add(s:update_queue[a:module], l:tags_file) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
367 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
368 call gutentags#trace("Tag file '" . l:tags_file . |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
369 \"' is already being updated. Queuing it up...") |
83
e7e392be4141
Only show message about an existing update job for user-initiated actions.
Ludovic Chabant <ludovic@chabant.com>
parents:
82
diff
changeset
|
370 elseif a:queue_mode == 1 |
e7e392be4141
Only show message about an existing update job for user-initiated actions.
Ludovic Chabant <ludovic@chabant.com>
parents:
82
diff
changeset
|
371 call gutentags#trace("Tag file '" . l:tags_file . |
e7e392be4141
Only show message about an existing update job for user-initiated actions.
Ludovic Chabant <ludovic@chabant.com>
parents:
82
diff
changeset
|
372 \"' is already being updated. Skipping...") |
e7e392be4141
Only show message about an existing update job for user-initiated actions.
Ludovic Chabant <ludovic@chabant.com>
parents:
82
diff
changeset
|
373 elseif a:queue_mode == 0 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
374 echom "gutentags: The tags file is already being updated, " . |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
375 \"please try again later." |
83
e7e392be4141
Only show message about an existing update job for user-initiated actions.
Ludovic Chabant <ludovic@chabant.com>
parents:
82
diff
changeset
|
376 else |
148
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
377 call gutentags#throwerr("Unknown queue mode: " . a:queue_mode) |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
378 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
379 return |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
380 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
381 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
382 " Switch to the project root to make the command line smaller, and make |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
383 " it possible to get the relative path of the filename to parse if we're |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
384 " doing an incremental update. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
385 let l:prev_cwd = getcwd() |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
386 execute "chdir " . fnameescape(l:proj_dir) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
387 try |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
388 call call("gutentags#".a:module."#generate", |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
389 \[l:proj_dir, l:tags_file, a:write_mode]) |
84
96bfe5c37f37
Error and abort if we'll be overwriting a non-ctags file.
Ludovic Chabant <ludovic@chabant.com>
parents:
83
diff
changeset
|
390 catch /^gutentags\:/ |
96bfe5c37f37
Error and abort if we'll be overwriting a non-ctags file.
Ludovic Chabant <ludovic@chabant.com>
parents:
83
diff
changeset
|
391 echom "Error while generating ".a:module." file:" |
96bfe5c37f37
Error and abort if we'll be overwriting a non-ctags file.
Ludovic Chabant <ludovic@chabant.com>
parents:
83
diff
changeset
|
392 echom v:exception |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
393 finally |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
394 " Restore the current directory... |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
395 execute "chdir " . fnameescape(l:prev_cwd) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
396 endtry |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
397 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
398 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
399 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
400 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
401 " Utility Functions {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
402 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
403 function! gutentags#rescan(...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
404 if exists('b:gutentags_files') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
405 unlet b:gutentags_files |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
406 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
407 if a:0 && a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
408 let l:trace_backup = g:gutentags_trace |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
409 let l:gutentags_trace = 1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
410 endif |
82
a837021a2388
Fix broken call debug function.
Ludovic Chabant <ludovic@chabant.com>
parents:
80
diff
changeset
|
411 call gutentags#setup_gutentags() |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
412 if a:0 && a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
413 let g:gutentags_trace = l:trace_backup |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
414 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
415 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
416 |
46
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
417 function! gutentags#delete_lock_files() abort |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
418 if exists('b:gutentags_files') |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
419 for tagfile in values(b:gutentags_files) |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
420 silent call delete(tagfile.'.lock') |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
421 endfor |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
422 endif |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
423 endfunction |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
424 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
425 function! gutentags#toggletrace(...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
426 let g:gutentags_trace = !g:gutentags_trace |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
427 if a:0 > 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
428 let g:gutentags_trace = a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
429 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
430 if g:gutentags_trace |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
431 echom "gutentags: Tracing is enabled." |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
432 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
433 echom "gutentags: Tracing is disabled." |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
434 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
435 echom "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
436 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
437 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
438 function! gutentags#fake(...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
439 let g:gutentags_fake = !g:gutentags_fake |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
440 if a:0 > 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
441 let g:gutentags_fake = a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
442 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
443 if g:gutentags_fake |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
444 echom "gutentags: Now faking gutentags." |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
445 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
446 echom "gutentags: Now running gutentags for real." |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
447 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
448 echom "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
449 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
450 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
451 function! gutentags#inprogress() |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
452 echom "gutentags: generations in progress:" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
453 for mip in keys(s:maybe_in_progress) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
454 echom mip |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
455 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
456 echom "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
457 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
458 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
459 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
460 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
461 " Statusline Functions {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
462 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
463 " Prints whether a tag file is being generated right now for the current |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
464 " buffer in the status line. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
465 " |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
466 " Arguments can be passed: |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
467 " - args 1 and 2 are the prefix and suffix, respectively, of whatever output, |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
468 " if any, is going to be produced. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
469 " (defaults to empty strings) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
470 " - arg 3 is the text to be shown if tags are currently being generated. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
471 " (defaults to 'TAGS') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
472 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
473 function! gutentags#statusline(...) abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
474 if !exists('b:gutentags_files') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
475 " This buffer doesn't have gutentags. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
476 return '' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
477 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
478 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
479 " Figure out what the user is customizing. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
480 let l:gen_msg = 'TAGS' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
481 if a:0 > 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
482 let l:gen_msg = a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
483 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
484 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
485 " To make this function as fast as possible, we first check whether the |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
486 " current buffer's tags file is 'maybe' being generated. This provides a |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
487 " nice and quick bail out for 99.9% of cases before we need to this the |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
488 " file-system to check the lock file. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
489 let l:modules_in_progress = [] |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
490 for module in keys(b:gutentags_files) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
491 let l:abs_tag_file = fnamemodify(b:gutentags_files[module], ':p') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
492 let l:progress_queue = s:maybe_in_progress[module] |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
493 let l:timestamp = get(l:progress_queue, l:abs_tag_file) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
494 if l:timestamp == 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
495 return '' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
496 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
497 " It's maybe generating! Check if the lock file is still there... but |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
498 " don't do it too soon after the script was originally launched, because |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
499 " there can be a race condition where we get here just before the script |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
500 " had a chance to write the lock file. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
501 if (localtime() - l:timestamp) > 1 && |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
502 \!filereadable(l:abs_tag_file . '.lock') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
503 call remove(l:progress_queue, l:abs_tag_file) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
504 return '' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
505 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
506 call add(l:modules_in_progress, module) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
507 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
508 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
509 " It's still there! So probably `ctags` is still running... |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
510 " (although there's a chance it crashed, or the script had a problem, and |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
511 " the lock file has been left behind... we could try and run some |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
512 " additional checks here to see if it's legitimately running, and |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
513 " otherwise delete the lock file... maybe in the future...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
514 if len(g:gutentags_modules) > 1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
515 let l:gen_msg .= '['.join(l:modules_in_progress, ',').']' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
516 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
517 return l:gen_msg |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
518 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
519 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
520 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
521 |