-
Notifications
You must be signed in to change notification settings - Fork 6
/
autotag.vim
executable file
·51 lines (42 loc) · 1.24 KB
/
autotag.vim
1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
" (c) Craig Emery 2013
"
" Increment the number below for a dynamic #include guard
let s:autotag_vim_version=1
if exists("g:autotag_vim_version_sourced")
if s:autotag_vim_version == g:autotag_vim_version_sourced
finish
endif
endif
let g:autotag_vim_version_sourced=s:autotag_vim_version
" This file supplies automatic tag regeneration when saving files
" There's a problem with ctags when run with -a (append)
" ctags doesn't remove entries for the supplied source file that no longer exist
" so this script (implemented in python) finds a tags file for the file vim has
" just saved, removes all entries for that source file and *then* runs ctags -a
if has("python")
let s:current_file=expand("<sfile>")
python << EEOOFF
import sys, os, vim
sys.path.insert(0, os.path.dirname(vim.eval("s:current_file")))
from autotag import autotag
EEOOFF
function! AutoTag()
python autotag()
if exists(":TlistUpdate")
TlistUpdate
endif
endfunction
function! AutoTagDebug()
new
file autotag_debug
setlocal buftype=nowrite
setlocal bufhidden=delete
setlocal noswapfile
normal
endfunction
augroup autotag
au!
autocmd BufWritePost,FileWritePost * call AutoTag ()
augroup END
endif " has("python")
" vim:shiftwidth=3:ts=3