Mercurial > vim-gutentags
annotate autoload/gutentags.vim @ 174:721cba3cd20d
Don't apply `wildignore` when looking for markers
When folks have `.git` in their `wildignore`, the `globpath` function
will never find a project marker.
author | Rafael Bodill <justrafi@gmail.com> |
---|---|
date | Wed, 22 Feb 2017 00:42:49 +0200 |
parents | 2cf3fb66285b |
children | 8bac4b955c84 |
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 |
168 | 5 function! gutentags#pwd() |
6 if has('nvim') | |
7 return haslocaldir() ? getcwd(0, 0) : haslocaldir(-1, 0) ? getcwd(-1, 0) : getcwd() | |
8 else | |
9 return haslocaldir() ? getcwd(0, 0) : getcwd() | |
10 endif | |
11 endfunction | |
12 | |
13 function! gutentags#chdir(path) | |
14 if has('nvim') | |
15 let chdir = haslocaldir() ? 'lcd' : haslocaldir(-1, 0) ? 'tcd' : 'cd' | |
16 else | |
17 let chdir = haslocaldir() ? 'lcd' : 'cd' | |
18 endif | |
19 execute chdir a:path | |
20 endfunction | |
21 | |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 " Throw an exception message. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 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
|
24 throw "gutentags: " . a:message |
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
25 endfunction |
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
26 |
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
27 " 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
|
28 function! gutentags#throwerr(message) |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
29 let v:errmsg = "gutentags: " . a:message |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 throw v:errmsg |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
31 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
33 " 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
|
34 function! gutentags#trace(message, ...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 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
|
36 let l:message = "gutentags: " . a:message |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
37 echom l:message |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
38 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
40 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
41 " 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
|
42 function! gutentags#stripslash(path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
43 return fnamemodify(a:path, ':s?[/\\]$??') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
44 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
45 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
46 " Normalizes the slashes in a path. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
47 function! gutentags#normalizepath(path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
48 if exists('+shellslash') && &shellslash |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
49 return substitute(a:path, '\v/', '\\', 'g') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
50 elseif has('win32') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
51 return substitute(a:path, '\v/', '\\', 'g') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
52 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
53 return a:path |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
54 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
55 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
56 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
57 " 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
|
58 function! gutentags#shellslash(path) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
59 if exists('+shellslash') && !&shellslash |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
60 return substitute(a:path, '\v\\', '/', 'g') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
61 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
62 return a:path |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
63 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
64 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
65 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
66 " 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
|
67 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
|
68 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
|
69 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
70 |
75
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
70
diff
changeset
|
71 " 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
|
72 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
|
73 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
|
74 endfunction |
d12543f11eb9
Move the default `-R` option to an overridable "global" options file.
Ludovic Chabant <ludovic@chabant.com>
parents:
70
diff
changeset
|
75 |
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
|
76 " 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
|
77 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
|
78 function! gutentags#is_path_rooted(path) abort |
173
2cf3fb66285b
Use absolute paths for `ctags` if the tags file is not local.
Ludovic Chabant <ludovic@chabant.com>
parents:
169
diff
changeset
|
79 return len(a:path) >= 2 && ( |
2cf3fb66285b
Use absolute paths for `ctags` if the tags file is not local.
Ludovic Chabant <ludovic@chabant.com>
parents:
169
diff
changeset
|
80 \a:path[0] == '/' || a:path[0] == '\' || a:path[1] == ':') |
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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
88 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
89 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
90 " Gutentags Setup {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
91 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
92 let s:known_files = [] |
89
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
93 let s:known_projects = {} |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
94 |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
95 function! s:cache_project_root(path) abort |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
96 let l:result = {} |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
97 |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
98 for proj_info in g:gutentags_project_info |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
99 let l:filematch = get(proj_info, 'file', '') |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
100 if l:filematch != '' && filereadable(a:path . '/'. l:filematch) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
101 let l:result = copy(proj_info) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
102 break |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
103 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
104 |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
105 let l:globmatch = get(proj_info, 'glob', '') |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
106 if l:globmatch != '' && glob(a:path . '/' . l:globmatch) != '' |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
107 let l:result = copy(proj_info) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
108 break |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
109 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
110 endfor |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
111 |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
112 let s:known_projects[a:path] = l:result |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
113 endfunction |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
114 |
136
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
115 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
|
116 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
|
117 return a:cmd |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
118 endif |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
119 return "" |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
120 endfunction |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
121 |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
122 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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 endif |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
132 endfor |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
133 endif |
157
6b00f4383708
Support project root markers that are wildcard patterns.
Ludovic Chabant <ludovic@chabant.com>
parents:
148
diff
changeset
|
134 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
|
135 endif |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
136 return "" |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
137 endfunction |
286e5b3095d0
Allow restricting tag generation to files listed by custom commands
Stephen Kent <smkent@smkent.net>
parents:
134
diff
changeset
|
138 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
139 " 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
|
140 " file path. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
141 function! gutentags#get_project_root(path) abort |
146
3459a2522a3b
Enable Project Root Finder
thecontinium <thecontinium@outlook.com>
parents:
136
diff
changeset
|
142 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
|
143 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
|
144 endif |
a6ef1c860d07
Add support for custom root finders like `vim-projectroot`.
Ludovic Chabant <ludovic@chabant.com>
parents:
131
diff
changeset
|
145 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
146 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
|
147 let l:previous_path = "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
148 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
|
149 if exists('g:ctrlp_root_markers') |
134 | 150 for crm in g:ctrlp_root_markers |
151 if index(l:markers, crm) < 0 | |
152 call add(l:markers, crm) | |
153 endif | |
154 endfor | |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
155 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
156 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
|
157 for root in l:markers |
174
721cba3cd20d
Don't apply `wildignore` when looking for markers
Rafael Bodill <justrafi@gmail.com>
parents:
173
diff
changeset
|
158 if !empty(globpath(l:path, root, 1)) |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
159 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
|
160 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
|
161 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
|
162 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
|
163 \"' 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
|
164 \" 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
|
165 \"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
|
166 \1) |
b9965d1288c3
Don't enable Gutentags for markers at the root of the file-system.
Ludovic Chabant <ludovic@chabant.com>
parents:
89
diff
changeset
|
167 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
|
168 endif |
118
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
169 for ign in g:gutentags_exclude_project_root |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
170 if l:proj_dir == ign |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
171 call gutentags#trace( |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
172 \"Ignoring project root '" . l:proj_dir . |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
173 \"' because it is in the list of ignored" . |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
174 \" projects.") |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
175 call gutentags#throw("Ignore project: " . l:proj_dir) |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
176 endif |
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
177 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
|
178 return l:proj_dir |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
179 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
180 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
181 let l:previous_path = l:path |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
182 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
|
183 endwhile |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
184 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
|
185 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
186 |
89
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
187 " Get info on the project we're inside of. |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
188 function! gutentags#get_project_info(path) abort |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
189 return get(s:known_projects, a:path, {}) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
190 endfunction |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
191 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
192 " 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
|
193 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
|
194 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
|
195 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
|
196 endif |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
197 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
|
198 if g:gutentags_cache_dir != "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
199 " 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
|
200 " project root. |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
201 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
|
202 \tr(l:tag_path, '\/: ', '---_') |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
203 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
|
204 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
205 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
|
206 return l:tag_path |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
207 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
208 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
209 " Setup gutentags for the current buffer. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
210 function! gutentags#setup_gutentags() abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
211 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
|
212 " This buffer already has gutentags support. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
213 return |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
214 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
215 |
63
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
216 " 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
|
217 " (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
|
218 " other such things) |
166
1fe62e7f1fae
Don't trigger a tags generation for the empty startup buffer.
Ludovic Chabant <ludovic@chabant.com>
parents:
164
diff
changeset
|
219 " Also don't do anything for the default `[No Name]` buffer you get |
1fe62e7f1fae
Don't trigger a tags generation for the empty startup buffer.
Ludovic Chabant <ludovic@chabant.com>
parents:
164
diff
changeset
|
220 " after starting Vim. |
1fe62e7f1fae
Don't trigger a tags generation for the empty startup buffer.
Ludovic Chabant <ludovic@chabant.com>
parents:
164
diff
changeset
|
221 if &buftype != '' || bufname('%') == '' |
63
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
222 return |
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
223 endif |
0f5b4a36c920
Don't try to setup Gutentags for non normal buffers.
Ludovic Chabant <ludovic@chabant.com>
parents:
59
diff
changeset
|
224 |
88
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
225 " 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
|
226 if g:gutentags_init_user_func != '' && |
7bc4df0225d1
Add support for specifying buffer-specific tagfiles.
Ludovic Chabant <ludovic@chabant.com>
parents:
136
diff
changeset
|
227 \!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
|
228 call gutentags#trace("Ignoring '" . bufname('%') . "' because of " . |
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
229 \"custom user function.") |
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
230 return |
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
231 endif |
073e63cc0456
Add `gutentags_enabled_user_func` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
87
diff
changeset
|
232 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
233 " 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 endif |
123
76a4822aab76
Use existing b:gutentags_root
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
240 if !exists('b:gutentags_root') |
76a4822aab76
Use existing b:gutentags_root
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
241 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
|
242 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
|
243 if filereadable(b:gutentags_root . '/.notags') |
121
8310e4602de9
minor: fix typos / unbalanced quotes
Daniel Hahler <git@thequod.de>
parents:
102
diff
changeset
|
244 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
|
245 return |
7b419abf7fba
Add ability to disable Gutentags if a `.notags` file is at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
246 endif |
7b419abf7fba
Add ability to disable Gutentags if a `.notags` file is at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
46
diff
changeset
|
247 |
89
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
248 if !has_key(s:known_projects, b:gutentags_root) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
249 call s:cache_project_root(b:gutentags_root) |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
250 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
251 if g:gutentags_trace |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
252 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
|
253 if l:projnfo != {} |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
254 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
|
255 else |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
256 call gutentags#trace("No specific project type.") |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
257 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
258 endif |
8bf96f9f649c
Add support for project types.
Ludovic Chabant <ludovic@chabant.com>
parents:
88
diff
changeset
|
259 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
260 let b:gutentags_files = {} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
261 for module in g:gutentags_modules |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
262 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
|
263 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
264 catch /^gutentags\:/ |
118
2838af9ff980
Add `g:gutentags_exclude_project_root`.
Ludovic Chabant <ludovic@chabant.com>
parents:
102
diff
changeset
|
265 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
|
266 return |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
267 endtry |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
268 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
269 " 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
|
270 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
|
271 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
272 " 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
|
273 " 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
|
274 " 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
|
275 " 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
|
276 " errors. |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
277 let l:bn = bufnr('%') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
278 execute 'augroup gutentags_buffer_' . l:bn |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
279 execute ' autocmd!' |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
280 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
|
281 execute 'augroup end' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
282 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
283 " Miscellaneous commands. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
284 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
|
285 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
286 " 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
|
287 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
|
288 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
|
289 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
|
290 if l:found < 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
291 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
|
292 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
293 " 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 endif |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
302 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
303 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
304 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
305 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
306 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
307 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
308 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
309 " Tags File Management {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
310 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
311 " 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
|
312 let s:update_queue = {} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
313 let s:maybe_in_progress = {} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
314 for module in g:gutentags_modules |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
315 let s:update_queue[module] = [] |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
316 let s:maybe_in_progress[module] = {} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
317 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
318 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
319 " 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
|
320 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
|
321 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
|
322 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
323 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
324 " 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
|
325 function! gutentags#get_execute_cmd() abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
326 if has('win32') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
327 let l:cmd = '!start ' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
328 if g:gutentags_background_update |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
329 let l:cmd .= '/b ' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
330 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
331 return l:cmd |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
332 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
333 return '!' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
334 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
335 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
336 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
337 " 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
|
338 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
|
339 if has('win32') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
340 return '' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
341 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
342 return ' &' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
343 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
344 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
345 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
346 " (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
|
347 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
|
348 let l:bn = bufnr('%') |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
349 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
|
350 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
|
351 endfor |
101
32e3d047e54e
add user autocmds for after tags updated
David O'Trakoun <me@davidosomething.com>
parents:
90
diff
changeset
|
352 silent doautocmd User GutentagsUpdated |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
353 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
354 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
355 " (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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
361 endif |
101
32e3d047e54e
add user autocmds for after tags updated
David O'Trakoun <me@davidosomething.com>
parents:
90
diff
changeset
|
362 silent doautocmd User GutentagsUpdated |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
363 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
364 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
365 " 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
|
366 " write_mode: |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
367 " 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
|
368 " 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
|
369 " |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
370 " queue_mode: |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
371 " 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
|
372 " 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
|
373 " 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
|
374 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
|
375 " Figure out where to save. |
130
b6ec4caa22ff
Remember the buffer number in the `BufWritePost` callback.
Ludovic Chabant <ludovic@chabant.com>
parents:
124
diff
changeset
|
376 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
|
377 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
|
378 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
|
379 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
380 " 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
|
381 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
|
382 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
|
383 if a:queue_mode == 2 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
384 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
|
385 if l:idx < 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
386 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
|
387 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
388 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
|
389 \"' 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
|
390 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
|
391 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
|
392 \"' 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
|
393 elseif a:queue_mode == 0 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
394 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
|
395 \"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
|
396 else |
148
b178f2251982
Only set `v:errmsg` when we throw an actual error.
Ludovic Chabant <ludovic@chabant.com>
parents:
147
diff
changeset
|
397 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
|
398 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
399 return |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
400 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
401 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
402 " 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
|
403 " 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
|
404 " doing an incremental update. |
168 | 405 let l:prev_cwd = gutentags#pwd() |
406 call gutentags#chdir(fnameescape(l:proj_dir)) | |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
407 try |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
408 call call("gutentags#".a:module."#generate", |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
409 \[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
|
410 catch /^gutentags\:/ |
96bfe5c37f37
Error and abort if we'll be overwriting a non-ctags file.
Ludovic Chabant <ludovic@chabant.com>
parents:
83
diff
changeset
|
411 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
|
412 echom v:exception |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
413 finally |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
414 " Restore the current directory... |
168 | 415 call gutentags#chdir(fnameescape(l:prev_cwd)) |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
416 endtry |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
417 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
418 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
419 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
420 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
421 " Utility Functions {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
422 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
423 function! gutentags#rescan(...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
424 if exists('b:gutentags_files') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
425 unlet b:gutentags_files |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
426 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
427 if a:0 && a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
428 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
|
429 let l:gutentags_trace = 1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
430 endif |
82
a837021a2388
Fix broken call debug function.
Ludovic Chabant <ludovic@chabant.com>
parents:
80
diff
changeset
|
431 call gutentags#setup_gutentags() |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
432 if a:0 && a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
433 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
|
434 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
435 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
436 |
46
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
437 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
|
438 if exists('b:gutentags_files') |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
439 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
|
440 silent call delete(tagfile.'.lock') |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
441 endfor |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
442 endif |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
443 endfunction |
c0f56e4d52bd
Make a bunch of advanced commands opt-in only.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
444 |
41
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
445 function! gutentags#toggletrace(...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
446 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
|
447 if a:0 > 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
448 let g:gutentags_trace = a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
449 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
450 if g:gutentags_trace |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
451 echom "gutentags: Tracing is enabled." |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
452 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
453 echom "gutentags: Tracing is disabled." |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
454 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
455 echom "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
456 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
457 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
458 function! gutentags#fake(...) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
459 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
|
460 if a:0 > 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
461 let g:gutentags_fake = a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
462 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
463 if g:gutentags_fake |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
464 echom "gutentags: Now faking gutentags." |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
465 else |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
466 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
|
467 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
468 echom "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
469 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
470 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
471 function! gutentags#inprogress() |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
472 echom "gutentags: generations in progress:" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
473 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
|
474 echom mip |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
475 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
476 echom "" |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
477 endfunction |
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 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
480 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
481 " Statusline Functions {{{ |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
482 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
483 " 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
|
484 " buffer in the status line. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
485 " |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
486 " Arguments can be passed: |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
487 " - 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
|
488 " 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
|
489 " (defaults to empty strings) |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
490 " - 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
|
491 " (defaults to 'TAGS') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
492 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
493 function! gutentags#statusline(...) abort |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
494 if !exists('b:gutentags_files') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
495 " This buffer doesn't have gutentags. |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
496 return '' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
497 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
498 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
499 " 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
|
500 let l:gen_msg = 'TAGS' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
501 if a:0 > 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
502 let l:gen_msg = a:1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
503 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
504 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
505 " 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
|
506 " 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
|
507 " 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
|
508 " 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
|
509 let l:modules_in_progress = [] |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
510 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
|
511 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
|
512 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
|
513 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
|
514 if l:timestamp == 0 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
515 return '' |
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 " 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
|
518 " 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
|
519 " 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
|
520 " 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
|
521 if (localtime() - l:timestamp) > 1 && |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
522 \!filereadable(l:abs_tag_file . '.lock') |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
523 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
|
524 return '' |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
525 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
526 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
|
527 endfor |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
528 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
529 " 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
|
530 " (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
|
531 " 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
|
532 " 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
|
533 " 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
|
534 if len(g:gutentags_modules) > 1 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
535 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
|
536 endif |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
537 return l:gen_msg |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
538 endfunction |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
539 |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
540 " }}} |
99328cb71e75
Refactor Gutentags so functionality can be implemented in "modules".
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
541 |