Browse Source

Install vim-gutentags

Alois Mahdal 4 years ago
parent
commit
d1d62a831d

+ 3
- 0
.gitmodules View File

@@ -43,3 +43,6 @@
43 43
 [submodule "dotfiles/vim/bundle/vim-airline-themes"]
44 44
 	path = dotfiles/vim/bundle/vim-airline-themes
45 45
 	url = https://github.com/vim-airline/vim-airline-themes
46
+[submodule "dotfiles/vim/bundle/vim-gutentags"]
47
+	path = dotfiles/vim/bundle/vim-gutentags
48
+	url = https://github.com/ludovicchabant/vim-gutentags.git

+ 27
- 0
dotfiles/vim/bundle/vim-gutentags/.github/ISSUE_TEMPLATE/bug_report.md View File

@@ -0,0 +1,27 @@
1
+---
2
+name: Bug report
3
+about: Something's wrong?
4
+
5
+---
6
+
7
+**Describe the bug**
8
+Describe what the bug is about, and what you expected. Don't forget to format things nicely with Markdown. If applicable, post screenshots.
9
+
10
+**Steps to reproduce**
11
+1. Do this '...'
12
+2. Do that '...'
13
+3. Etc.
14
+
15
+**Share your setup**
16
+- What OS and version of Vim are you using?
17
+- What version of `ctags`, `gtags`, or whatever do you have installed?
18
+- Are you using `g:gutentags_cache_dir`?
19
+
20
+**Post the logs**
21
+- Run `:let g:gutentags_trace = 1`.
22
+- Reproduce the bug.
23
+- Run `:messages` and show the messages that Gutentags posted.
24
+- Look for the `tags.log` file that Gutentags' script left behind, and post its contents.
25
+
26
+**Additional context**
27
+Add any other context about the problem here.

+ 1
- 0
dotfiles/vim/bundle/vim-gutentags/.gitignore View File

@@ -0,0 +1 @@
1
+doc/tags

+ 3
- 0
dotfiles/vim/bundle/vim-gutentags/.hgignore View File

@@ -0,0 +1,3 @@
1
+syntax:regexp
2
+(^|/)tags$
3
+

+ 1
- 0
dotfiles/vim/bundle/vim-gutentags/.hgtags View File

@@ -0,0 +1 @@
1
+06c496e010b403703643284b12893c1f92b3e756 v1.0.0

+ 60
- 0
dotfiles/vim/bundle/vim-gutentags/CONTRIBUTING.md View File

@@ -0,0 +1,60 @@
1
+
2
+# Contributing
3
+
4
+You're thinking of contributing something to one of my projects? Oh my, I'm
5
+quite honoured! Here's what you need to know.
6
+
7
+
8
+## Writing
9
+
10
+Clone the repository from either [BitBucket][] (if you're into Mercurial) or
11
+[GitHub][] (if you're into Git).
12
+
13
+Next, create a branch for your work -- don't work directly on the `defaut` or
14
+`master` branch. Instead, in Mercurial:
15
+
16
+  $ hg bookmark my-fix
17
+
18
+Or, in Git:
19
+
20
+  $ git checkout -b my-fix master
21
+
22
+Make your changes. Don't write anything that's not related to the fix you're
23
+trying to contribute to the project.
24
+
25
+Write a simple, concise commit message. Gutentags isn't a big piece of code so
26
+no need for strict message formats, so don't get fancy.
27
+
28
+
29
+## Testing
30
+
31
+If you can, try and test your changes on multiple platforms -- Ubuntu, MacOS,
32
+and Windows are supposed to be supported.
33
+
34
+Also try to test your changes with:
35
+
36
+1. `g:gutentags_cache_dir` enabled and disabled.
37
+2. A repository with spaces in its root path.
38
+3. A repository with files and folders that have spaces in them.
39
+
40
+If you're on NeoVim, try and test on a "normal" Vim.
41
+
42
+
43
+## Pushing
44
+
45
+Once everything's fine, go on BitBucket or GitHub (again, depending on your
46
+favorite source control tool) and create a fork if you haven't done so yet. Push
47
+your changes to your fork, and create a pull request. Check the documentation of
48
+either code portal for more information.
49
+
50
+Don't worry if you don't see any reply from me for a while. My turn around time
51
+is measured in weeks, sometimes in months. This is normal -- I've got a job,
52
+a family, and open-source hacking is only one of many awesome hobbies I spend my
53
+limited free time on.
54
+
55
+That's it for now! And thanks a lot for contributing!
56
+
57
+
58
+[bitbucket]: https://bitbucket.org/ludovicchabant/vim-gutentags
59
+[github]: https://github.com/ludovicchabant/vim-gutentags
60
+

+ 23
- 0
dotfiles/vim/bundle/vim-gutentags/LICENSE View File

@@ -0,0 +1,23 @@
1
+
2
+The MIT License (MIT)
3
+
4
+Copyright (c) 2014 Ludovic Chabant
5
+
6
+Permission is hereby granted, free of charge, to any person obtaining a copy
7
+of this software and associated documentation files (the "Software"), to deal
8
+in the Software without restriction, including without limitation the rights
9
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+copies of the Software, and to permit persons to whom the Software is
11
+furnished to do so, subject to the following conditions:
12
+
13
+The above copyright notice and this permission notice shall be included in
14
+all copies or substantial portions of the Software.
15
+
16
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+THE SOFTWARE.
23
+

+ 81
- 0
dotfiles/vim/bundle/vim-gutentags/README.md View File

@@ -0,0 +1,81 @@
1
+
2
+# Gutentags
3
+
4
+Gutentags is a plugin that takes care of the much needed management of tags
5
+files in Vim. It will (re)generate tag files as you work while staying
6
+completely out of your way. It will even do its best to keep those tag files
7
+out of your way too. It has no dependencies and just works.
8
+
9
+
10
+## How?
11
+
12
+Install Gutentags like any other Vim plugin. I recommend something like
13
+[Pathogen][], so you can go:
14
+
15
+    cd ~/.vim/bundle
16
+    hg clone https://bitbucket.org/ludovicchabant/vim-gutentags
17
+
18
+If you're more into Git than Mercurial:
19
+
20
+    git clone https://github.com/ludovicchabant/vim-gutentags.git
21
+
22
+Then you only need to do a `:call pathogen#helptags()` to generate the
23
+documentation tags (how ironic, eh?) and you can access Gutentags' help pages
24
+with `help gutentags`.
25
+
26
+
27
+## What?
28
+
29
+In order to generate tag files, Gutentags will have to figure out what's in
30
+your project. To do this, it will locate well-known project root markers like
31
+SCM folders (`.git`, `.hg`, etc.), any custom tags you define (with
32
+`gutentags_project_root`), and even things you may have defined already with
33
+other plugins, like [CtrlP][].
34
+
35
+If the current file you're editing is found to be in such a project, Gutentags
36
+will make sure the tag file for that project is up to date. Then, as you work
37
+in files in that project, it will partially re-generate the tag file. Every
38
+time you save, it will silently, in the background, update the tags for that
39
+file.
40
+
41
+Usually, ctags can only append tags to an existing tag file, so Gutentags
42
+removes the tags for the current file first, to make sure the tag file is
43
+always consistent with the source code.
44
+
45
+Also, Gutentags is clever enough to not stumble upon itself by triggering
46
+multiple ctags processes if you save files too fast, or your project is really
47
+big.
48
+
49
+
50
+## Why?
51
+
52
+There are some similar Vim plugins out there ("vim-tags", "vim-autotag",
53
+"vim-automatic-ctags", etc.). They all fail on one or more of the requirements
54
+I set for myself with Gutentags:
55
+
56
+* No other dependency than running Vim: no Python, Ruby, or whatever.
57
+* Cross-platform: should work on at least Ubuntu, Mac, and Windows.
58
+* Incremental tags generation: don't re-generate the whole project all the time.
59
+  This may be fine for small projects, but it doesn't scale.
60
+* External process management: if the ctags process is taking a long time, don't
61
+  run another one because I saved a file again.
62
+* Keep the tag file consistent: don't just append the current file's tags to the
63
+  tag file, otherwise you will still "see" tags for deleted or renamed classes
64
+  and functions.
65
+* Automatically create the tag file: you open something from a freshly forked
66
+  project, it should start indexing it automatically, just like in Sublime Text
67
+  or Visual Studio or any other IDE.
68
+
69
+I hope Gutentags will bring you as much closure as me regarding tag files. I know
70
+I don't want to have to think about it, and probably neither do you.
71
+
72
+
73
+# Related Projects
74
+
75
+* [gutentags_plus](https://github.com/skywind3000/gutentags_plus): handles
76
+  switching between `cscope` databases automatically before performing a search
77
+  query.
78
+
79
+[Pathogen]: https://github.com/tpope/vim-pathogen
80
+[ctrlp]: https://github.com/kien/ctrlp.vim
81
+

+ 705
- 0
dotfiles/vim/bundle/vim-gutentags/autoload/gutentags.vim View File

@@ -0,0 +1,705 @@
1
+" gutentags.vim - Automatic ctags management for Vim
2
+
3
+" Utilities {{{
4
+
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
+
14
+" Throw an exception message.
15
+function! gutentags#throw(message)
16
+    throw "gutentags: " . a:message
17
+endfunction
18
+
19
+" Show an error message.
20
+function! gutentags#error(message)
21
+    let v:errmsg = "gutentags: " . a:message
22
+    echoerr v:errmsg
23
+endfunction
24
+
25
+" Show a warning message.
26
+function! gutentags#warning(message)
27
+    echohl WarningMsg
28
+    echom "gutentags: " . a:message
29
+    echohl None
30
+endfunction
31
+
32
+" Prints a message if debug tracing is enabled.
33
+function! gutentags#trace(message, ...)
34
+    if g:gutentags_trace || (a:0 && a:1)
35
+        let l:message = "gutentags: " . a:message
36
+        echom l:message
37
+    endif
38
+endfunction
39
+
40
+" Strips the ending slash in a path.
41
+function! gutentags#stripslash(path)
42
+    return fnamemodify(a:path, ':s?[/\\]$??')
43
+endfunction
44
+
45
+" Normalizes the slashes in a path.
46
+function! gutentags#normalizepath(path)
47
+    if exists('+shellslash') && &shellslash
48
+        return substitute(a:path, '\v/', '\\', 'g')
49
+    elseif has('win32')
50
+        return substitute(a:path, '\v/', '\\', 'g')
51
+    else
52
+        return a:path
53
+    endif
54
+endfunction
55
+
56
+" Shell-slashes the path (opposite of `normalizepath`).
57
+function! gutentags#shellslash(path)
58
+    if exists('+shellslash') && !&shellslash
59
+        return substitute(a:path, '\v\\', '/', 'g')
60
+    else
61
+        return a:path
62
+    endif
63
+endfunction
64
+
65
+" Gets a file path in the correct `plat` folder.
66
+function! gutentags#get_plat_file(filename) abort
67
+    return g:gutentags_plat_dir . a:filename . g:gutentags_script_ext
68
+endfunction
69
+
70
+" Gets a file path in the resource folder.
71
+function! gutentags#get_res_file(filename) abort
72
+    return g:gutentags_res_dir . a:filename
73
+endfunction
74
+
75
+" Generate a path for a given filename in the cache directory.
76
+function! gutentags#get_cachefile(root_dir, filename) abort
77
+    if gutentags#is_path_rooted(a:filename)
78
+        return a:filename
79
+    endif
80
+    let l:tag_path = gutentags#stripslash(a:root_dir) . '/' . a:filename
81
+    if g:gutentags_cache_dir != ""
82
+        " Put the tag file in the cache dir instead of inside the
83
+        " project root.
84
+        let l:tag_path = g:gutentags_cache_dir . '/' .
85
+                    \tr(l:tag_path, '\/: ', '---_')
86
+        let l:tag_path = substitute(l:tag_path, '/\-', '/', '')
87
+        let l:tag_path = substitute(l:tag_path, '[\-_]*$', '', '')
88
+    endif
89
+    let l:tag_path = gutentags#normalizepath(l:tag_path)
90
+    return l:tag_path
91
+endfunction
92
+
93
+" Makes sure a given command starts with an executable that's in the PATH.
94
+function! gutentags#validate_cmd(cmd) abort
95
+    if !empty(a:cmd) && executable(split(a:cmd)[0])
96
+        return a:cmd
97
+    endif
98
+    return ""
99
+endfunction
100
+
101
+" Makes an appropriate command line for use with `job_start` by converting
102
+" a list of possibly quoted arguments into a single string on Windows, or
103
+" into a list of unquoted arguments on Unix/Mac.
104
+if has('win32') || has('win64')
105
+    function! gutentags#make_args(cmd) abort
106
+        return join(a:cmd, ' ')
107
+    endfunction
108
+else
109
+    function! gutentags#make_args(cmd) abort
110
+        let l:outcmd = []
111
+        for cmdarg in a:cmd
112
+            " Thanks Vimscript... you can use negative integers for strings
113
+            " in the slice notation, but not for indexing characters :(
114
+            let l:arglen = strlen(cmdarg)
115
+            if (cmdarg[0] == '"' && cmdarg[l:arglen - 1] == '"') || 
116
+                        \(cmdarg[0] == "'" && cmdarg[l:arglen - 1] == "'")
117
+                call add(l:outcmd, cmdarg[1:-2])
118
+            else
119
+                call add(l:outcmd, cmdarg)
120
+            endif
121
+        endfor
122
+        return l:outcmd
123
+    endfunction
124
+endif
125
+
126
+" Returns whether a path is rooted.
127
+if has('win32') || has('win64')
128
+    function! gutentags#is_path_rooted(path) abort
129
+        return len(a:path) >= 2 && (
130
+                    \a:path[0] == '/' || a:path[0] == '\' || a:path[1] == ':')
131
+    endfunction
132
+else
133
+    function! gutentags#is_path_rooted(path) abort
134
+        return !empty(a:path) && a:path[0] == '/'
135
+    endfunction
136
+endif
137
+
138
+" }}}
139
+
140
+" Gutentags Setup {{{
141
+
142
+let s:known_files = []
143
+let s:known_projects = {}
144
+
145
+function! s:cache_project_root(path) abort
146
+    let l:result = {}
147
+
148
+    for proj_info in g:gutentags_project_info
149
+        let l:filematch = get(proj_info, 'file', '')
150
+        if l:filematch != '' && filereadable(a:path . '/'. l:filematch)
151
+            let l:result = copy(proj_info)
152
+            break
153
+        endif
154
+
155
+        let l:globmatch = get(proj_info, 'glob', '')
156
+        if l:globmatch != '' && glob(a:path . '/' . l:globmatch) != ''
157
+            let l:result = copy(proj_info)
158
+            break
159
+        endif
160
+    endfor
161
+
162
+    let s:known_projects[a:path] = l:result
163
+endfunction
164
+
165
+function! gutentags#get_project_file_list_cmd(path) abort
166
+    if type(g:gutentags_file_list_command) == type("")
167
+        return gutentags#validate_cmd(g:gutentags_file_list_command)
168
+    elseif type(g:gutentags_file_list_command) == type({})
169
+        let l:markers = get(g:gutentags_file_list_command, 'markers', [])
170
+        if type(l:markers) == type({})
171
+            for [marker, file_list_cmd] in items(l:markers)
172
+                if !empty(globpath(a:path, marker, 1))
173
+                    return gutentags#validate_cmd(file_list_cmd)
174
+                endif
175
+            endfor
176
+        endif
177
+        return get(g:gutentags_file_list_command, 'default', "")
178
+    endif
179
+    return ""
180
+endfunction
181
+
182
+" Finds the first directory with a project marker by walking up from the given
183
+" file path.
184
+function! gutentags#get_project_root(path) abort
185
+    if g:gutentags_project_root_finder != ''
186
+        return call(g:gutentags_project_root_finder, [a:path])
187
+    endif
188
+    return gutentags#default_get_project_root(a:path)
189
+endfunction
190
+
191
+" Default implementation for finding project markers... useful when a custom
192
+" finder (`g:gutentags_project_root_finder`) wants to fallback to the default
193
+" behaviour.
194
+function! gutentags#default_get_project_root(path) abort
195
+    let l:path = gutentags#stripslash(a:path)
196
+    let l:previous_path = ""
197
+    let l:markers = g:gutentags_project_root[:]
198
+    if g:gutentags_add_ctrlp_root_markers && exists('g:ctrlp_root_markers')
199
+        for crm in g:ctrlp_root_markers
200
+            if index(l:markers, crm) < 0
201
+                call add(l:markers, crm)
202
+            endif
203
+        endfor
204
+    endif
205
+    while l:path != l:previous_path
206
+        for root in l:markers
207
+            if !empty(globpath(l:path, root, 1))
208
+                let l:proj_dir = simplify(fnamemodify(l:path, ':p'))
209
+                let l:proj_dir = gutentags#stripslash(l:proj_dir)
210
+                if l:proj_dir == ''
211
+                    call gutentags#trace("Found project marker '" . root .
212
+                                \"' at the root of your file-system! " .
213
+                                \" That's probably wrong, disabling " .
214
+                                \"gutentags for this file...",
215
+                                \1)
216
+                    call gutentags#throw("Marker found at root, aborting.")
217
+                endif
218
+                for ign in g:gutentags_exclude_project_root
219
+                    if l:proj_dir == ign
220
+                        call gutentags#trace(
221
+                                    \"Ignoring project root '" . l:proj_dir .
222
+                                    \"' because it is in the list of ignored" .
223
+                                    \" projects.")
224
+                        call gutentags#throw("Ignore project: " . l:proj_dir)
225
+                    endif
226
+                endfor
227
+                return l:proj_dir
228
+            endif
229
+        endfor
230
+        let l:previous_path = l:path
231
+        let l:path = fnamemodify(l:path, ':h')
232
+    endwhile
233
+    call gutentags#throw("Can't figure out what tag file to use for: " . a:path)
234
+endfunction
235
+
236
+" Get info on the project we're inside of.
237
+function! gutentags#get_project_info(path) abort
238
+    return get(s:known_projects, a:path, {})
239
+endfunction
240
+
241
+" Setup gutentags for the current buffer.
242
+function! gutentags#setup_gutentags() abort
243
+    if exists('b:gutentags_files') && !g:gutentags_debug
244
+        " This buffer already has gutentags support.
245
+        return
246
+    endif
247
+
248
+    " Don't setup gutentags for anything that's not a normal buffer
249
+    " (so don't do anything for help buffers and quickfix windows and
250
+    "  other such things)
251
+    " Also don't do anything for the default `[No Name]` buffer you get
252
+    " after starting Vim.
253
+    if &buftype != '' || 
254
+          \(bufname('%') == '' && !g:gutentags_generate_on_empty_buffer)
255
+        return
256
+    endif
257
+
258
+    " Don't setup gutentags for things that don't need it, or that could
259
+    " cause problems.
260
+    if index(g:gutentags_exclude_filetypes, &filetype) >= 0
261
+        return
262
+    endif
263
+
264
+    " Let the user specify custom ways to disable Gutentags.
265
+    if g:gutentags_init_user_func != '' &&
266
+                \!call(g:gutentags_init_user_func, [expand('%:p')])
267
+        call gutentags#trace("Ignoring '" . bufname('%') . "' because of " .
268
+                    \"custom user function.")
269
+        return
270
+    endif
271
+
272
+    " Try and find what tags file we should manage.
273
+    call gutentags#trace("Scanning buffer '" . bufname('%') . "' for gutentags setup...")
274
+    try
275
+        let l:buf_dir = expand('%:p:h', 1)
276
+        if g:gutentags_resolve_symlinks
277
+            let l:buf_dir = fnamemodify(resolve(expand('%:p', 1)), ':p:h')
278
+        endif
279
+        if !exists('b:gutentags_root')
280
+            let b:gutentags_root = gutentags#get_project_root(l:buf_dir)
281
+        endif
282
+        if !len(b:gutentags_root)
283
+            call gutentags#trace("no valid project root.. no gutentags support.")
284
+            return
285
+        endif
286
+        if filereadable(b:gutentags_root . '/.notags')
287
+            call gutentags#trace("'.notags' file found... no gutentags support.")
288
+            return
289
+        endif
290
+
291
+        if !has_key(s:known_projects, b:gutentags_root)
292
+            call s:cache_project_root(b:gutentags_root)
293
+        endif
294
+        if g:gutentags_trace
295
+            let l:projnfo = gutentags#get_project_info(b:gutentags_root)
296
+            if l:projnfo != {}
297
+                call gutentags#trace("Setting project type to ".l:projnfo['type'])
298
+            else
299
+                call gutentags#trace("No specific project type.")
300
+            endif
301
+        endif
302
+
303
+        let b:gutentags_files = {}
304
+        for module in g:gutentags_modules
305
+            call call("gutentags#".module."#init", [b:gutentags_root])
306
+        endfor
307
+    catch /^gutentags\:/
308
+        call gutentags#trace("No gutentags support for this buffer.")
309
+        return
310
+    endtry
311
+
312
+    " We know what tags file to manage! Now set things up.
313
+    call gutentags#trace("Setting gutentags for buffer '".bufname('%')."'")
314
+
315
+    " Autocommands for updating the tags on save.
316
+    " We need to pass the buffer number to the callback function in the rare
317
+    " case that the current buffer is changed by another `BufWritePost`
318
+    " callback. This will let us get that buffer's variables without causing
319
+    " errors.
320
+    let l:bn = bufnr('%')
321
+    execute 'augroup gutentags_buffer_' . l:bn
322
+    execute '  autocmd!'
323
+    execute '  autocmd BufWritePost <buffer=' . l:bn . '> call s:write_triggered_update_tags(' . l:bn . ')'
324
+    execute 'augroup end'
325
+
326
+    " Miscellaneous commands.
327
+    command! -buffer -bang GutentagsUpdate :call s:manual_update_tags(<bang>0)
328
+
329
+    " Add these tags files to the known tags files.
330
+    for module in keys(b:gutentags_files)
331
+        let l:tagfile = b:gutentags_files[module]
332
+        let l:found = index(s:known_files, l:tagfile)
333
+        if l:found < 0
334
+            call add(s:known_files, l:tagfile)
335
+
336
+            " Generate this new file depending on settings and stuff.
337
+            if g:gutentags_enabled
338
+                if g:gutentags_generate_on_missing && !filereadable(l:tagfile)
339
+                    call gutentags#trace("Generating missing tags file: " . l:tagfile)
340
+                    call s:update_tags(l:bn, module, 1, 1)
341
+                elseif g:gutentags_generate_on_new
342
+                    call gutentags#trace("Generating tags file: " . l:tagfile)
343
+                    call s:update_tags(l:bn, module, 1, 1)
344
+                endif
345
+            endif
346
+        endif
347
+    endfor
348
+endfunction
349
+
350
+" }}}
351
+
352
+"  Job Management {{{
353
+
354
+" List of queued-up jobs, and in-progress jobs, per module.
355
+let s:update_queue = {}
356
+let s:update_in_progress = {}
357
+for module in g:gutentags_modules
358
+    let s:update_queue[module] = []
359
+    let s:update_in_progress[module] = []
360
+endfor
361
+
362
+function! gutentags#add_job(module, tags_file, data) abort
363
+    call add(s:update_in_progress[a:module], [a:tags_file, a:data])
364
+endfunction
365
+
366
+function! gutentags#find_job_index_by_tags_file(module, tags_file) abort
367
+    let l:idx = -1
368
+    for upd_info in s:update_in_progress[a:module]
369
+        let l:idx += 1
370
+        if upd_info[0] == a:tags_file
371
+            return l:idx
372
+        endif
373
+    endfor
374
+    return -1
375
+endfunction
376
+
377
+function! gutentags#find_job_index_by_data(module, data) abort
378
+    let l:idx = -1
379
+    for upd_info in s:update_in_progress[a:module]
380
+        let l:idx += 1
381
+        if upd_info[1] == a:data
382
+            return l:idx
383
+        endif
384
+    endfor
385
+    return -1
386
+endfunction
387
+
388
+function! gutentags#get_job_tags_file(module, job_idx) abort
389
+    return s:update_in_progress[a:module][a:job_idx][0]
390
+endfunction
391
+
392
+function! gutentags#get_job_data(module, job_idx) abort
393
+    return s:update_in_progress[a:module][a:job_idx][1]
394
+endfunction
395
+
396
+function! gutentags#remove_job(module, job_idx) abort
397
+    let l:tags_file = s:update_in_progress[a:module][a:job_idx][0]
398
+    call remove(s:update_in_progress[a:module], a:job_idx)
399
+
400
+    " Run the user callback for finished jobs.
401
+    silent doautocmd User GutentagsUpdated
402
+
403
+    " See if we had any more updates queued up for this.
404
+    let l:qu_idx = -1
405
+    for qu_info in s:update_queue[a:module]
406
+        let l:qu_idx += 1
407
+        if qu_info[0] == l:tags_file
408
+            break
409
+        endif
410
+    endfor
411
+    if l:qu_idx >= 0
412
+        let l:qu_info = s:update_queue[a:module][l:qu_idx]
413
+        call remove(s:update_queue[a:module], l:qu_idx)
414
+
415
+        if bufexists(l:qu_info[1])
416
+            call gutentags#trace("Finished ".a:module." job, ".
417
+                        \"running queued update for '".l:tags_file."'.")
418
+            call s:update_tags(l:qu_info[1], a:module, l:qu_info[2], 2)
419
+        else
420
+            call gutentags#trace("Finished ".a:module." job, ".
421
+                        \"but skipping queued update for '".l:tags_file."' ".
422
+                        \"because originating buffer doesn't exist anymore.")
423
+        endif
424
+    else
425
+        call gutentags#trace("Finished ".a:module." job.")
426
+    endif
427
+endfunction
428
+
429
+function! gutentags#remove_job_by_data(module, data) abort
430
+    let l:idx = gutentags#find_job_index_by_data(a:module, a:data)
431
+    call gutentags#remove_job(a:module, l:idx)
432
+endfunction
433
+
434
+" }}}
435
+
436
+"  Tags File Management {{{
437
+
438
+" (Re)Generate the tags file for the current buffer's file.
439
+function! s:manual_update_tags(bang) abort
440
+    let l:restore_prev_trace = 0
441
+    let l:prev_trace = g:gutentags_trace
442
+    if &verbose > 0
443
+        let g:gutentags_trace = 1
444
+        let l:restore_prev_trace = 1
445
+    endif
446
+
447
+    try
448
+        let l:bn = bufnr('%')
449
+        for module in g:gutentags_modules
450
+            call s:update_tags(l:bn, module, a:bang, 0)
451
+        endfor
452
+        silent doautocmd User GutentagsUpdating
453
+    finally
454
+        if l:restore_prev_trace
455
+            let g:gutentags_trace = l:prev_trace
456
+        endif
457
+    endtry
458
+endfunction
459
+
460
+" (Re)Generate the tags file for a buffer that just go saved.
461
+function! s:write_triggered_update_tags(bufno) abort
462
+    if g:gutentags_enabled && g:gutentags_generate_on_write
463
+        for module in g:gutentags_modules
464
+            call s:update_tags(a:bufno, module, 0, 2)
465
+        endfor
466
+    endif
467
+    silent doautocmd User GutentagsUpdating
468
+endfunction
469
+
470
+" Update the tags file for the current buffer's file.
471
+" write_mode:
472
+"   0: update the tags file if it exists, generate it otherwise.
473
+"   1: always generate (overwrite) the tags file.
474
+"
475
+" queue_mode:
476
+"   0: if an update is already in progress, report it and abort.
477
+"   1: if an update is already in progress, abort silently.
478
+"   2: if an update is already in progress, queue another one.
479
+function! s:update_tags(bufno, module, write_mode, queue_mode) abort
480
+    " Figure out where to save.
481
+    let l:buf_gutentags_files = getbufvar(a:bufno, 'gutentags_files')
482
+    let l:tags_file = l:buf_gutentags_files[a:module]
483
+    let l:proj_dir = getbufvar(a:bufno, 'gutentags_root')
484
+
485
+    " Check that there's not already an update in progress.
486
+    let l:in_progress_idx = gutentags#find_job_index_by_tags_file(
487
+                \a:module, l:tags_file)
488
+    if l:in_progress_idx >= 0
489
+        if a:queue_mode == 2
490
+            let l:needs_queuing = 1
491
+            for qu_info in s:update_queue[a:module]
492
+                if qu_info[0] == l:tags_file
493
+                    let l:needs_queuing = 0
494
+                    break
495
+                endif
496
+            endfor
497
+            if l:needs_queuing
498
+                call add(s:update_queue[a:module], 
499
+                            \[l:tags_file, a:bufno, a:write_mode])
500
+            endif
501
+            call gutentags#trace("Tag file '" . l:tags_file . 
502
+                        \"' is already being updated. Queuing it up...")
503
+        elseif a:queue_mode == 1
504
+            call gutentags#trace("Tag file '" . l:tags_file .
505
+                        \"' is already being updated. Skipping...")
506
+        elseif a:queue_mode == 0
507
+            echom "gutentags: The tags file is already being updated, " .
508
+                        \"please try again later."
509
+        else
510
+            call gutentags#throw("Unknown queue mode: " . a:queue_mode)
511
+        endif
512
+
513
+        " Don't update the tags right now.
514
+        return
515
+    endif
516
+
517
+    " Switch to the project root to make the command line smaller, and make
518
+    " it possible to get the relative path of the filename to parse if we're
519
+    " doing an incremental update.
520
+    let l:prev_cwd = getcwd()
521
+    call gutentags#chdir(fnameescape(l:proj_dir))
522
+    try
523
+        call call("gutentags#".a:module."#generate",
524
+                    \[l:proj_dir, l:tags_file,
525
+                    \ {
526
+                    \   'write_mode': a:write_mode,
527
+                    \ }])
528
+    catch /^gutentags\:/
529
+        echom "Error while generating ".a:module." file:"
530
+        echom v:exception
531
+    finally
532
+        " Restore the current directory...
533
+        call gutentags#chdir(fnameescape(l:prev_cwd))
534
+    endtry
535
+endfunction
536
+
537
+" }}}
538
+
539
+" Utility Functions {{{
540
+
541
+function! gutentags#rescan(...)
542
+    if exists('b:gutentags_files')
543
+        unlet b:gutentags_files
544
+    endif
545
+    if a:0 && a:1
546
+        let l:trace_backup = g:gutentags_trace
547
+        let l:gutentags_trace = 1
548
+    endif
549
+    call gutentags#setup_gutentags()
550
+    if a:0 && a:1
551
+        let g:gutentags_trace = l:trace_backup
552
+    endif
553
+endfunction
554
+
555
+function! gutentags#toggletrace(...)
556
+    let g:gutentags_trace = !g:gutentags_trace
557
+    if a:0 > 0
558
+        let g:gutentags_trace = a:1
559
+    endif
560
+    if g:gutentags_trace
561
+        echom "gutentags: Tracing is enabled."
562
+    else
563
+        echom "gutentags: Tracing is disabled."
564
+    endif
565
+    echom ""
566
+endfunction
567
+
568
+function! gutentags#fake(...)
569
+    let g:gutentags_fake = !g:gutentags_fake
570
+    if a:0 > 0
571
+        let g:gutentags_fake = a:1
572
+    endif
573
+    if g:gutentags_fake
574
+        echom "gutentags: Now faking gutentags."
575
+    else
576
+        echom "gutentags: Now running gutentags for real."
577
+    endif
578
+    echom ""
579
+endfunction
580
+
581
+function! gutentags#default_io_cb(chan, msg) abort
582
+    call gutentags#trace('[job output]: '.string(a:msg))
583
+endfunction
584
+
585
+if has('nvim')
586
+    " Neovim job API.
587
+    function! s:nvim_job_exit_wrapper(real_cb, job, exit_code, event_type) abort
588
+        call call(a:real_cb, [a:job, a:exit_code])
589
+    endfunction
590
+
591
+    function! s:nvim_job_out_wrapper(real_cb, job, lines, event_type) abort
592
+        call call(a:real_cb, [a:job, a:lines])
593
+    endfunction
594
+
595
+    function! gutentags#build_default_job_options(module) abort
596
+       " Neovim kills jobs on exit, which is what we want.
597
+       let l:job_opts = {
598
+                \'on_exit': function(
599
+                \    '<SID>nvim_job_exit_wrapper',
600
+                \    ['gutentags#'.a:module.'#on_job_exit']),
601
+                \'on_stdout': function(
602
+                \    '<SID>nvim_job_out_wrapper',
603
+                \    ['gutentags#default_io_cb']),
604
+                \'on_stderr': function(
605
+                \    '<SID>nvim_job_out_wrapper',
606
+                \    ['gutentags#default_io_cb'])
607
+                \}
608
+       return l:job_opts
609
+    endfunction
610
+
611
+    function! gutentags#start_job(cmd, opts) abort
612
+        return jobstart(a:cmd, a:opts)
613
+    endfunction
614
+else
615
+    " Vim8 job API.
616
+    function! gutentags#build_default_job_options(module) abort
617
+        let l:job_opts = {
618
+                 \'exit_cb': 'gutentags#'.a:module.'#on_job_exit',
619
+                 \'out_cb': 'gutentags#default_io_cb',
620
+                 \'err_cb': 'gutentags#default_io_cb',
621
+                 \'stoponexit': 'term'
622
+                 \}
623
+        return l:job_opts
624
+    endfunction
625
+
626
+    function! gutentags#start_job(cmd, opts) abort
627
+        return job_start(a:cmd, a:opts)
628
+    endfunction
629
+endif
630
+
631
+" Returns which modules are currently generating something for the
632
+" current buffer.
633
+function! gutentags#inprogress()
634
+    " Does this buffer have gutentags enabled?
635
+    if !exists('b:gutentags_files')
636
+        return []
637
+    endif
638
+
639
+    " Find any module that has a job in progress for any of this buffer's
640
+    " tags files.
641
+    let l:modules_in_progress = []
642
+    for [module, tags_file] in items(b:gutentags_files)
643
+        let l:jobidx = gutentags#find_job_index_by_tags_file(module, tags_file)
644
+        if l:jobidx >= 0
645
+            call add(l:modules_in_progress, module)
646
+        endif
647
+    endfor
648
+    return l:modules_in_progress
649
+endfunction
650
+
651
+" }}}
652
+
653
+" Statusline Functions {{{
654
+
655
+" Prints whether a tag file is being generated right now for the current
656
+" buffer in the status line.
657
+"
658
+" Arguments can be passed:
659
+" - args 1 and 2 are the prefix and suffix, respectively, of whatever output,
660
+"   if any, is going to be produced.
661
+"   (defaults to empty strings)
662
+" - arg 3 is the text to be shown if tags are currently being generated.
663
+"   (defaults to the name(s) of the modules currently generating).
664
+
665
+function! gutentags#statusline(...) abort
666
+    let l:modules_in_progress = gutentags#inprogress()
667
+    if empty(l:modules_in_progress)
668
+       return ''
669
+    endif
670
+
671
+    let l:prefix = ''
672
+    let l:suffix = ''
673
+    if a:0 > 0
674
+       let l:prefix = a:1
675
+    endif
676
+    if a:0 > 1
677
+       let l:suffix = a:2
678
+    endif
679
+
680
+    if a:0 > 2
681
+       let l:genmsg = a:3
682
+    else
683
+       let l:genmsg = join(l:modules_in_progress, ',')
684
+    endif
685
+
686
+    return l:prefix.l:genmsg.l:suffix
687
+endfunction
688
+
689
+" Same as `gutentags#statusline`, but the only parameter is a `Funcref` or
690
+" function name that will get passed the list of modules currently generating
691
+" something. This formatter function should return the string to display in
692
+" the status line.
693
+
694
+function! gutentags#statusline_cb(fmt_cb, ...) abort
695
+    let l:modules_in_progress = gutentags#inprogress()
696
+
697
+    if (a:0 == 0 || !a:1) && empty(l:modules_in_progress)
698
+       return ''
699
+    endif
700
+
701
+    return call(a:fmt_cb, [l:modules_in_progress])
702
+endfunction
703
+
704
+" }}}
705
+

+ 93
- 0
dotfiles/vim/bundle/vim-gutentags/autoload/gutentags/cscope.vim View File

@@ -0,0 +1,93 @@
1
+" Cscope module for Gutentags
2
+
3
+if !has('cscope')
4
+    throw "Can't enable the cscope module for Gutentags, this Vim has ".
5
+                \"no support for cscope files."
6
+endif
7
+
8
+" Global Options {{{
9
+
10
+if !exists('g:gutentags_cscope_executable')
11
+    let g:gutentags_cscope_executable = 'cscope'
12
+endif
13
+
14
+if !exists('g:gutentags_scopefile')
15
+    let g:gutentags_scopefile = 'cscope.out'
16
+endif
17
+
18
+if !exists('g:gutentags_auto_add_cscope')
19
+    let g:gutentags_auto_add_cscope = 1
20
+endif
21
+
22
+if !exists('g:gutentags_cscope_build_inverted_index')
23
+    let g:gutentags_cscope_build_inverted_index = 0
24
+endif
25
+
26
+" }}}
27
+
28
+" Gutentags Module Interface {{{
29
+
30
+let s:runner_exe = gutentags#get_plat_file('update_scopedb')
31
+let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
32
+let s:added_dbs = []
33
+
34
+function! gutentags#cscope#init(project_root) abort
35
+    let l:dbfile_path = gutentags#get_cachefile(
36
+                \a:project_root, g:gutentags_scopefile)
37
+    let b:gutentags_files['cscope'] = l:dbfile_path
38
+
39
+    if g:gutentags_auto_add_cscope && filereadable(l:dbfile_path)
40
+        if index(s:added_dbs, l:dbfile_path) < 0
41
+            call add(s:added_dbs, l:dbfile_path)
42
+            silent! execute 'cs add ' . fnameescape(l:dbfile_path)
43
+        endif
44
+    endif
45
+endfunction
46
+
47
+function! gutentags#cscope#generate(proj_dir, tags_file, gen_opts) abort
48
+    let l:cmd = [s:runner_exe]
49
+    let l:cmd += ['-e', g:gutentags_cscope_executable]
50
+    let l:cmd += ['-p', a:proj_dir]
51
+    let l:cmd += ['-f', a:tags_file]
52
+    let l:file_list_cmd =
53
+        \ gutentags#get_project_file_list_cmd(a:proj_dir)
54
+    if !empty(l:file_list_cmd)
55
+        let l:cmd += ['-L', '"' . l:file_list_cmd . '"']
56
+    endif
57
+    if g:gutentags_cscope_build_inverted_index
58
+        let l:cmd += ['-I']
59
+    endif
60
+    let l:cmd = gutentags#make_args(l:cmd)
61
+
62
+    call gutentags#trace("Running: " . string(l:cmd))
63
+    call gutentags#trace("In:      " . getcwd())
64
+    if !g:gutentags_fake
65
+		let l:job_opts = gutentags#build_default_job_options('cscope')
66
+        let l:job = gutentags#start_job(l:cmd, l:job_opts)
67
+        call gutentags#add_job('cscope', a:tags_file, l:job)
68
+    else
69
+        call gutentags#trace("(fake... not actually running)")
70
+    endif
71
+endfunction
72
+
73
+function! gutentags#cscope#on_job_exit(job, exit_val) abort
74
+    let l:job_idx = gutentags#find_job_index_by_data('cscope', a:job)
75
+    let l:dbfile_path = gutentags#get_job_tags_file('cscope', l:job_idx)
76
+    call gutentags#remove_job('cscope', l:job_idx)
77
+
78
+    if a:exit_val == 0
79
+        if index(s:added_dbs, l:dbfile_path) < 0
80
+            call add(s:added_dbs, l:dbfile_path)
81
+            silent! execute 'cs add ' . fnameescape(l:dbfile_path)
82
+        else
83
+            silent! execute 'cs reset'
84
+        endif
85
+    else
86
+        call gutentags#warning(
87
+                    \"cscope job failed, returned: ".
88
+                    \string(a:exit_val))
89
+    endif
90
+endfunction
91
+
92
+" }}}
93
+

+ 294
- 0
dotfiles/vim/bundle/vim-gutentags/autoload/gutentags/ctags.vim View File

@@ -0,0 +1,294 @@
1
+" Ctags module for Gutentags
2
+
3
+" Global Options {{{
4
+
5
+let g:gutentags_ctags_executable = get(g:, 'gutentags_ctags_executable', 'ctags')
6
+let g:gutentags_ctags_tagfile = get(g:, 'gutentags_ctags_tagfile', 'tags')
7
+let g:gutentags_ctags_auto_set_tags = get(g:, 'gutentags_ctags_auto_set_tags', 1)
8
+
9
+let g:gutentags_ctags_options_file = get(g:, 'gutentags_ctags_options_file', '.gutctags')
10
+let g:gutentags_ctags_check_tagfile = get(g:, 'gutentags_ctags_check_tagfile', 0)
11
+let g:gutentags_ctags_extra_args = get(g:, 'gutentags_ctags_extra_args', [])
12
+let g:gutentags_ctags_post_process_cmd = get(g:, 'gutentags_ctags_post_process_cmd', '')
13
+
14
+let g:gutentags_ctags_exclude = get(g:, 'gutentags_ctags_exclude', [])
15
+let g:gutentags_ctags_exclude_wildignore = get(g:, 'gutentags_ctags_exclude_wildignore', 1)
16
+
17
+" Backwards compatibility.
18
+function! s:_handleOldOptions() abort
19
+    let l:renamed_options = {
20
+                \'gutentags_exclude': 'gutentags_ctags_exclude',
21
+                \'gutentags_tagfile': 'gutentags_ctags_tagfile',
22
+                \'gutentags_auto_set_tags': 'gutentags_ctags_auto_set_tags'
23
+                \}
24
+    for key in keys(l:renamed_options)
25
+        if exists('g:'.key)
26
+            let newname = l:renamed_options[key]
27
+            echom "gutentags: Option 'g:'".key." has been renamed to ".
28
+                        \"'g:'".newname." Please update your vimrc."
29
+            let g:[newname] = g:[key]
30
+        endif
31
+    endfor
32
+endfunction
33
+call s:_handleOldOptions()
34
+" }}}
35
+
36
+" Gutentags Module Interface {{{
37
+
38
+let s:did_check_exe = 0
39
+let s:runner_exe = gutentags#get_plat_file('update_tags')
40
+let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
41
+let s:wildignores_options_path = ''
42
+let s:last_wildignores = ''
43
+
44
+function! gutentags#ctags#init(project_root) abort
45
+    " Figure out the path to the tags file.
46
+    " Check the old name for this option, too, before falling back to the
47
+    " globally defined name.
48
+    let l:tagfile = getbufvar("", 'gutentags_ctags_tagfile',
49
+                \getbufvar("", 'gutentags_tagfile', 
50
+                \g:gutentags_ctags_tagfile))
51
+    let b:gutentags_files['ctags'] = gutentags#get_cachefile(
52
+                \a:project_root, l:tagfile)
53
+
54
+    " Set the tags file for Vim to use.
55
+    if g:gutentags_ctags_auto_set_tags
56
+        execute 'setlocal tags^=' . fnameescape(b:gutentags_files['ctags'])
57
+    endif
58
+
59
+    " Check if the ctags executable exists.
60
+    if s:did_check_exe == 0
61
+        if g:gutentags_enabled && executable(expand(g:gutentags_ctags_executable, 1)) == 0
62
+            let g:gutentags_enabled = 0
63
+            echoerr "Executable '".g:gutentags_ctags_executable."' can't be found. "
64
+                        \."Gutentags will be disabled. You can re-enable it by "
65
+                        \."setting g:gutentags_enabled back to 1."
66
+        endif
67
+        let s:did_check_exe = 1
68
+    endif
69
+endfunction
70
+
71
+function! gutentags#ctags#generate(proj_dir, tags_file, gen_opts) abort
72
+    let l:write_mode = a:gen_opts['write_mode']
73
+
74
+    let l:tags_file_exists = filereadable(a:tags_file)
75
+    let l:tags_file_relative = fnamemodify(a:tags_file, ':.')
76
+    let l:tags_file_is_local = len(l:tags_file_relative) < len(a:tags_file)
77
+
78
+    if l:tags_file_exists && g:gutentags_ctags_check_tagfile
79
+        let l:first_lines = readfile(a:tags_file, '', 1)
80
+        if len(l:first_lines) == 0 || stridx(l:first_lines[0], '!_TAG_') != 0
81
+            call gutentags#throw(
82
+                        \"File ".a:tags_file." doesn't appear to be ".
83
+                        \"a ctags file. Please delete it and run ".
84
+                        \":GutentagsUpdate!.")
85
+            return
86
+        endif
87
+    endif
88
+
89
+    if empty(g:gutentags_cache_dir) && l:tags_file_is_local
90
+        " If we don't use the cache directory, we can pass relative paths
91
+        " around.
92
+        "
93
+        " Note that if we don't do this and pass a full path for the project
94
+        " root, some `ctags` implementations like Exhuberant Ctags can get
95
+        " confused if the paths have spaces -- but not if you're *in* the root 
96
+        " directory, for some reason... (which we are, our caller in
97
+        " `autoload/gutentags.vim` changed it).
98
+        let l:actual_proj_dir = '.'
99
+        let l:actual_tags_file = l:tags_file_relative
100
+    else
101
+        " else: the tags file goes in a cache directory, so we need to specify
102
+        " all the paths absolutely for `ctags` to do its job correctly.
103
+        let l:actual_proj_dir = a:proj_dir
104
+        let l:actual_tags_file = a:tags_file
105
+    endif
106
+
107
+    " Build the command line.
108
+    let l:cmd = [s:runner_exe]
109
+    let l:cmd += ['-e', '"' . s:get_ctags_executable(a:proj_dir) . '"']
110
+    let l:cmd += ['-t', '"' . l:actual_tags_file . '"']
111
+    let l:cmd += ['-p', '"' . l:actual_proj_dir . '"']
112
+    if l:write_mode == 0 && l:tags_file_exists
113
+        let l:cur_file_path = expand('%:p')
114
+        if empty(g:gutentags_cache_dir) && l:tags_file_is_local
115
+            let l:cur_file_path = fnamemodify(l:cur_file_path, ':.')
116
+        endif
117
+        let l:cmd += ['-s', '"' . l:cur_file_path . '"']
118
+    else
119
+        let l:file_list_cmd = gutentags#get_project_file_list_cmd(l:actual_proj_dir)
120
+        if !empty(l:file_list_cmd)
121
+            if match(l:file_list_cmd, '///') > 0
122
+                let l:suffopts = split(l:file_list_cmd, '///')
123
+                let l:suffoptstr = l:suffopts[1]
124
+                let l:file_list_cmd = l:suffopts[0]
125
+                if l:suffoptstr == 'absolute'
126
+                    let l:cmd += ['-A']
127
+                endif
128
+            endif
129
+            let l:cmd += ['-L', '"' . l:file_list_cmd. '"']
130
+        endif
131
+    endif
132
+    if empty(get(l:, 'file_list_cmd', ''))
133
+        " Pass the Gutentags recursive options file before the project
134
+        " options file, so that users can override --recursive.
135
+        " Omit --recursive if this project uses a file list command.
136
+        let l:cmd += ['-o', '"' . gutentags#get_res_file('ctags_recursive.options') . '"']
137
+    endif
138
+    if !empty(g:gutentags_ctags_extra_args)
139
+        let l:cmd += ['-O', shellescape(join(g:gutentags_ctags_extra_args))]
140
+    endif
141
+    if !empty(g:gutentags_ctags_post_process_cmd)
142
+        let l:cmd += ['-P', shellescape(g:gutentags_ctags_post_process_cmd)]
143
+    endif
144
+    let l:proj_options_file = a:proj_dir . '/' .
145
+                \g:gutentags_ctags_options_file
146
+    if filereadable(l:proj_options_file)
147
+        let l:proj_options_file = s:process_options_file(
148
+                    \a:proj_dir, l:proj_options_file)
149
+        let l:cmd += ['-o', '"' . l:proj_options_file . '"']
150
+    endif
151
+    if g:gutentags_ctags_exclude_wildignore
152
+        call s:generate_wildignore_options()
153
+        if !empty(s:wildignores_options_path)
154
+            let l:cmd += ['-x', shellescape('@'.s:wildignores_options_path, 1)]
155
+        endif
156
+    endif
157
+    for exc in g:gutentags_ctags_exclude
158
+        let l:cmd += ['-x', '"' . exc . '"']
159
+    endfor
160
+    if g:gutentags_pause_after_update
161
+        let l:cmd += ['-c']
162
+    endif
163
+    if g:gutentags_trace
164
+        let l:cmd += ['-l', '"' . l:actual_tags_file . '.log"']
165
+    endif
166
+    let l:cmd = gutentags#make_args(l:cmd)
167
+
168
+    call gutentags#trace("Running: " . string(l:cmd))
169
+    call gutentags#trace("In:      " . getcwd())
170
+    if !g:gutentags_fake
171
+        let l:job_opts = gutentags#build_default_job_options('ctags')
172
+        let l:job = gutentags#start_job(l:cmd, l:job_opts)
173
+        call gutentags#add_job('ctags', a:tags_file, l:job)
174
+    else
175
+        call gutentags#trace("(fake... not actually running)")
176
+    endif
177
+endfunction
178
+
179
+function! gutentags#ctags#on_job_exit(job, exit_val) abort
180
+    call gutentags#remove_job_by_data('ctags', a:job)
181
+
182
+    if a:exit_val != 0
183
+        call gutentags#warning("ctags job failed, returned: ".
184
+                    \string(a:exit_val))
185
+    endif
186
+endfunction
187
+
188
+" }}}
189
+
190
+" Utilities {{{
191
+
192
+" Get final ctags executable depending whether a filetype one is defined
193
+function! s:get_ctags_executable(proj_dir) abort
194
+    "Only consider the main filetype in cases like 'python.django'
195
+    let l:ftype = get(split(&filetype, '\.'), 0, '')
196
+    let l:proj_info = gutentags#get_project_info(a:proj_dir)
197
+    let l:type = get(l:proj_info, 'type', l:ftype)
198
+    let exepath = exists('g:gutentags_ctags_executable_{l:type}')
199
+        \ ? g:gutentags_ctags_executable_{l:type} : g:gutentags_ctags_executable
200
+    return expand(exepath, 1)
201
+endfunction
202
+
203
+function! s:generate_wildignore_options() abort
204
+    if s:last_wildignores == &wildignore
205
+        " The 'wildignore' setting didn't change since last time we did this.
206
+        call gutentags#trace("Wildignore options file is up to date.")
207
+        return
208
+    endif
209
+
210
+    if s:wildignores_options_path == ''
211
+        if empty(g:gutentags_cache_dir)
212
+            let s:wildignores_options_path = tempname()
213
+        else
214
+            let s:wildignores_options_path = 
215
+                        \gutentags#stripslash(g:gutentags_cache_dir).
216
+                        \'/_wildignore.options'
217
+        endif
218
+    endif
219
+
220
+    call gutentags#trace("Generating wildignore options: ".s:wildignores_options_path)
221
+    let l:opt_lines = []
222
+    for ign in split(&wildignore, ',')
223
+        call add(l:opt_lines, ign)
224
+    endfor
225
+    call writefile(l:opt_lines, s:wildignores_options_path)
226
+    let s:last_wildignores = &wildignore
227
+endfunction
228
+
229
+function! s:process_options_file(proj_dir, path) abort
230
+    if empty(g:gutentags_cache_dir)
231
+        " If we're not using a cache directory to store tag files, we can
232
+        " use the options file straight away.
233
+        return a:path
234
+    endif
235
+
236
+    " See if we need to process the options file.
237
+    let l:do_process = 0
238
+    let l:proj_dir = gutentags#stripslash(a:proj_dir)
239
+    let l:out_path = gutentags#get_cachefile(l:proj_dir, 'options')
240
+    if !filereadable(l:out_path)
241
+        call gutentags#trace("Processing options file '".a:path."' because ".
242
+                    \"it hasn't been processed yet.")
243
+        let l:do_process = 1
244
+    elseif getftime(a:path) > getftime(l:out_path)
245
+        call gutentags#trace("Processing options file '".a:path."' because ".
246
+                    \"it has changed.")
247
+        let l:do_process = 1
248
+    endif
249
+    if l:do_process == 0
250
+        " Nothing's changed, return the existing processed version of the
251
+        " options file.
252
+        return l:out_path
253
+    endif
254
+
255
+    " We have to process the options file. Right now this only means capturing
256
+    " all the 'exclude' rules, and rewrite them to make them absolute.
257
+    "
258
+    " This is because since `ctags` is run with absolute paths (because we
259
+    " want the tag file to be in a cache directory), it will do its path
260
+    " matching with absolute paths too, so the exclude rules need to be
261
+    " absolute.
262
+    let l:lines = readfile(a:path)
263
+    let l:outlines = []
264
+    for line in l:lines
265
+        let l:exarg_idx = matchend(line, '\v^\-\-exclude=')
266
+        if l:exarg_idx < 0
267
+            call add(l:outlines, line)
268
+            continue
269
+        endif
270
+
271
+        " Don't convert things that don't look like paths.
272
+        let l:exarg = strpart(line, l:exarg_idx + 1)
273
+        let l:do_convert = 1
274
+        if l:exarg[0] == '@'   " Manifest file path
275
+            let l:do_convert = 0
276
+        endif
277
+        if stridx(l:exarg, '/') < 0 && stridx(l:exarg, '\\') < 0   " Filename
278
+            let l:do_convert = 0
279
+        endif
280
+        if l:do_convert == 0
281
+            call add(l:outlines, line)
282
+            continue
283
+        endif
284
+
285
+        let l:fullp = l:proj_dir . gutentags#normalizepath('/'.l:exarg)
286
+        let l:ol = '--exclude='.l:fullp
287
+        call add(l:outlines, l:ol)
288
+    endfor
289
+
290
+    call writefile(l:outlines, l:out_path)
291
+    return l:out_path
292
+endfunction
293
+
294
+" }}}

+ 122
- 0
dotfiles/vim/bundle/vim-gutentags/autoload/gutentags/gtags_cscope.vim View File

@@ -0,0 +1,122 @@
1
+" gtags_cscope module for Gutentags
2
+
3
+if !has('cscope')
4
+    throw "Can't enable the gtags-cscope module for Gutentags, "
5
+                \"this Vim has no support for cscope files."
6
+endif
7
+
8
+" Global Options {{{
9
+
10
+if !exists('g:gutentags_gtags_executable')
11
+    let g:gutentags_gtags_executable = 'gtags'
12
+endif
13
+
14
+if !exists('g:gutentags_gtags_dbpath')
15
+    let g:gutentags_gtags_dbpath = ''
16
+endif
17
+
18
+if !exists('g:gutentags_gtags_options_file')
19
+    let g:gutentags_gtags_options_file = '.gutgtags'
20
+endif
21
+
22
+if !exists('g:gutentags_gtags_cscope_executable')
23
+    let g:gutentags_gtags_cscope_executable = 'gtags-cscope'
24
+endif
25
+
26
+if !exists('g:gutentags_auto_add_gtags_cscope')
27
+    let g:gutentags_auto_add_gtags_cscope = 1
28
+endif
29
+
30
+" }}}
31
+
32
+" Gutentags Module Interface {{{
33
+
34
+let s:added_db_files = {}
35
+
36
+function! s:add_db(db_file) abort
37
+    if filereadable(a:db_file)
38
+        call gutentags#trace(
39
+                    \"Adding cscope DB file: " . a:db_file)
40
+        set nocscopeverbose
41
+        execute 'cs add ' . fnameescape(a:db_file)
42
+        set cscopeverbose
43
+        let s:added_db_files[a:db_file] = 1
44
+    else
45
+        call gutentags#trace(
46
+                    \"Not adding cscope DB file because it doesn't " .
47
+                    \"exist yet: " . a:db_file)
48
+    endif
49
+endfunction
50
+
51
+function! gutentags#gtags_cscope#init(project_root) abort
52
+    let l:db_path = gutentags#get_cachefile(
53
+                \a:project_root, g:gutentags_gtags_dbpath)
54
+    let l:db_path = gutentags#stripslash(l:db_path)
55
+    let l:db_file = l:db_path . '/GTAGS'
56
+    let l:db_file = gutentags#normalizepath(l:db_file)
57
+
58
+    if !isdirectory(l:db_path)
59
+        call mkdir(l:db_path, 'p')
60
+    endif
61
+
62
+    let b:gutentags_files['gtags_cscope'] = l:db_file
63
+
64
+    execute 'set cscopeprg=' . fnameescape(g:gutentags_gtags_cscope_executable)
65
+
66
+    " The combination of gtags-cscope, vim's cscope and global files is
67
+    " a bit flaky. Environment variables are safer than vim passing
68
+    " paths around and interpreting input correctly.
69
+    let $GTAGSDBPATH = l:db_path
70
+    let $GTAGSROOT = a:project_root
71
+
72
+    if g:gutentags_auto_add_gtags_cscope && 
73
+                \!has_key(s:added_db_files, l:db_file)
74
+        let s:added_db_files[l:db_file] = 0
75
+        call s:add_db(l:db_file)
76
+    endif
77
+endfunction
78
+
79
+function! gutentags#gtags_cscope#generate(proj_dir, tags_file, gen_opts) abort
80
+    " gtags doesn't honour GTAGSDBPATH and GTAGSROOT, so PWD and dbpath
81
+    " have to be set
82
+    let l:db_path = fnamemodify(a:tags_file, ':p:h')
83
+
84
+    let l:proj_options_file = a:proj_dir . '/' . g:gutentags_gtags_options_file
85
+
86
+    let l:cmd = ['"'.g:gutentags_gtags_executable.'"']
87
+    if filereadable(l:proj_options_file)
88
+        let l:proj_options = readfile(l:proj_options_file)
89
+        let l:cmd += l:proj_options
90
+    endif
91
+    let l:cmd += ['--incremental', '"'.l:db_path.'"']
92
+    let l:cmd = gutentags#make_args(l:cmd)
93
+
94
+    call gutentags#trace("Running: " . string(l:cmd))
95
+    call gutentags#trace("In:      " . getcwd())
96
+    if !g:gutentags_fake
97
+        let l:job_opts = gutentags#build_default_job_options('gtags_cscope')
98
+        let l:job = gutentags#start_job(l:cmd, l:job_opts)
99
+        call gutentags#add_job('gtags_cscope', a:tags_file, l:job)
100
+    else
101
+        call gutentags#trace("(fake... not actually running)")
102
+    endif
103
+    call gutentags#trace("")
104
+endfunction
105
+
106
+function! gutentags#gtags_cscope#on_job_exit(job, exit_val) abort
107
+    let l:job_idx = gutentags#find_job_index_by_data('gtags_cscope', a:job)
108
+    let l:dbfile_path = gutentags#get_job_tags_file('gtags_cscope', l:job_idx)
109
+    call gutentags#remove_job('gtags_cscope', l:job_idx)
110
+
111
+    if g:gutentags_auto_add_gtags_cscope
112
+        call s:add_db(l:dbfile_path)
113
+    endif
114
+
115
+    if a:exit_val != 0
116
+        call gutentags#warning(
117
+                    \"gtags-cscope job failed, returned: ".
118
+                    \string(a:exit_val))
119
+    endif
120
+endfunction
121
+
122
+" }}}

+ 728
- 0
dotfiles/vim/bundle/vim-gutentags/doc/gutentags.txt View File

@@ -0,0 +1,728 @@
1
+*gutentags.txt*  Automatic ctags management for VIM
2
+      ___           ___           ___           ___           ___     
3
+     /\__\         /\  \         /\__\         /\__\         /\  \    
4
+    /:/ _/_        \:\  \       /:/  /        /:/ _/_        \:\  \   
5
+   /:/ /\  \        \:\  \     /:/__/        /:/ /\__\        \:\  \  
6
+  /:/ /::\  \   ___  \:\  \   /::\  \       /:/ /:/ _/_   _____\:\  \ 
7
+ /:/__\/\:\__\ /\  \  \:\__\ /:/\:\  \     /:/_/:/ /\__\ /::::::::\__\
8
+ \:\  \ /:/  / \:\  \ /:/  / \/__\:\  \    \:\/:/ /:/  / \:\~~\~~\/__/
9
+  \:\  /:/  /   \:\  /:/  /       \:\__\    \::/_/:/  /   \:\  \      
10
+   \:\/:/  /     \:\/:/  /         \/__/     \:\/:/  /     \:\  \     
11
+    \::/  /       \::/  /                     \::/  /       \:\__\    
12
+     \/__/         \/__/                       \/__/         \/__/    
13
+        ___           ___           ___           ___     
14
+       /\__\         /\  \         /\__\         /\__\    
15
+      /:/  /        /::\  \       /:/ _/_       /:/ _/_   
16
+     /:/__/        /:/\:\  \     /:/ /\  \     /:/ /\  \  
17
+    /::\  \       /:/ /::\  \   /:/ /::\  \   /:/ /::\  \ 
18
+   /:/\:\  \     /:/_/:/\:\__\ /:/__\/\:\__\ /:/_/:/\:\__\
19
+   \/__\:\  \    \:\/:/  \/__/ \:\  \ /:/  / \:\/:/ /:/  /
20
+        \:\__\    \::/__/       \:\  /:/  /   \::/ /:/  / 
21
+         \/__/     \:\  \        \:\/:/  /     \/_/:/  /  
22
+                    \:\__\        \::/  /        /:/  /   
23
+                     \/__/         \/__/         \/__/    
24
+
25
+
26
+                GUTENTAGS REFERENCE MANUAL
27
+                    by Ludovic Chabant
28
+
29
+                                                *gutentags*
30
+
31
+1. Introduction             |gutentags-intro|
32
+2. Commands                 |gutentags-commands|
33
+3. Status Line              |gutentags-status-line|
34
+4. Global Settings          |gutentags-settings|
35
+5. Project Settings         |gutentags-project-settings|
36
+
37
+=============================================================================
38
+1. Introduction                                 *gutentags-intro*
39
+
40
+Gutentags is a plugin that takes care of the much needed management of tags
41
+files in Vim. It will (re)generate tag files as you work while staying
42
+completely out of your way. It will even do its best to keep those tag files
43
+out of your way too. It has no dependencies and just works.
44
+
45
+In order to generate tag files, Gutentags will have to figure out what's in
46
+your project. To do this, it will locate well-known project root markers like
47
+SCM folders (.git, .hg, etc.), any custom tags you define (with
48
+|gutentags_project_root|), and even things you may have defined already with
49
+other plugins, like CtrlP.
50
+
51
+If the current file you're editing is found to be in such a project, Gutentags
52
+will make sure the tag file for that project is up to date. Then, as you work
53
+in files in that project, it will partially re-generate the tag file. Every
54
+time you save, it will silently, in the background, update the tags for that
55
+file.
56
+
57
+Usually, `ctags` can only append tags to an existing tag file, so Gutentags
58
+removes the tags for the current file first, to make sure the tag file is
59
+always consistent with the source code.
60
+
61
+Also, Gutentags is clever enough to not stumble upon itself by triggering
62
+multiple ctags processes if you save files too fast, or if your project is
63
+really big.
64
+
65
+
66
+1.1 Requirements
67
+                                                *gutentags-ctags-requirements*
68
+
69
+If you're using the `ctags` modules (which is the default and only working one
70
+at this point, really), you will need a `tags` generator that supports the
71
+following arguments:
72
+
73
+* `-f` (to specify the output file)
74
+* `--append` (to append to an existing file while keeping it sorted)
75
+* `--exclude` (to exclude file patterns)
76
+* `--options` (to specify an options file)
77
+
78
+This means you probably want Exuberant Ctags or Universal Ctags. The basic
79
+old BSD Ctags WON'T WORK. Other language-specific versions may or may not
80
+work. Check with their help or man page.
81
+
82
+
83
+1.2 Similar Plugins
84
+                                                *gutentags-similar-plugins*
85
+
86
+There are some similar Vim plugins out there ("vim-tags", "vim-autotag",
87
+"vim-automatic-ctags", etc.). They all fail on one or more of the requirements
88
+I set for myself with Gutentags:
89
+
90
+* No other dependency than running Vim: no Python, Ruby, or whatever.
91
+* Cross-platform: should work on at least Mac and Windows.
92
+* Incremental tags generation: don't re-generate the whole project all the
93
+  time. This may be fine for small projects, but it doesn't scale.
94
+* External process management: if the ctags process is taking a long time,
95
+  don't run another one because I saved the file again.
96
+* Keep the tag file consistent: don't just append the current file's tags to
97
+  the tag file, otherwise you will still "see" tags for deleted or renamed
98
+  classes and functions.
99
+* Automatically create the tag file: you open something from a freshly forked
100
+  project, it should start indexing it automatically, just like in Sublime Text 
101
+  or Visual Studio or any other IDE.
102
+
103
+
104
+=============================================================================
105
+2. Commands                                     *gutentags-commands*
106
+
107
+                                                *gutentags-project-commands*
108
+The following commands are only available in buffers that have been found to
109
+belong to a project that should be managed by Gutentags. See
110
+|gutentags_project_root| for how Gutentags figures out the project a file
111
+belongs to. When no project is found (i.e. the file is not under any of the
112
+known project markers), Gutentags is disabled for that buffer, and the
113
+following commands and remarks don't apply.
114
+
115
+If you want to force-disable Gutentags for a given project even though it does
116
+match one of the items in |gutentags_project_root|, create a file named
117
+"`.notags`" at the root of the project.
118
+
119
+The tag file that Gutentags creates and manages will be named after
120
+|gutentags_ctags_tagfile|, relative to the project's root directory. When
121
+Gutentags finds a valid project root, it will prepend the tag file's path to
122
+'tags', unless |gutentags_ctags_auto_set_tags| is set to 0. This is to make
123
+sure Vim will use that file first.
124
+
125
+If a file managed by Gutentags is opened and no tag file already exists,
126
+Gutentags will start generating it right away in the background, unless 
127
+|gutentags_generate_on_missing| is set to 0. If you have a large project, you
128
+may want to know when Gutentags is generating tags: see
129
+|gutentags-status-line| to display an indicator in your status line.
130
+
131
+When a file managed by Gutentags is saved, the tag file will be incrementally
132
+updated, i.e. references to the recently saved file are removed, and that file
133
+is re-parsed for tags, with the result being merged into the tag file. This
134
+makes the tag file 100% consistent with the latest changes. This doesn't
135
+happen however if |gutentags_generate_on_write| is set to 0, in which case you
136
+have to run |GutentagsUpdate| manually.
137
+
138
+
139
+                                                *:GutentagsUpdate*
140
+:GutentagsUpdate
141
+                        Forces an update of the current tag file with the
142
+                        current buffer. If tags are already being generated,
143
+                        you will be notified and the command will abort.
144
+
145
+:GutentagsUpdate!
146
+                        Like |GutentagsUpdate|, but updates the current tags
147
+                        file with the whole project instead of just the
148
+                        current buffer.
149
+
150
+
151
+Some debugging/troubleshooting commands are also available if the
152
+|gutentags_define_advanced_commands| global setting is set to 1.
153
+
154
+                                                *:GutentagsToggleEnabled*
155
+:GutentagsToggleEnabled
156
+                        Disables and re-enables Gutentags.
157
+                        When Gutentags is disabled, it won't update your tag
158
+                        file when you save a buffer. It will however still
159
+                        look for project markers as you open new buffers so
160
+                        that they can start working again when you re-enable
161
+                        Gutentags.
162
+
163
+                        {only available when
164
+                        |gutentags_define_advanced_commands| is set}
165
+
166
+                                                *GutentagsToggleTrace*
167
+:GutentagsToggleTrace
168
+                        If you want to keep an eye on what Gutentags is doing,
169
+                        you can enable tracing. This will show messages every
170
+                        time Gutentags does something. It can get annoying
171
+                        quickly, since it will require you to press a key to
172
+                        dismiss those messages, but it can be useful to
173
+                        troubleshoot a problem.
174
+                        In addition to messages in Vim, it will also make
175
+                        Gutentags redirect the output of the tag generation
176
+                        script to a `.log` file in the project root.
177
+
178
+                        {only available when
179
+                        |gutentags_define_advanced_commands| is set}
180
+
181
+
182
+Gutentags also has some user auto-commands (see |User| and |:doautocmd|):
183
+
184
+                                                *GutentagsUpdating*
185
+GutentagsUpdating
186
+                        This auto-command is triggered when a background
187
+                        update job has started.
188
+
189
+                                                *GutentagsUpdated*
190
+GutentagsUpdated
191
+                        This auto-command is triggered when a background
192
+                        update job has finished.
193
+
194
+
195
+=============================================================================
196
+3.  Status Line                                 *gutentags-status-line*
197
+
198
+Tag file generation can take a while if you're working on a project big
199
+enough. In that case, you may want to know when `ctags` is running, so you
200
+have a heads up if some of the tags aren't recognized yet.
201
+
202
+                                                *gutentags#statusline()*
203
+You can display an indicator of tag generation progress in your |status-line|
204
+with the following function: >
205
+        :set statusline+=%{gutentags#statusline()}
206
+
207
+The function will, by default, print a list of modules in the status line. So
208
+if the `ctags` module (see |g:gutentags_modules|) is currently generating
209
+a tags file, you will see "ctags" printed in the status line. If nothing is
210
+happening, nothing will be printed in the status line.
211
+
212
+You can pass some parameters to customize this:
213
+
214
+1. A prefix string (defaults to `""`).
215
+2. A suffix string (defaults to `""`).
216
+3. The text to print (defaults to the names of modules currently generating
217
+   something).
218
+
219
+So using `gutentags#statusline('[', ']')` would print `"[ctags]"` instead of
220
+`"ctags"`.
221
+
222
+Because Gutentags runs the tag generation in the background, the statusline
223
+indicator might stay there even after the background process has ended. It
224
+would only go away when Vim decides to refresh the statusline. You can force
225
+refresh it in a callback on |GutentagsUpdating| and |GutentagsUpdated|.
226
+
227
+For instance, with the `lightline` plugin:
228
+
229
+        augroup MyGutentagsStatusLineRefresher
230
+            autocmd!
231
+            autocmd User GutentagsUpdating call lightline#update()
232
+            autocmd User GutentagsUpdated call lightline#update()
233
+        augroup END
234
+
235
+                                                *gutentags#statusline_cb*
236
+As an alternative to the previous function, `gutentags#statusline_cb` takes
237
+a single parameter which should be a |Funcref| or a function name. This
238
+function should take a list of active module names, and return a string. This
239
+lets you completely control what the status line will print.
240
+
241
+For instance:
242
+        function! s:get_gutentags_status(mods) abort
243
+            let l:msg = ''
244
+            if index(a:mods, 'ctags') >= 0
245
+               let l:msg .= '♨'
246
+             endif
247
+             if index(a:mods, 'cscope') >= 0
248
+               let l:msg .= '♺'
249
+             endif
250
+             return l:msg
251
+        endfunction
252
+
253
+        :set statusline+=%{gutentags#statusline_cb(
254
+                    \function('<SID>get_gutentags_status'))}
255
+
256
+By default, the callback function doesn't get called if no tags generation is
257
+currently happening. You can pass `1` as a second argument so that the
258
+callback function is always called.
259
+
260
+
261
+=============================================================================
262
+4. Global Settings                              *gutentags-settings*
263
+
264
+The following settings can be defined in your |vimrc| to change the default
265
+behaviour of Gutentags.
266
+
267
+                                                *gutentags_enabled*
268
+g:gutentags_enabled
269
+                        Defines whether Gutentags should be enabled. When
270
+                        disabled, Gutentags will still scan for project root
271
+                        markers when opening buffers. This is so that when you
272
+                        re-enable Gutentags, you won't have some buffers
273
+                        mysteriously working while others (those open last)
274
+                        don't.
275
+                        Defaults to `1`.
276
+
277
+                                                *gutentags_trace*
278
+g:gutentags_trace
279
+                        When true, Gutentags will spit out debugging
280
+                        information as Vim messages (which you can later read
281
+                        with |:messages|). It also runs its background scripts
282
+                        with extra parameters to log activity to a `tags.log`
283
+                        file that you can also inspect for more information.
284
+
285
+                        Note: you can run `:verbose GutentagsUpdate` to
286
+                        temporarily set |g:gutentags_trace| to `1` for that
287
+                        update only.
288
+
289
+                        Defaults to `0`.
290
+
291
+                                                *gutentags_dont_load*
292
+g:gutentags_dont_load
293
+                        Prevents Gutentags from loading at all on Vim startup.
294
+
295
+                        The difference between this and |gutentags_enabled| is
296
+                        that |gutentags_enabled| can be turned on and off in
297
+                        the same Vim session -- Gutentags as a plugin stays
298
+                        loaded and will keep track of what happened while it
299
+                        was disabled. However, |gutentags_dont_load| only
300
+                        works on Vim startup and will prevent Gutentags from
301
+                        loading at all, as if it wasn't there.
302
+
303
+                                                *gutentags_modules*
304
+g:gutentags_modules
305
+                        A list of modules to load with Gutentags. Each module
306
+                        is responsible for generating a specific type of tags
307
+                        file.
308
+                        Valid values are:
309
+
310
+                        - `ctags`: generates a `tags` file using
311
+                          a `ctags`-compatible program like Exhuberant Ctags
312
+                          or Universal Ctags.
313
+
314
+                        - `cscope`: generates a code database file using
315
+                          `cscope`.
316
+
317
+                        - `gtags_cscope`: same as `cscope` but uses GNU's
318
+                          `gtags` executable and database.
319
+
320
+                        Defaults to `[ctags]`.
321
+
322
+                                                *gutentags_project_root*
323
+g:gutentags_project_root
324
+                        When a buffer is loaded, Gutentags will figure out if
325
+                        it's part of a project that should have tags managed
326
+                        automatically. To do this, it looks for "root markers"
327
+                        in the current file's directory and its parent
328
+                        directories. If it finds any of those markers,
329
+                        Gutentags will be enabled for the project, and a tags
330
+                        file named after |gutentags_ctags_tagfile| will be 
331
+                        created at the project root.
332
+                        Defaults to `[]` (an empty |List|).
333
+                        A list of default markers will be appended to the
334
+                        user-defined ones unless
335
+                        |gutentags_add_default_project_roots| is set to 0.
336
+
337
+                                            *gutentags_add_default_project_roots*
338
+g:gutentags_add_default_project_roots
339
+                        Defines whether Gutentags should always define some
340
+                        default project roots (see |gutentags_project_root|).
341
+                        This can be useful to prevent unnecessary disk access
342
+                        when Gutentags searches for a project root.
343
+                        The default markers are:
344
+                        `['.git', '.hg', '.svn', '.bzr', '_darcs', '_darcs', '_FOSSIL_', '.fslckout']`
345
+
346
+                                            *gutentags_add_ctrlp_root_markers*
347
+g:gutentags_add_ctrlp_root_markers
348
+                        If Gutentags finds `g:ctrlp_root_markers` (used by the
349
+                        CtrlP plugin), it will append those root markers to
350
+                        the existing ones (see |g:gutentags_project_root|).
351
+                        Set this to 0 to stop it from happening.
352
+                        Defaults to 1.
353
+
354
+                                                *gutentags_exclude_filetypes*
355
+g:gutentags_exclude_filetypes
356
+                        A |List| of file types (see |'filetype'|) that Gutentags
357
+                        should ignore. When a buffer is opened, if its
358
+                        'filetype' is found in this list, Gutentags features
359
+                        won't be available for this buffer.
360
+                        Defaults to an empty list (`[]`).
361
+
362
+                                                *gutentags_exclude_project_root*
363
+g:gutentags_exclude_project_root
364
+                        A list of project roots to generally ignore. If a file
365
+                        is opened inside one of those projects, Gutentags
366
+                        won't be activated. This is similar to placing
367
+                        a `.notags` file in the root of those projects, but
368
+                        can be useful when you don't want to, or can't, place
369
+                        such a file there.
370
+                        Defaults to `['/usr/local']`, which is the folder where
371
+                        Homebrew is known to create a Git directory by default
372
+                        on MacOS.
373
+
374
+                                                *gutentags_project_root_finder*
375
+g:gutentags_project_root_finder
376
+                        When a buffer is loaded, Gutentags uses a default
377
+                        (internal) implementation to find that file's
378
+                        project's root directory, using settings like
379
+                        |g:gutentags_project_root|. When you specify
380
+                        |g:gutentags_project_root_finder|, you can tell
381
+                        Gutentags to use a custom implementation, such as
382
+                        `vim-projectroot`. The value of this setting must be
383
+                        the name of a function that takes a single string
384
+                        argument (the path to the current buffer's file) and
385
+                        returns a string value (the project's root directory).
386
+                        Defaults to `''`.
387
+                        Note: when set, the called implementation will
388
+                        possibly ignore |g:gutentags_project_root|.
389
+                        Note: an implementation can fallback to the default
390
+                        behaviour by calling
391
+                        `gutentags#default_get_project_root`.
392
+
393
+                                                *gutentags_generate_on_missing*
394
+g:gutentags_generate_on_missing
395
+                        If set to 1, Gutentags will start generating an initial
396
+                        tag file if a file is open in a project where no tags
397
+                        file is found. See |gutentags_project_root| for how
398
+                        Gutentags locates the project.
399
+                        When set to 0, Gutentags will only generate the first
400
+                        time the file is saved (if
401
+                        |gutentags_generate_on_write| is set to 1), or when
402
+                        |GutentagsUpdate| or |GutentagsGenerate| is run.
403
+                        Defaults to 1.
404
+
405
+                                                *gutentags_generate_on_new*
406
+g:gutentags_generate_on_new
407
+                        If set to 1, Gutentags will start generating the tag
408
+                        file when a new project is open. A new project is
409
+                        considered open when a buffer is created for a file
410
+                        whose corresponding tag file has not been "seen" yet
411
+                        in the current Vim session -- which pretty much means
412
+                        when you open the first file in a given source control
413
+                        repository.
414
+                        When set to 0, Gutentags won't do anything special.
415
+                        See also |gutentags_generate_on_missing| and
416
+                        |gutentags_generate_on_write|.
417
+                        Defaults to 1.
418
+
419
+                                                *gutentags_generate_on_write*
420
+g:gutentags_generate_on_write
421
+                        If set to 1, Gutentags will update the current
422
+                        project's tag file when a file inside that project is
423
+                        saved. See |gutentags_project_root| for how Gutentags
424
+                        locates the project.
425
+                        When set to 0, Gutentags won't do anything on save.
426
+                        This means that the project's tag file won't reflect
427
+                        the latest changes, and you will have to run
428
+                        |GutentagsUpdate| manually.
429
+                        Defaults to 1.
430
+
431
+                                            *gutentags_generate_on_empty_buffer*
432
+g:gutentags_generate_on_empty_buffer
433
+                        If set to 1, Gutentags will start generating the tag
434
+                        file even if there's no buffer currently open, as long
435
+                        as the current working directory (as returned by
436
+                        |:cd|) is inside a known project.
437
+                        This is useful if you want Gutentags to generate the
438
+                        tag file right after opening Vim.
439
+                        Defaults to 0.
440
+
441
+                                                *gutentags_background_update*
442
+g:gutentags_background_update
443
+                        Specifies whether the process that updates the tags
444
+                        file should be run in the background or in the
445
+                        foreground. If run in the foreground, Vim will block
446
+                        until the process is complete.
447
+                        Defaults to 1.
448
+
449
+                                                *gutentags_cache_dir*
450
+g:gutentags_cache_dir
451
+                        Specifies a directory in which to create all the tags
452
+                        files, instead of writing them at the root of each
453
+                        project. This is handy to keep tags files from
454
+                        polluting many directories all across your computer.
455
+
456
+                                            *gutentags_resolve_symlinks*
457
+g:gutentags_resolve_symlinks
458
+                        When set to 1, Gutentags will resolve any symlinks in
459
+                        the current buffer's path in order to find the project
460
+                        it belongs to. This is what you want if you're editing
461
+                        a symlink located outside of the project, and it
462
+                        points to a file inside the project. However, this is
463
+                        maybe not what you want if the symlink itself is
464
+                        part of the project.
465
+                        Defaults to 0.
466
+                        
467
+                                            *gutentags_init_user_func*
468
+g:gutentags_init_user_func
469
+                        When set to a non-empty string, it is expected to be
470
+                        the name of a function that will be called when a file
471
+                        is opened in a project. The function gets passed the
472
+                        path of the file and if it returns 0, Gutentags won't
473
+                        be enabled for that file.
474
+
475
+                        You can use this to manually set buffer-local
476
+                        settings:
477
+                        
478
+                        * `b:gutentags_ctags_tagfile` (see |gutentags_ctags_tagfile|).
479
+
480
+                        This setting was previously called 
481
+                        `gutentags_enabled_user_func`. The old setting is
482
+                        still used as a fallback.
483
+
484
+                        Defaults to "".
485
+
486
+                                            *gutentags_define_advanced_commands*
487
+g:gutentags_define_advanced_commands
488
+                        Defines some advanced commands like
489
+                        |GutentagsToggleEnabled| and |GutentagsUnlock|.
490
+
491
+                                            *gutentags_project_info*
492
+g:gutentags_project_info
493
+                        Defines ways for Gutentags to figure out what kind of
494
+                        project any given file belongs to. This should be
495
+                        a list of dictionaries:
496
+
497
+                        let g:gutentags_project_info = []
498
+                        call add(g:gutentags_project_info, {...})
499
+
500
+                        Each dictionary item must contain at least a `type`
501
+                        key, indicating the type of project:
502
+
503
+                        {"type": "python"}
504
+
505
+                        Other items will be used to figure out if a project is
506
+                        of the given type.
507
+
508
+                        "file": any existing file with this path (relative to
509
+                        the project root) will make the current project match
510
+                        the given info.
511
+
512
+                        "glob": any result found with this glob pattern
513
+                        (relative to the project root) will make the current
514
+                        project match the given info. See |glob()| for more
515
+                        information.
516
+
517
+                        Gutentags adds by default the following definitions:
518
+
519
+                        call add(g:gutentags_project_info, {'type': 'python', 'file': 'setup.py'})
520
+                        call add(g:gutentags_project_info, {'type': 'ruby', 'file': 'Gemfile'})
521
+
522
+                        This means, for example, that you can use
523
+                        `g:gutentags_ctags_executable_ruby` out of the box.
524
+                        See |gutentags_ctags_executable_{filetype}| for more
525
+                        information.
526
+
527
+                                            *gutentags_file_list_command*
528
+g:gutentags_file_list_command
529
+                        Specifies command(s) to use to list files for which
530
+                        tags should be generated, instead of recursively
531
+                        examining all files within the project root. When
532
+                        invoked, file list commands will execute in the
533
+                        project root directory.
534
+
535
+                        This setting is useful in projects using source
536
+                        control to restrict tag generation to only files
537
+                        tracked in the repository.
538
+
539
+                        This variable may be set in one of two ways. If
540
+                        set as a |String|, the specified command will be used to
541
+                        list files for all projects. For example: >
542
+
543
+                         let g:gutentags_file_list_command = 'find . -type f'
544
+<
545
+                        If set as a |Dictionary|, this variable should be set
546
+                        as a mapping of project root markers to the desired
547
+                        file list command for that root marker. (See
548
+                        |gutentags_project_root| for how Gutentags uses root
549
+                        markers to locate the project.) For example: >
550
+
551
+                         let g:gutentags_file_list_command = {
552
+                             \ 'markers': {
553
+                                 \ '.git': 'git ls-files',
554
+                                 \ '.hg': 'hg files',
555
+                                 \ },
556
+                             \ }
557
+<
558
+                        Note: If a custom ctags executable is specified, it
559
+                        must support the '-L' command line option in order to
560
+                        read the list of files to be examined.
561
+
562
+
563
+The following settings are valid for the `ctags` module.
564
+
565
+                                                *gutentags_ctags_executable*
566
+g:gutentags_ctags_executable
567
+                        Specifies the ctags executable to launch.
568
+                        Defaults to `ctags`.
569
+
570
+                                     *gutentags_ctags_executable_{filetype}*
571
+g:gutentags_ctags_executable_{type}
572
+                        Specifies the ctags executable to launch for a project
573
+                        of type {type}. See |gutentags_project_info| for more
574
+                        information.
575
+                        IMPORTANT: please see |gutentags-ctags-requirements|.
576
+                        Example: >
577
+                         let g:gutentags_ctags_executable_ruby = 'foobar'
578
+<
579
+
580
+                                                *gutentags_ctags_tagfile*
581
+g:gutentags_ctags_tagfile
582
+                        Specifies the name of the tag file to create. This
583
+                        will be appended to the project's root. See
584
+                        |gutentags_project_root| for how Gutentags locates the
585
+                        project.
586
+                        Defaults to `tags`.
587
+
588
+                                                *gutentags_ctags_exclude*
589
+g:gutentags_ctags_exclude
590
+                        A list of file patterns to pass to the
591
+                        |gutentags_ctags_executable| so that they will be
592
+                        excluded from parsing for the tags generation.
593
+                        See also |gutentags_ctags_exclude_wildignore|.
594
+                        Defaults to `[]` (an empty |List|).
595
+
596
+                                                *gutentags_ctags_exclude_wildignore*
597
+g:gutentags_ctags_exclude_wildignore
598
+                        When 1, Gutentags will automatically pass your
599
+                        'wildignore' file patterns to the 
600
+                        |gutentags_ctags_executable| so that they are ignored.
601
+                        Set also |gutentags_ctags_exclude| to pass custom
602
+                        patterns.
603
+                        Defaults to 1.
604
+
605
+                                                *gutentags_ctags_auto_set_tags*
606
+g:gutentags_ctags_auto_set_tags
607
+                        If set to 1, Gutentags will automatically prepend
608
+                        'tags' with the exact path to the tag file for the
609
+                        current project. See |gutentags_project_root| for how
610
+                        Gutentags locates the project.
611
+                        When set to 0, Gutentags doesn't change 'tags', and
612
+                        this means that whatever tag file it generates may
613
+                        not be picked up by Vim. See |tagfiles()| to know what
614
+                        tag files Vim knows about.
615
+                        Defaults to 1.
616
+
617
+                                                *gutentags_ctags_extra_args*
618
+g:gutentags_ctags_extra_args
619
+                        A list of arguments to pass to `ctags`.
620
+                        Defaults to `[]`.
621
+
622
+                                                *gutentags_ctags_post_process_cmd*
623
+g:gutentags_ctags_post_process_cmd
624
+                        If defined, the tags generation script will run the
625
+                        command with an argument that points to a temporary
626
+                        copy of the tags file. If the post-process step is
627
+                        modifying the tags file, it needs to do so in-place.
628
+                        This is useful for cleaning up a tags file that may
629
+                        contain tags with non-ASCII names that somehow upsets
630
+                        Vim.
631
+                        Defaults to `""` (an empty |String|).
632
+
633
+
634
+The following settings are valid for the `cscope` module.
635
+
636
+                                                *gutentags_cscope_executable*
637
+g:gutentags_cscope_executable
638
+                        Specifies the name or path of the `cscope` executable
639
+                        to use to generate the code database.
640
+                        Defaults to `"cscope"`.
641
+
642
+                                                *gutentags_scopefile*
643
+g:gutentags_scopefile
644
+                        Specifies the name of the scope file to create. This
645
+                        will be appended to the project's root. See
646
+                        |gutentags_project_root| for how Gutentags locates the
647
+                        project.
648
+                        Defaults to `"cscope.out"`.
649
+
650
+                                                *gutentags_auto_add_cscope*
651
+g:gutentags_auto_add_cscope
652
+                        If set to 1, Gutentags will automatically add the
653
+                        generated code database to Vim by running `:cs add`
654
+                        (see |:cscope|).
655
+                        Defaults to 1.
656
+
657
+                                                *gutentags_cscope_build_inverted_index*
658
+g:gutentags_cscope_build_inverted_index
659
+                        If set to 1, Gutentags will make `cscope` build an
660
+                        inverted index.
661
+                        Defaults to 0.
662
+
663
+
664
+The following settings are valid for the `gtags_cscope` module.
665
+
666
+                                                *gutentags_gtags_executable*
667
+g:gutentags_gtags_executable
668
+                        Specifies the name or path of the `gtags` executable
669
+                        to use to generate the code database.
670
+                        Defaults to `"gtags"`.
671
+
672
+                                                *gutentags_gtags_cscope_executable*
673
+g:gutentags_gtags_cscope_executable
674
+                        Specifies the name or path of the `gtags-cscope`
675
+                        executable to use to generate the code database.
676
+                        Defaults to `"gtags-cscope"`.
677
+
678
+                                                *gutentags_gtags_dbpath*
679
+g:gutentags_gtags_dbpath
680
+                        Path from the cache directory (|gutentags_cache_dir|
681
+                        or project root) to the folder containing the
682
+                        definition database file (usually called `GTAGS`).
683
+                        Defaults to `""`.
684
+
685
+                                                *gutentags_gtags_options_file*
686
+g:gutentags_gtags_options_file
687
+                        The name of a file that will be looked for in
688
+                        a project root directory. The file is expected to
689
+                        contain `gtags` options (one per line).
690
+                        Defaults to `".gutgtags"`.
691
+
692
+                                                *gutentags_auto_add_gtags_cscope*
693
+g:gutentags_auto_add_gtags_cscope
694
+                        If set to 1, Gutentags will automatically add the
695
+                        generated code database to Vim by running `:cs add`
696
+                        (see |:cscope|).
697
+                        Defaults to 1.
698
+
699
+People using `cscope` or `gtags_cscope` across multiple projects in the same
700
+Vim instance might be interested in the `gutentags_plus` plugin, which handles
701
+switching databases automatically before performing a query.
702
+See https://github.com/skywind3000/gutentags_plus.
703
+
704
+=============================================================================
705
+5. Project Settings                             *gutentags-project-settings*
706
+
707
+Gutentags can be customized to some extent on a per-project basis with the
708
+following files present in the project root directory:
709
+
710
+                                                *gutentags-.gutctags*
711
+`.gutctags`: if this file exists, Ctags will be told to load additional
712
+command-line parameters by reading it line by line (see the Ctags
713
+documentation for more information).
714
+
715
+Note that for complex reasons, Gutentags can't run `ctags` from the project
716
+root if you're using |gutentags_cache_dir|, so if the `.gutctags` file exists,
717
+it will be pre-processed in order to make all `--exclude=` clauses into
718
+absolute paths (by prepending the project root). The resulting file will be
719
+saved into the cache directory, and passed to `ctags` via the `--options=`
720
+parameter. If you're _not_ using |gutentags_cache_dir|, the `.gutctags` file
721
+is _not_ pre-processed, and is passed as-is via the `--options=` parameter.
722
+
723
+                                                *gutentags-.notags*
724
+`.notags`: if this file exists, Gutentags will be disabled completely for that
725
+project.
726
+
727
+
728
+ vim:tw=78:et:ft=help:norl:

+ 124
- 0
dotfiles/vim/bundle/vim-gutentags/plat/unix/update_scopedb.sh View File

@@ -0,0 +1,124 @@
1
+#!/bin/sh
2
+
3
+set -e
4
+
5
+PROG_NAME=$0
6
+CSCOPE_EXE=cscope
7
+CSCOPE_ARGS=
8
+DB_FILE=cscope.out
9
+PROJECT_ROOT=
10
+FILE_LIST_CMD=
11
+BUILD_INVERTED_INDEX=0
12
+
13
+ShowUsage() {
14
+    echo "Usage:"
15
+    echo "    $PROG_NAME <options>"
16
+    echo ""
17
+    echo "    -e [exe=cscope]:      The cscope executable to run"
18
+    echo "    -f [file=cscope.out]: The path to the ctags file to update"
19
+    echo "    -p [dir=]:            The path to the project root"
20
+    echo "    -L [cmd=]:            The file list command to run"
21
+    echo "    -I:                   Builds an inverted index"
22
+    echo ""
23
+}
24
+
25
+
26
+while getopts "h?e:f:p:L:I" opt; do
27
+    case $opt in
28
+        h|\?)
29
+            ShowUsage
30
+            exit 0
31
+            ;;
32
+        e)
33
+            CSCOPE_EXE=$OPTARG
34
+            ;;
35
+        f)
36
+            DB_FILE=$OPTARG
37
+            ;;
38
+        p)
39
+            PROJECT_ROOT=$OPTARG
40
+            ;;
41
+        L)
42
+            FILE_LIST_CMD=$OPTARG
43
+            ;;
44
+        I)
45
+            BUILD_INVERTED_INDEX=1
46
+            ;;
47
+    esac
48
+done
49
+
50
+shift $((OPTIND - 1))
51
+
52
+if [ "$1" != "" ]; then
53
+    echo "Invalid Argument: $1"
54
+    exit 1
55
+fi
56
+
57
+echo "Locking cscope DB file..."
58
+echo $$ > "$DB_FILE.lock"
59
+
60
+# Remove lock and temp file if script is stopped unexpectedly.
61
+CleanUp() {
62
+    rm -f "$DB_FILE.lock" "$DB_FILE.files" "$DB_FILE.temp"
63
+    if [ "$BUILD_INVERTED_INDEX" -eq 1 ]; then
64
+        rm -f "$DB_FILE.temp.in" "$DB_FILE.temp.po"
65
+    fi
66
+}
67
+
68
+trap CleanUp INT QUIT TERM EXIT
69
+
70
+PREVIOUS_DIR=$(pwd)
71
+if [ -d "$PROJECT_ROOT" ]; then
72
+    cd "$PROJECT_ROOT"
73
+fi
74
+
75
+if [ -n "${FILE_LIST_CMD}" ]; then
76
+    if [ "${PROJECT_ROOT}" = "." ]; then
77
+        eval "$FILE_LIST_CMD" | while read -r l; do
78
+            echo "\"${l}\""
79
+        done > "${DB_FILE}.files"
80
+    else
81
+        # If using a tags cache directory, use absolute paths
82
+        eval "$FILE_LIST_CMD" | while read -r l; do
83
+            echo "\"${PROJECT_ROOT%/}/${l}\""
84
+        done > "${DB_FILE}.files"
85
+    fi
86
+else
87
+    find . -type f ! -name ${DB_FILE} | while read -r l; do
88
+        echo "\"${l}\""
89
+    done > "${DB_FILE}.files"
90
+fi
91
+
92
+if [ ! -s "${DB_FILE}.files" ]; then
93
+    echo "There is no files to generate cscope DB"
94
+    exit
95
+fi
96
+
97
+CSCOPE_ARGS="${CSCOPE_ARGS} -i ${DB_FILE}.files"
98
+
99
+if [ "$BUILD_INVERTED_INDEX" -eq 1 ]; then
100
+    CSCOPE_ARGS="$CSCOPE_ARGS -q"
101
+fi
102
+
103
+echo "Running cscope"
104
+echo "$CSCOPE_EXE $CSCOPE_ARGS -b -k -f \"$DB_FILE.temp\""
105
+"$CSCOPE_EXE" $CSCOPE_ARGS -v -b -k -f "$DB_FILE.temp"
106
+
107
+if [ -d "$PROJECT_ROOT" ]; then
108
+    cd "$PREVIOUS_DIR"
109
+fi
110
+
111
+echo "Replacing cscope DB file"
112
+if [ "$BUILD_INVERTED_INDEX" -eq 1 ]; then
113
+    echo "mv -f \"$DB_FILE.temp.in\" \"$DB_FILE.in\""
114
+    mv -f "$DB_FILE.temp.in" "$DB_FILE.in"
115
+    echo "mv -f \"$DB_FILE.temp.po\" \"$DB_FILE.po\""
116
+    mv -f "$DB_FILE.temp.po" "$DB_FILE.po"
117
+fi
118
+echo "mv -f \"$DB_FILE.temp\" \"$DB_FILE\""
119
+mv -f "$DB_FILE.temp" "$DB_FILE"
120
+
121
+echo "Unlocking cscope DB file..."
122
+rm -f "$DB_FILE.lock"
123
+
124
+echo "Done."

+ 155
- 0
dotfiles/vim/bundle/vim-gutentags/plat/unix/update_tags.sh View File

@@ -0,0 +1,155 @@
1
+#!/bin/sh
2
+
3
+set -e
4
+
5
+PROG_NAME=$0
6
+CTAGS_EXE=ctags
7
+CTAGS_ARGS=
8
+TAGS_FILE=tags
9
+PROJECT_ROOT=
10
+LOG_FILE=
11
+FILE_LIST_CMD=
12
+FILE_LIST_CMD_IS_ABSOLUTE=0
13
+UPDATED_SOURCE=
14
+POST_PROCESS_CMD=
15
+PAUSE_BEFORE_EXIT=0
16
+
17
+
18
+ShowUsage() {
19
+    echo "Usage:"
20
+    echo "    $PROG_NAME <options>"
21
+    echo ""
22
+    echo "    -e [exe=ctags]: The ctags executable to run"
23
+    echo "    -t [file=tags]: The path to the ctags file to update"
24
+    echo "    -p [dir=]:      The path to the project root"
25
+    echo "    -l [file=]:     The path to a log file"
26
+    echo "    -L [cmd=]:      The file list command to run"
27
+    echo "    -A:             Specifies that the file list command returns "
28
+    echo "                    absolute paths"
29
+    echo "    -s [file=]:     The path to the source file that needs updating"
30
+    echo "    -x [pattern=]:  A pattern of files to exclude"
31
+    echo "    -o [options=]:  An options file to read additional options from"
32
+    echo "    -O [params=]:   Parameters to pass to ctags"
33
+    echo "    -P [cmd=]:      Post process command to run on the tags file"
34
+    echo "    -c:             Ask for confirmation before exiting"
35
+    echo ""
36
+}
37
+
38
+
39
+while getopts "h?e:x:t:p:l:L:s:o:O:P:cA" opt; do
40
+    case $opt in
41
+        h|\?)
42
+            ShowUsage
43
+            exit 0
44
+            ;;
45
+        e)
46
+            CTAGS_EXE=$OPTARG
47
+            ;;
48
+        x)
49
+            CTAGS_ARGS="$CTAGS_ARGS --exclude=$OPTARG"
50
+            ;;
51
+        t)
52
+            TAGS_FILE=$OPTARG
53
+            ;;
54
+        p)
55
+            PROJECT_ROOT=$OPTARG
56
+            ;;
57
+        l)
58
+            LOG_FILE=$OPTARG
59
+            ;;
60
+        L)
61
+            FILE_LIST_CMD=$OPTARG
62
+            ;;
63
+        A)
64
+            FILE_LIST_CMD_IS_ABSOLUTE=1
65
+            ;;
66
+        s)
67
+            UPDATED_SOURCE=$OPTARG
68
+            ;;
69
+        c)
70
+            PAUSE_BEFORE_EXIT=1
71
+            ;;
72
+        o)
73
+            CTAGS_ARGS="$CTAGS_ARGS --options=$OPTARG"
74
+            ;;
75
+        O)
76
+            CTAGS_ARGS="$CTAGS_ARGS $OPTARG"
77
+            ;;
78
+        P)
79
+            POST_PROCESS_CMD=$OPTARG
80
+            ;;
81
+    esac
82
+done
83
+
84
+shift $((OPTIND - 1))
85
+
86
+if [ "$1" != "" ]; then
87
+    echo "Invalid Argument: $1"
88
+    exit 1
89
+fi
90
+
91
+echo "Locking tags file..."
92
+echo $$ > "$TAGS_FILE.lock"
93
+
94
+# Remove lock and temp file if script is stopped unexpectedly.
95
+trap 'errorcode=$?; rm -f "$TAGS_FILE.lock" "$TAGS_FILE.files" "$TAGS_FILE.temp"; exit $errorcode' INT QUIT TERM EXIT
96
+
97
+INDEX_WHOLE_PROJECT=1
98
+if [ -f "$TAGS_FILE" ]; then
99
+    if [ "$UPDATED_SOURCE" != "" ]; then
100
+        echo "Removing references to: $UPDATED_SOURCE"
101
+        tab="	"
102
+        cmd="grep --text -Ev '^[^$tab]+$tab$UPDATED_SOURCE$tab' '$TAGS_FILE' > '$TAGS_FILE.temp'"
103
+        echo "$cmd"
104
+        eval "$cmd" || true
105
+        INDEX_WHOLE_PROJECT=0
106
+    fi
107
+fi
108
+
109
+if [ $INDEX_WHOLE_PROJECT -eq 1 ]; then
110
+    if [ -n "${FILE_LIST_CMD}" ]; then
111
+        if [ "${PROJECT_ROOT}" = "." ] || [ $FILE_LIST_CMD_IS_ABSOLUTE -eq 1 ]; then
112
+            echo "Running file list command"
113
+            echo "eval $FILE_LIST_CMD > \"${TAGS_FILE}.files\""
114
+            eval $FILE_LIST_CMD > "${TAGS_FILE}.files"
115
+        else
116
+            # If using a tags cache directory, use absolute paths
117
+            echo "Running file list command, patching for absolute paths"
118
+            echo "eval $FILE_LIST_CMD"
119
+            eval $FILE_LIST_CMD | while read -r l; do
120
+                echo "${PROJECT_ROOT%/}/${l}"
121
+            done > "${TAGS_FILE}.files"
122
+        fi
123
+        CTAGS_ARGS="${CTAGS_ARGS} -L "${TAGS_FILE}.files""
124
+    else
125
+        CTAGS_ARGS="${CTAGS_ARGS} "${PROJECT_ROOT}""
126
+    fi
127
+
128
+    echo "Running ctags on whole project"
129
+    echo "$CTAGS_EXE -f \"$TAGS_FILE.temp\" $CTAGS_ARGS"
130
+    $CTAGS_EXE -f "$TAGS_FILE.temp" $CTAGS_ARGS
131
+else
132
+    echo "Running ctags on \"$UPDATED_SOURCE\""
133
+    echo "$CTAGS_EXE -f \"$TAGS_FILE.temp\" $CTAGS_ARGS --append \"$UPDATED_SOURCE\""
134
+    $CTAGS_EXE -f "$TAGS_FILE.temp" $CTAGS_ARGS --append "$UPDATED_SOURCE"
135
+fi
136
+
137
+if [ "$POST_PROCESS_CMD" != "" ]; then
138
+    echo "Running post process"
139
+    echo "$POST_PROCESS_CMD \"$TAGS_FILE.temp\""
140
+    $POST_PROCESS_CMD "$TAGS_FILE.temp"
141
+fi
142
+
143
+echo "Replacing tags file"
144
+echo "mv -f \"$TAGS_FILE.temp\" \"$TAGS_FILE\""
145
+mv -f "$TAGS_FILE.temp" "$TAGS_FILE"
146
+
147
+echo "Unlocking tags file..."
148
+rm -f "$TAGS_FILE.lock"
149
+
150
+echo "Done."
151
+
152
+if [ $PAUSE_BEFORE_EXIT -eq 1 ]; then
153
+    printf "Press ENTER to exit..."
154
+    read -r
155
+fi

+ 120
- 0
dotfiles/vim/bundle/vim-gutentags/plat/win32/update_scopedb.cmd View File

@@ -0,0 +1,120 @@
1
+@echo off
2
+setlocal EnableExtensions EnableDelayedExpansion
3
+
4
+rem ==========================================
5
+rem            PARSE ARGUMENTS
6
+rem ==========================================
7
+
8
+set CSCOPE_EXE=cscope
9
+set CSCOPE_ARGS=
10
+set DB_FILE=cscope.out
11
+set FILE_LIST_CMD=
12
+set LOG_FILE=
13
+set BUILD_INVERTED_INDEX=0
14
+
15
+:ParseArgs
16
+if [%1]==[] goto :DoneParseArgs
17
+if [%1]==[-e] (
18
+    set CSCOPE_EXE=%~2
19
+    shift
20
+    goto :LoopParseArgs
21
+)
22
+if [%1]==[-f] (
23
+    set DB_FILE=%~2
24
+    shift
25
+    goto :LoopParseArgs
26
+)
27
+if [%1]==[-p] (
28
+    set PROJ_ROOT=%~2
29
+    shift
30
+    goto :LoopParseArgs
31
+)
32
+if [%1]==[-L] (
33
+    set FILE_LIST_CMD=%~2
34
+    shift
35
+    goto :LoopParseArgs
36
+)
37
+if [%1]==[-l] (
38
+    set LOG_FILE=%~2
39
+    shift
40
+    goto :LoopParseArgs
41
+)
42
+if [%1]==[-I] (
43
+    set BUILD_INVERTED_INDEX=1
44
+    goto :LoopParseArgs
45
+)
46
+echo Invalid Argument: %1
47
+goto :Usage
48
+
49
+:LoopParseArgs
50
+shift
51
+goto :ParseArgs
52
+
53
+:DoneParseArgs
54
+
55
+
56
+rem ==========================================
57
+rem             GENERATE DATABASE
58
+rem ==========================================
59
+
60
+if [%LOG_FILE%]==[] set LOG_FILE=CON
61
+
62
+echo Locking db file > %LOG_FILE%
63
+echo locked > "%DB_FILE%.lock"
64
+
65
+echo Running cscope >> %LOG_FILE%
66
+if NOT ["%FILE_LIST_CMD%"]==[""] (
67
+    if ["%PROJECT_ROOT%"]==["."] (
68
+        for /F "usebackq delims=" %%F in (`%FILE_LIST_CMD%`) do @echo "%%F">%DB_FILE%.files
69
+    ) else (
70
+        rem Potentially useful:
71
+        rem http://stackoverflow.com/questions/9749071/cmd-iterate-stdin-piped-from-another-command
72
+        for /F "usebackq delims=" %%F in (`%FILE_LIST_CMD%`) do @echo "%PROJECT_ROOT%\%%F">%DB_FILE%.files
73
+    )
74
+) ELSE (
75
+    for /F "usebackq delims=" %%F in (`dir /S /B /A-D .`) do @echo "%%F">%DB_FILE%.files
76
+)
77
+
78
+set FILESIZE=0
79
+for /F %%F in ("%DB_FILE%.files") do set FILESIZE=%%~zF
80
+if %FILESIZE% EQU 0 (
81
+    echo There is no files to generate cscope DB
82
+    goto :EOF
83
+)
84
+
85
+set CSCOPE_ARGS=%CSCOPE_ARGS% -i %DB_FILE%.files
86
+if ["%BUILD_INVERTED_INDEX%"]==["1"] (
87
+    set CSCOPE_ARGS=%CSCOPE_ARGS% -q
88
+)
89
+"%CSCOPE_EXE%" %CSCOPE_ARGS% -b -k -f "%DB_FILE%"
90
+if ERRORLEVEL 1 (
91
+    echo ERROR: Cscope executable returned non-zero code. >> %LOG_FILE%
92
+)
93
+
94
+echo Unlocking db file >> %LOG_FILE%
95
+del /F "%DB_FILE%.files" "%DB_FILE%.lock"
96
+if ERRORLEVEL 1 (
97
+    echo ERROR: Unable to remove file lock. >> %LOG_FILE%
98
+)
99
+
100
+echo Done. >> %LOG_FILE%
101
+
102
+goto :EOF
103
+
104
+
105
+rem ==========================================
106
+rem                 USAGE
107
+rem ==========================================
108
+
109
+:Usage
110
+echo Usage:
111
+echo    %~n0 ^<options^>
112
+echo.
113
+echo    -e [exe=cscope]:             The cscope executable to run
114
+echo    -f [file=cscope.out]:        The path to the database file to create
115
+echo    -p [dir=]:                   The path to the project root
116
+echo    -L [cmd=]:                   The file list command to run
117
+echo    -l [log=]:                   The log file to output to
118
+echo    -I:                          Builds an inverted index
119
+echo.
120
+

+ 191
- 0
dotfiles/vim/bundle/vim-gutentags/plat/win32/update_tags.cmd View File

@@ -0,0 +1,191 @@
1
+@echo off
2
+setlocal EnableExtensions EnableDelayedExpansion
3
+
4
+rem ==========================================
5
+rem            PARSE ARGUMENTS
6
+rem ==========================================
7
+
8
+set CTAGS_EXE=ctags
9
+set CTAGS_ARGS=
10
+set TAGS_FILE=tags
11
+set PROJECT_ROOT=
12
+set FILE_LIST_CMD=
13
+set FILE_LIST_CMD_IS_ABSOLUTE=0
14
+set UPDATED_SOURCE=
15
+set POST_PROCESS_CMD=
16
+set PAUSE_BEFORE_EXIT=0
17
+set LOG_FILE=
18
+
19
+:ParseArgs
20
+if [%1]==[] goto :DoneParseArgs
21
+if [%1]==[-e] (
22
+    set CTAGS_EXE=%~2
23
+    shift
24
+    goto :LoopParseArgs
25
+)
26
+if [%1]==[-x] (
27
+    set CTAGS_ARGS=%CTAGS_ARGS% --exclude=%2
28
+    shift
29
+    goto :LoopParseArgs
30
+)
31
+if [%1]==[-t] (
32
+    set TAGS_FILE=%~2
33
+    shift
34
+    goto :LoopParseArgs
35
+)
36
+if [%1]==[-p] (
37
+    set PROJECT_ROOT=%~2
38
+    shift
39
+    goto :LoopParseArgs
40
+)
41
+if [%1]==[-L] (
42
+    set FILE_LIST_CMD=%~2
43
+    shift
44
+    goto :LoopParseArgs
45
+)
46
+if [%1]==[-A] (
47
+    set FILE_LIST_CMD_IS_ABSOLUTE=1
48
+    goto :LoopParseArgs
49
+)
50
+if [%1]==[-s] (
51
+    set UPDATED_SOURCE=%~2
52
+    shift
53
+    goto :LoopParseArgs
54
+)
55
+if [%1]==[-c] (
56
+    set PAUSE_BEFORE_EXIT=1
57
+    goto :LoopParseArgs
58
+)
59
+if [%1]==[-l] (
60
+    set LOG_FILE=%~2
61
+    shift
62
+    goto :LoopParseArgs
63
+)
64
+if [%1]==[-o] (
65
+    set CTAGS_ARGS=%CTAGS_ARGS% --options=%2
66
+    shift
67
+    goto :LoopParseArgs
68
+)
69
+if [%1]==[-O] (
70
+    set CTAGS_ARGS=%CTAGS_ARGS% %~2
71
+    shift
72
+    goto :LoopParseArgs
73
+)
74
+if [%1]==[-P] (
75
+    set POST_PROCESS_CMD=%~2
76
+    shift
77
+    goto :LoopParseArgs
78
+)
79
+echo Invalid Argument: %1
80
+goto :Usage
81
+
82
+:LoopParseArgs
83
+shift
84
+goto :ParseArgs
85
+
86
+:DoneParseArgs
87
+
88
+
89
+rem ==========================================
90
+rem               GENERATE TAGS
91
+rem ==========================================
92
+
93
+if [%LOG_FILE%]==[] set LOG_FILE=CON
94
+
95
+echo Locking tags file... > %LOG_FILE%
96
+echo locked > "%TAGS_FILE%.lock"
97
+
98
+set INDEX_WHOLE_PROJECT=1
99
+if exist "%TAGS_FILE%" (
100
+    if not ["%UPDATED_SOURCE%"]==[""] (
101
+        echo Removing references to: %UPDATED_SOURCE% >> %LOG_FILE%
102
+        echo findstr /V /C:"%UPDATED_SOURCE%" "%TAGS_FILE%" ^> "%TAGS_FILE%.temp" >> %LOG_FILE%
103
+        findstr /V /C:"%UPDATED_SOURCE%" "%TAGS_FILE%" > "%TAGS_FILE%.temp"
104
+        set CTAGS_ARGS=%CTAGS_ARGS% --append "%UPDATED_SOURCE%"
105
+        set INDEX_WHOLE_PROJECT=0
106
+    )
107
+)
108
+if ["%INDEX_WHOLE_PROJECT%"]==["1"] (
109
+    if not ["%FILE_LIST_CMD%"]==[""] (
110
+        echo Running file list command >> %LOG_FILE%
111
+        set use_raw_list=0
112
+        if ["%PROJECT_ROOT%"]==["."] set use_raw_list=1
113
+        if ["%FILE_LIST_CMD_IS_ABSOLUTE%"]==["1"] set use_raw_list=1
114
+        rem No idea why we need to use delayed expansion here to make it work :(
115
+        if ["!use_raw_list!"]==["1"] (
116
+            echo call %FILE_LIST_CMD% ^> %TAGS_FILE%.files >> %LOG_FILE%
117
+            call %FILE_LIST_CMD% > %TAGS_FILE%.files
118
+        ) else (
119
+            rem Potentially useful:
120
+            rem http://stackoverflow.com/questions/9749071/cmd-iterate-stdin-piped-from-another-command
121
+            echo call %FILE_LIST_CMD% -- with loop for prepending project root >> %LOG_FILE%
122
+            type NUL > %TAGS_FILE%.files
123
+            for /F "usebackq delims=" %%F in (`%FILE_LIST_CMD%`) do @echo %PROJECT_ROOT%\%%F >> %TAGS_FILE%.files
124
+        )
125
+        set CTAGS_ARGS=%CTAGS_ARGS% -L %TAGS_FILE%.files
126
+    ) else (
127
+        set CTAGS_ARGS=%CTAGS_ARGS% "%PROJECT_ROOT%"
128
+    )
129
+)
130
+
131
+echo Running ctags >> %LOG_FILE%
132
+echo call "%CTAGS_EXE%" -f "%TAGS_FILE%.temp" %CTAGS_ARGS% >> %LOG_FILE%
133
+call "%CTAGS_EXE%" -f "%TAGS_FILE%.temp" %CTAGS_ARGS% >> %LOG_FILE% 2>&1
134
+if ERRORLEVEL 1 (
135
+    echo ERROR: Ctags executable returned non-zero code. >> %LOG_FILE%
136
+    goto :Unlock
137
+)
138
+
139
+if not ["%POST_PROCESS_CMD%"]==[""] (
140
+    echo Running post process >> %LOG_FILE%
141
+    echo call %POST_PROCESS_CMD% %TAGS_FILE%.temp >> %LOG_FILE%
142
+    call %POST_PROCESS_CMD% %TAGS_FILE%.temp >> %LOG_FILE% 2>&1
143
+    if ERRORLEVEL 1 (
144
+        echo ERROR: Post process returned non-zero code. >> %LOG_FILE%
145
+        goto :Unlock
146
+    )
147
+)
148
+
149
+echo Replacing tags file >> %LOG_FILE%
150
+echo move /Y "%TAGS_FILE%.temp" "%TAGS_FILE%" >> %LOG_FILE%
151
+move /Y "%TAGS_FILE%.temp" "%TAGS_FILE%" >> %LOG_FILE% 2>&1
152
+if ERRORLEVEL 1 (
153
+    echo ERROR: Unable to rename temp tags file into actual tags file. >> %LOG_FILE%
154
+    goto :Unlock
155
+)
156
+
157
+:Unlock
158
+echo Unlocking tags file... >> %LOG_FILE%
159
+del /F "%TAGS_FILE%.files" "%TAGS_FILE%.lock"
160
+if ERRORLEVEL 1 (
161
+    echo ERROR: Unable to remove file lock. >> %LOG_FILE%
162
+)
163
+
164
+echo Done. >> %LOG_FILE%
165
+if [%PAUSE_BEFORE_EXIT%]==[1] (
166
+    pause
167
+)
168
+
169
+goto :EOF
170
+
171
+
172
+rem ==========================================
173
+rem                 USAGE
174
+rem ==========================================
175
+
176
+:Usage
177
+echo Usage:
178
+echo    %~n0 ^<options^>
179
+echo.
180
+echo    -e [exe=ctags]: The ctags executable to run
181
+echo    -t [file=tags]: The path to the ctags file to update
182
+echo    -p [dir=]:      The path to the project root
183
+echo    -L [cmd=]:      The file list command to run
184
+echo    -A:             Specifies that the file list command returns
185
+echo                    absolute paths
186
+echo    -s [file=]:     The path to the source file that needs updating
187
+echo    -l [log=]:      The log file to output to
188
+echo    -o [options=]:  An options file to read additional options from
189
+echo    -c:             Ask for confirmation before exiting
190
+echo.
191
+

+ 114
- 0
dotfiles/vim/bundle/vim-gutentags/plugin/gutentags.vim View File

@@ -0,0 +1,114 @@
1
+" gutentags.vim - Automatic ctags management for Vim
2
+" Maintainer:   Ludovic Chabant <http://ludovic.chabant.com>
3
+" Version:      2.0.0
4
+
5
+" Globals {{{
6
+
7
+if (&cp || get(g:, 'gutentags_dont_load', 0))
8
+    finish
9
+endif
10
+
11
+if v:version < 704
12
+    echoerr "gutentags: this plugin requires vim >= 7.4."
13
+    finish
14
+endif
15
+
16
+if !(has('job') || (has('nvim') && exists('*jobwait')))
17
+    echoerr "gutentags: this plugin requires the job API from Vim8 or Neovim."
18
+    finish
19
+endif
20
+
21
+let g:gutentags_debug = get(g:, 'gutentags_debug', 0)
22
+
23
+if (exists('g:loaded_gutentags') && !g:gutentags_debug)
24
+    finish
25
+endif
26
+if (exists('g:loaded_gutentags') && g:gutentags_debug)
27
+    echom "Reloaded gutentags."
28
+endif
29
+let g:loaded_gutentags = 1
30
+
31
+let g:gutentags_trace = get(g:, 'gutentags_trace', 0)
32
+let g:gutentags_fake = get(g:, 'gutentags_fake', 0)
33
+let g:gutentags_background_update = get(g:, 'gutentags_background_update', 1)
34
+let g:gutentags_pause_after_update = get(g:, 'gutentags_pause_after_update', 0)
35
+let g:gutentags_enabled = get(g:, 'gutentags_enabled', 1)
36
+let g:gutentags_modules = get(g:, 'gutentags_modules', ['ctags'])
37
+
38
+let g:gutentags_init_user_func = get(g:, 'gutentags_init_user_func', 
39
+            \get(g:, 'gutentags_enabled_user_func', ''))
40
+
41
+let g:gutentags_add_ctrlp_root_markers = get(g:, 'gutentags_add_ctrlp_root_markers', 1)
42
+let g:gutentags_add_default_project_roots = get(g:, 'gutentags_add_default_project_roots', 1)
43
+let g:gutentags_project_root = get(g:, 'gutentags_project_root', [])
44
+if g:gutentags_add_default_project_roots
45
+    let g:gutentags_project_root += ['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout']
46
+endif
47
+
48
+let g:gutentags_project_root_finder = get(g:, 'gutentags_project_root_finder', '')
49
+
50
+let g:gutentags_project_info = get(g:, 'gutentags_project_info', [])
51
+call add(g:gutentags_project_info, {'type': 'python', 'file': 'setup.py'})
52
+call add(g:gutentags_project_info, {'type': 'ruby', 'file': 'Gemfile'})
53
+
54
+let g:gutentags_exclude_filetypes = get(g:, 'gutentags_exclude_filetypes', [])
55
+let g:gutentags_exclude_project_root = get(g:, 'gutentags_exclude_project_root', ['/usr/local'])
56
+let g:gutentags_resolve_symlinks = get(g:, 'gutentags_resolve_symlinks', 0)
57
+let g:gutentags_generate_on_new = get(g:, 'gutentags_generate_on_new', 1)
58
+let g:gutentags_generate_on_missing = get(g:, 'gutentags_generate_on_missing', 1)
59
+let g:gutentags_generate_on_write = get(g:, 'gutentags_generate_on_write', 1)
60
+let g:gutentags_generate_on_empty_buffer = get(g:, 'gutentags_generate_on_empty_buffer', 0)
61
+let g:gutentags_file_list_command = get(g:, 'gutentags_file_list_command', '')
62
+
63
+let g:gutentags_use_jobs = get(g:, 'gutentags_use_jobs', has('job'))
64
+
65
+if !exists('g:gutentags_cache_dir')
66
+    let g:gutentags_cache_dir = ''
67
+elseif !empty(g:gutentags_cache_dir)
68
+    " Make sure we get an absolute/resolved path (e.g. expanding `~/`), and
69
+    " strip any trailing slash.
70
+    let g:gutentags_cache_dir = fnamemodify(g:gutentags_cache_dir, ':p')
71
+    let g:gutentags_cache_dir = fnamemodify(g:gutentags_cache_dir, ':s?[/\\]$??')
72
+endif
73
+
74
+let g:gutentags_define_advanced_commands = get(g:, 'gutentags_define_advanced_commands', 0)
75
+
76
+if g:gutentags_cache_dir != '' && !isdirectory(g:gutentags_cache_dir)
77
+    call mkdir(g:gutentags_cache_dir, 'p')
78
+endif
79
+
80
+if has('win32')
81
+    let g:gutentags_plat_dir = expand('<sfile>:h:h:p') . "\\plat\\win32\\"
82
+    let g:gutentags_res_dir = expand('<sfile>:h:h:p') . "\\res\\"
83
+    let g:gutentags_script_ext = '.cmd'
84
+else
85
+    let g:gutentags_plat_dir = expand('<sfile>:h:h:p') . '/plat/unix/'
86
+    let g:gutentags_res_dir = expand('<sfile>:h:h:p') . '/res/'
87
+    let g:gutentags_script_ext = '.sh'
88
+endif
89
+
90
+" }}}
91
+
92
+" Gutentags Setup {{{
93
+
94
+augroup gutentags_detect
95
+    autocmd!
96
+    autocmd BufNewFile,BufReadPost *  call gutentags#setup_gutentags()
97
+    autocmd VimEnter               *  if expand('<amatch>')==''|call gutentags#setup_gutentags()|endif
98
+augroup end
99
+
100
+" }}}
101
+
102
+" Toggles and Miscellaneous Commands {{{
103
+
104
+if g:gutentags_define_advanced_commands
105
+    command! GutentagsToggleEnabled :let g:gutentags_enabled=!g:gutentags_enabled
106
+    command! GutentagsToggleTrace   :call gutentags#toggletrace()
107
+endif
108
+
109
+if g:gutentags_debug
110
+    command! GutentagsToggleFake    :call gutentags#fake()
111
+endif
112
+
113
+" }}}
114
+

+ 2
- 0
dotfiles/vim/bundle/vim-gutentags/res/ctags_recursive.options View File

@@ -0,0 +1,2 @@
1
+--recurse=yes
2
+