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