Skip to content

Commit 075ffe9

Browse files
committed
Add g:easytags_opts option (issue #98)
See also issue #98 on GitHub: #98
1 parent 706c665 commit 075ffe9

File tree

4 files changed

+57
-26
lines changed

4 files changed

+57
-26
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ The plug-in will try to determine the location where Exuberant Ctags is installe
6262

6363
If you rely entirely on language-specific configuration and don't have a general ctags program, set this to the empty string.
6464

65+
### The `g:easytags_opts` option
66+
67+
If you need to pass custom command line option(s) to the program specified by `g:easytags_cmd` you can set this option to a list of strings to be passed to Exuberant Ctags. Make sure to only use options that are valid in any context, for example the concatenation of `g:easytags_cmd`, `g:easytags_opts` and `--list-languages` should work as expected.
68+
6569
### The `g:easytags_async` option
6670

6771
By default vim-easytags runs Exuberant Ctags and updates your tags file in the foreground, blocking Vim in the process. As your tags files get larger this becomes more annoying. It has been the number one complaint about vim-easytags since I published the first release online.

autoload/xolox/easytags.vim

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: November 3, 2014
3+
" Last Change: November 13, 2014
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '3.8.3'
6+
let g:xolox#easytags#version = '3.9'
77
let g:xolox#easytags#default_pattern_prefix = '\C\<'
88
let g:xolox#easytags#default_pattern_suffix = '\>'
99

@@ -239,15 +239,17 @@ function! s:prep_cmdline(cfile, tagsfile, arguments) " {{{3
239239
let custom_languages = xolox#misc#option#get('easytags_languages', {})
240240
let language = get(custom_languages, vim_file_type, {})
241241
if empty(language)
242-
let program = xolox#misc#option#get('easytags_cmd')
243-
let cmdline = [program, '--fields=+l', '--c-kinds=+p', '--c++-kinds=+p']
242+
let cmdline = [xolox#easytags#ctags_command()]
243+
call add(cmdline, '--fields=+l')
244+
call add(cmdline, '--c-kinds=+p')
245+
call add(cmdline, '--c++-kinds=+p')
244246
call add(cmdline, '--sort=no')
245247
call add(cmdline, '-f-')
246248
if xolox#misc#option#get('easytags_include_members', 0)
247249
call add(cmdline, '--extra=+q')
248250
endif
249251
else
250-
let program = get(language, 'cmd', xolox#misc#option#get('easytags_cmd'))
252+
let program = get(language, 'cmd', xolox#easytags#ctags_command())
251253
if empty(program)
252254
call xolox#misc#msg#warn("easytags.vim %s: No 'cmd' defined for language '%s', and also no global default!", g:xolox#easytags#version, vim_file_type)
253255
return
@@ -431,6 +433,20 @@ let s:invalid_keywords = {
431433

432434
" Public supporting functions (might be useful to others). {{{1
433435

436+
function! xolox#easytags#ctags_command() " {{{2
437+
let program = xolox#misc#option#get('easytags_cmd')
438+
if !empty(program)
439+
let options = xolox#misc#option#get('easytags_opts')
440+
if !empty(options)
441+
let command_line = [program]
442+
call extend(command_line, map(copy(options), 'xolox#misc#escape#shell(v:val)'))
443+
let program = join(command_line)
444+
endif
445+
return program
446+
endif
447+
return ''
448+
endfunction
449+
434450
function! xolox#easytags#get_tagsfile() " {{{2
435451
let tagsfile = ''
436452
" Look for a suitable project specific tags file?

autoload/xolox/easytags/filetypes.vim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: October 21, 2014
3+
" Last Change: November 13, 2014
44
" URL: http://peterodding.com/code/vim/easytags/
55

66
" This submodule of the vim-easytags plug-in translates between back and forth
@@ -87,10 +87,11 @@ function! s:discover_supported_filetypes() " {{{1
8787
" Initialize predefined groups & mappings and discover supported file types.
8888
if !s:discovered_filetypes
8989
" Discover the file types supported by Exuberant Ctags?
90-
if !empty(g:easytags_cmd)
90+
let command_line = xolox#easytags#ctags_command()
91+
if !empty(command_line)
9192
let starttime = xolox#misc#timer#start()
92-
let command = g:easytags_cmd . ' --list-languages'
93-
for line in xolox#misc#os#exec({'command': command})['stdout']
93+
let command_line .= ' --list-languages'
94+
for line in xolox#misc#os#exec({'command': command_line})['stdout']
9495
if line =~ '\[disabled\]$'
9596
" Ignore languages that have been explicitly disabled using `--languages=-Vim'.
9697
continue

doc/easytags.txt

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@ Contents ~
1111
2. The |:HighlightTags| command
1212
4. Options |easytags-options|
1313
1. The |g:easytags_cmd| option
14-
2. The |g:easytags_async| option
15-
3. The |g:easytags_syntax_keyword| option
16-
4. The |g:easytags_languages| option
17-
5. The |g:easytags_file| option
18-
6. The |g:easytags_dynamic_files| option
19-
7. The |g:easytags_by_filetype| option
20-
8. The |g:easytags_events| option
21-
9. The |g:easytags_always_enabled| option
22-
10. The |g:easytags_on_cursorhold| option
23-
11. The |g:easytags_updatetime_min| option
24-
12. The |g:easytags_auto_update| option
25-
13. The |g:easytags_auto_highlight| option
26-
14. The |g:easytags_autorecurse| option
27-
15. The |g:easytags_include_members| option
28-
16. The |g:easytags_resolve_links| option
29-
17. The |g:easytags_suppress_ctags_warning| option
30-
18. The |g:easytags_suppress_report| option
14+
2. The |g:easytags_opts| option
15+
3. The |g:easytags_async| option
16+
4. The |g:easytags_syntax_keyword| option
17+
5. The |g:easytags_languages| option
18+
6. The |g:easytags_file| option
19+
7. The |g:easytags_dynamic_files| option
20+
8. The |g:easytags_by_filetype| option
21+
9. The |g:easytags_events| option
22+
10. The |g:easytags_always_enabled| option
23+
11. The |g:easytags_on_cursorhold| option
24+
12. The |g:easytags_updatetime_min| option
25+
13. The |g:easytags_auto_update| option
26+
14. The |g:easytags_auto_highlight| option
27+
15. The |g:easytags_autorecurse| option
28+
16. The |g:easytags_include_members| option
29+
17. The |g:easytags_resolve_links| option
30+
18. The |g:easytags_suppress_ctags_warning| option
31+
19. The |g:easytags_suppress_report| option
3132
5. Customizing the easytags plug-in |customizing-easytags-plug-in|
3233
1. Passing custom command line arguments to Exuberant Ctags |easytags-passing-custom-command-line-arguments-to-exuberant-ctags|
3334
2. Update & highlight tags immediately after save |easytags-update-highlight-tags-immediately-after-save|
@@ -186,6 +187,15 @@ you've installed Exuberant Ctags, e.g.:
186187
If you rely entirely on language-specific configuration and don't have a
187188
general ctags program, set this to the empty string.
188189

190+
-------------------------------------------------------------------------------
191+
The *g:easytags_opts* option
192+
193+
If you need to pass custom command line option(s) to the program specified by
194+
|g:easytags_cmd| you can set this option to a list of strings to be passed to
195+
Exuberant Ctags. Make sure to only use options that are valid in any context,
196+
for example the concatenation of |g:easytags_cmd|, |g:easytags_opts| and
197+
'--list-languages' should work as expected.
198+
189199
-------------------------------------------------------------------------------
190200
The *g:easytags_async* option
191201

0 commit comments

Comments
 (0)