annotate autoload/gutentags.vim @ 172:02a94ff0db57

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