Skip to content

Commit 2e05e0e

Browse files
committed
Support buffer local variants of most options
1 parent 82d2b7e commit 2e05e0e

File tree

4 files changed

+42
-57
lines changed

4 files changed

+42
-57
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ Note that this command will be executed automatically every once in a while, ass
4040

4141
## Options
4242

43+
The easytags plug-in should work out of the box but if you don't like the default configuration you can change how it works by setting the variables documented below. Most of these variables can also be changed for specific files by setting a buffer local variable instead of the global variable. For example to disable automatic highlighting (enabled by default) only in Python files you can add the following line to your [vimrc script] [vimrc]:
44+
45+
:autocmd FileType python let b:easytags_auto_highlight = 0
46+
47+
Note that buffer local variables always override global variables, so if you want to undo this for a specific file you have to use [:unlet] [unlet]:
48+
49+
:unlet b:easytags_auto_highlight
50+
4351
### The `g:easytags_cmd` option
4452

4553
The plug-in will try to determine the location where Exuberant Ctags is installed on its own but this might not always work because any given executable named `ctags` in your `$PATH` might not in fact be Exuberant Ctags but some older, more primitive `ctags` implementation which doesn't support the same command line options and thus breaks the easytags plug-in. If this is the case you can set the global variable `g:easytags_cmd` to the location where you've installed Exuberant Ctags, e.g.:
@@ -102,20 +110,12 @@ By default the plug-in automatically updates and highlights your tags when you s
102110

103111
:let g:easytags_auto_update = 0
104112

105-
If you want to disable automatic updating for a single file you can execute the following command while editing the file:
106-
107-
:let b:easytags_auto_update = 0
108-
109113
### The `g:easytags_auto_highlight` option
110114

111115
By default the plug-in automatically updates and highlights your tags when you stop typing for a moment. If you want to disable automatic highlighting while keeping automatic updating enabled you can set this option to false:
112116

113117
:let g:easytags_auto_highlight = 0
114118

115-
If you want to disable automatic highlighting for a single file you can execute the following command while editing the file:
116-
117-
:let b:easytags_auto_highlight = 0
118-
119119
### The `g:easytags_autorecurse` option
120120

121121
When the `:UpdateTags` command is executed automatically or without arguments, it defaults to updating just the tags for the current file. If you'd rather have it recursively scan everything below the directory of the current file then set this option to true (1):

autoload/xolox/easytags.vim

Lines changed: 11 additions & 10 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: June 26, 2011
3+
" Last Change: June 27, 2011
44
" URL: http://peterodding.com/code/vim/easytags/
55

66
" Public interface through (automatic) commands. {{{1
@@ -109,7 +109,7 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
109109
return ''
110110
endif
111111
let silent = a:silent || a:filter_tags
112-
if g:easytags_autorecurse
112+
if xolox#misc#option#get('easytags_autorecurse', 0)
113113
let cdir = s:resolve(expand('%:p:h'))
114114
if !isdirectory(cdir)
115115
if silent | return '' | endif
@@ -132,20 +132,21 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
132132
endfunction
133133

134134
function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
135-
let cmdline = [g:easytags_cmd, '--fields=+l', '--c-kinds=+p', '--c++-kinds=+p']
135+
let program = xolox#misc#option#get('easytags_cmd')
136+
let cmdline = [program, '--fields=+l', '--c-kinds=+p', '--c++-kinds=+p']
136137
if a:firstrun
137138
call add(cmdline, shellescape('-f' . a:tagsfile))
138139
call add(cmdline, '--sort=' . (&ic ? 'foldcase' : 'yes'))
139140
else
140141
call add(cmdline, '--sort=no')
141142
call add(cmdline, '-f-')
142143
endif
143-
if g:easytags_include_members
144+
if xolox#misc#option#get('easytags_include_members', 0)
144145
call add(cmdline, '--extra=+q')
145146
endif
146147
let have_args = 0
147148
if a:cfile != ''
148-
if g:easytags_autorecurse
149+
if xolox#misc#option#get('easytags_autorecurse', 0)
149150
call add(cmdline, '-R')
150151
call add(cmdline, shellescape(a:cfile))
151152
else
@@ -504,14 +505,14 @@ endfunction
504505

505506
function! xolox#easytags#get_tagsfile() " {{{2
506507
" Look for a writable project specific tags file?
507-
if g:easytags_dynamic_files
508+
if xolox#misc#option#get('easytags_dynamic_files', 0)
508509
let files = tagfiles()
509510
if len(files) > 0 && filewritable(files[0]) == 1
510511
return files[0]
511512
endif
512513
endif
513514
" Default to the global tags file.
514-
let tagsfile = expand(g:easytags_file)
515+
let tagsfile = expand(xolox#misc#option#get('easytags_file'))
515516
" Check if a file type specific tags file is useful?
516517
if !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0
517518
let directory = xolox#misc#path#absolute(g:easytags_by_filetype)
@@ -583,7 +584,7 @@ endfunction
583584
" Miscellaneous script-local functions. {{{1
584585

585586
function! s:resolve(filename) " {{{2
586-
if g:easytags_resolve_links
587+
if xolox#misc#option#get('easytags_resolve_links', 0)
587588
return resolve(a:filename)
588589
else
589590
return a:filename
@@ -618,7 +619,7 @@ function! s:python_available() " {{{2
618619
endfunction
619620

620621
function! s:highlight_with_python(syntax_group, tagkind) " {{{2
621-
if g:easytags_python_enabled && s:python_available()
622+
if xolox#misc#option#get('easytags_python_enabled', 1) && s:python_available()
622623
" Gather arguments for Python function.
623624
let context = {}
624625
let context['tagsfiles'] = tagfiles()
@@ -702,7 +703,7 @@ call xolox#easytags#define_tagkind({
702703
highlight def link cEnum Identifier
703704
highlight def link cFunction Function
704705

705-
if g:easytags_include_members
706+
if xolox#misc#option#get('easytags_include_members', 0)
706707
call xolox#easytags#define_tagkind({
707708
\ 'filetype': 'c',
708709
\ 'hlgroup': 'cMember',

doc/easytags.txt

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ assuming you haven't changed |g:easytags_on_cursorhold|.
9797
*easytags-options*
9898
Options ~
9999

100+
The easytags plug-in should work out of the box but if you don't like the
101+
default configuration you can change how it works by setting the variables
102+
documented below. Most of these variables can also be changed for specific
103+
files by setting a buffer local variable instead of the global variable. For
104+
example to disable automatic highlighting (enabled by default) only in Python
105+
files you can add the following line to your |vimrc| script:
106+
>
107+
:autocmd FileType python let b:easytags_auto_highlight = 0
108+
109+
Note that buffer local variables always override global variables, so if you
110+
want to undo this for a specific file you have to use |:unlet|:
111+
>
112+
:unlet b:easytags_auto_highlight
113+
100114
-------------------------------------------------------------------------------
101115
The *g:easytags_cmd* option
102116

@@ -207,11 +221,6 @@ keeping automatic highlighting enabled you can set this option to false:
207221
>
208222
:let g:easytags_auto_update = 0
209223
210-
If you want to disable automatic updating for a single file you can execute
211-
the following command while editing the file:
212-
>
213-
:let b:easytags_auto_update = 0
214-
215224
-------------------------------------------------------------------------------
216225
The *g:easytags_auto_highlight* option
217226

@@ -221,11 +230,6 @@ keeping automatic updating enabled you can set this option to false:
221230
>
222231
:let g:easytags_auto_highlight = 0
223232
224-
If you want to disable automatic highlighting for a single file you can
225-
execute the following command while editing the file:
226-
>
227-
:let b:easytags_auto_highlight = 0
228-
229233
-------------------------------------------------------------------------------
230234
The *g:easytags_autorecurse* option
231235

@@ -240,7 +244,7 @@ You have to explicitly enable this option because it should only be used while
240244
navigating around small directory trees. Imagine always having this option
241245
enabled and then having to edit a file in e.g. the root of your home
242246
directory: The 'easytags.vim' plug-in would freeze Vim for a long time while
243-
you'd have to wait for Exuberant Cags to scan thousands of files...
247+
you'd have to wait for Exuberant Ctags to scan thousands of files...
244248

245249
Note that when you enable this option the 'easytags.vim' plug-in might ignore
246250
other options like |g:easytags_resolve_links|. This is an implementation
@@ -433,8 +437,8 @@ is to reduce the number of tagged identifiers...
433437

434438
In my case the solution was to move most of the tags from '/usr/include/' over
435439
to project specific tags files which are automatically loaded by Vim when I
436-
edit files in different projects because I've set the |'tags'| option as
437-
follows:
440+
edit files in different projects because I've set the ['tags' option] ['tags']
441+
as follows:
438442
>
439443
:set tags=./.tags;,~/.vimtags
440444
@@ -444,11 +448,11 @@ also recurses upwards so that you can nest files arbitrarily deep under your
444448
project directories.
445449

446450
-------------------------------------------------------------------------------
447-
The plug-in doesn't seem to work in Cygwin [12] ~
451+
The plug-in doesn't seem to work in Cygwin ~
448452

449-
If you want to use the plug-in with Vim under Cygwin, you need to have the
450-
Cygwin version of Ctags installed instead of the Windows version (thanks to
451-
Alex Zuroff for reporting this!).
453+
If you want to use the plug-in with Vim under Cygwin [12], you need to have
454+
the Cygwin version of Ctags installed instead of the Windows version (thanks
455+
to Alex Zuroff for reporting this!).
452456

453457
===============================================================================
454458
*easytags-contact*

plugin/easytags.vim

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 26, 2011
3+
" Last Change: June 27, 2011
44
" URL: http://peterodding.com/code/vim/easytags/
55
" Requires: Exuberant Ctags (http://ctags.sf.net)
66

@@ -12,7 +12,7 @@ if &cp || exists('g:loaded_easytags')
1212
finish
1313
endif
1414

15-
let g:easytags_version = '2.4.7'
15+
let g:easytags_version = '2.4.8'
1616

1717
" Configuration defaults and initialization. {{{1
1818

@@ -24,18 +24,10 @@ if !exists('g:easytags_file')
2424
endif
2525
endif
2626

27-
if !exists('g:easytags_dynamic_files')
28-
let g:easytags_dynamic_files = 0
29-
endif
30-
3127
if !exists('g:easytags_by_filetype')
3228
let g:easytags_by_filetype = ''
3329
endif
3430

35-
if !exists('g:easytags_resolve_links')
36-
let g:easytags_resolve_links = 0
37-
endif
38-
3931
if !exists('g:easytags_events')
4032
let g:easytags_events = []
4133
if !exists('g:easytags_on_cursorhold') || g:easytags_on_cursorhold
@@ -50,18 +42,6 @@ if !exists('g:easytags_ignored_filetypes')
5042
let g:easytags_ignored_filetypes = '^tex$'
5143
endif
5244

53-
if !exists('g:easytags_autorecurse')
54-
let g:easytags_autorecurse = 0
55-
endif
56-
57-
if !exists('g:easytags_include_members')
58-
let g:easytags_include_members = 0
59-
endif
60-
61-
if !exists('g:easytags_python_enabled')
62-
let g:easytags_python_enabled = 1
63-
endif
64-
6545
if !exists('g:easytags_python_script')
6646
let g:easytags_python_script = expand('<sfile>:p:h') . '/../misc/easytags/highlight.py'
6747
endif

0 commit comments

Comments
 (0)