Skip to content

Commit 3d7514c

Browse files
committed
set ctags args
1 parent 9f13237 commit 3d7514c

File tree

2 files changed

+40
-35
lines changed

2 files changed

+40
-35
lines changed

README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ Create tags
2525

2626
:Ctags
2727

28-
Delete tags
29-
30-
:CtagsDelete
31-
3228
Create at a Writing the file, default `0`
3329

3430
let g:auto_ctags = 1
@@ -43,11 +39,12 @@ Create the tags name, default `tags`
4339

4440
let g:auto_ctags_tags_name = 'tags'
4541

42+
Create the ctags args, default `--tag-relative --recurse --sort=yes`
43+
44+
let g:auto_ctags_tags_args = '--tag-relative --recurse --sort=yes'
45+
4646
## Policy
4747
* Created in the current directory by default
4848
* Create the version control directory in the configuration
4949
* Can be extended settings in the filetype
5050
* so that it can be used a minimum without any knowledge of tags
51-
52-
## ToDo
53-
* Set ctags option

plugin/auto-ctags.vim

+36-28
Original file line numberDiff line numberDiff line change
@@ -23,50 +23,58 @@ if !exists("g:auto_ctags_tags_name")
2323
let g:auto_ctags_tags_name = 'tags'
2424
endif
2525

26-
let s:ctags_cmd = 'ctags'
27-
let s:ctags_opt = '--tag-relative'
28-
let s:ctags_create = 0
29-
for s:directory in g:auto_ctags_directory_list
30-
if isdirectory(s:directory)
31-
let s:tags_name = s:directory.'/'.g:auto_ctags_tags_name
32-
""silent! execute 'set tags+='.s:tags_name
33-
let s:ctags_opt = s:ctags_opt.' -f '.s:tags_name
34-
let s:ctags_create = 1
35-
endif
36-
if s:ctags_create > 0
37-
break
26+
if !exists("g:auto_ctags_tags_args")
27+
let g:auto_ctags_tags_args = '--tag-relative --recurse --sort=yes'
28+
endif
29+
30+
function! s:get_ctags_path()
31+
let s:path = ''
32+
33+
for s:directory in g:auto_ctags_directory_list
34+
if isdirectory(s:directory)
35+
let s:path = s:directory.'/'.g:auto_ctags_tags_name
36+
break
37+
endif
38+
endfor
39+
40+
return s:path
41+
endfunction
42+
43+
function! s:get_ctags_cmd()
44+
let s:ctags_cmd = ''
45+
46+
let s:tags_name = s:get_ctags_path()
47+
if len(s:tags_name) > 0
48+
let s:ctags_cmd = 'ctags '.g:auto_ctags_tags_args.' -f '.s:tags_name
3849
endif
39-
endfor
4050

41-
function! s:ctags(opt, redraw)
51+
return s:ctags_cmd
52+
endfunction
4253

43-
if s:ctags_create > 0
44-
silent! execute '!'.s:ctags_cmd.' '.s:ctags_opt.' '.a:opt.' 2>/dev/null &'
54+
function! s:ctags(recreate)
55+
if a:recreate > 0
56+
silent! execute '!rm '.s:get_ctags_path().' 2>/dev/null'
4557
endif
4658

47-
if a:redraw > 0
48-
redraw!
59+
let s:cmd = s:get_ctags_cmd()
60+
if len(s:cmd) > 0
61+
silent! execute '!'.s:cmd.' 2>/dev/null &'
4962
endif
50-
endfunction
5163

52-
function! s:ctags_delete()
53-
silent! execute '!rm '.s:tags_name.' 2>/dev/null'
54-
redraw!
64+
if a:recreate > 0
65+
redraw!
66+
endif
5567
endfunction
5668

5769
if g:auto_ctags > 0
5870
augroup auto_ctags
5971
autocmd!
60-
autocmd BufReadPre * call <SID>ctags('', 0)
72+
autocmd BufReadPre * call <SID>ctags(0)
6173
augroup END
6274
endif
6375

6476
if !exists(":Ctags")
65-
command -nargs=0 Ctags call <SID>ctags('', 1)
66-
endif
67-
68-
if !exists(":CtagsDelete")
69-
command -nargs=0 CtagsDelete call <SID>ctags_delete()
77+
command -nargs=0 Ctags call <SID>ctags(1)
7078
endif
7179

7280
let &cpo = s:save_cpo

0 commit comments

Comments
 (0)