Skip to content
This repository
Browse code

Support buffer local variants of most options

  • Loading branch information...
commit 2e05e0ea8370f4f83163a3a6383476135445a463 1 parent 82d2b7e
Peter Odding authored June 27, 2011
16  README.md
Source Rendered
@@ -40,6 +40,14 @@ Note that this command will be executed automatically every once in a while, ass
40 40
 
41 41
 ## Options
42 42
 
  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
+
43 51
 ### The `g:easytags_cmd` option
44 52
 
45 53
 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
102 110
 
103 111
     :let g:easytags_auto_update = 0
104 112
 
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  
-
109 113
 ### The `g:easytags_auto_highlight` option
110 114
 
111 115
 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:
112 116
 
113 117
     :let g:easytags_auto_highlight = 0
114 118
 
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  
-
119 119
 ### The `g:easytags_autorecurse` option
120 120
 
121 121
 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):
21  autoload/xolox/easytags.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 26, 2011
  3
+" Last Change: June 27, 2011
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 
6 6
 " Public interface through (automatic) commands. {{{1
@@ -109,7 +109,7 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
109 109
     return ''
110 110
   endif
111 111
   let silent = a:silent || a:filter_tags
112  
-  if g:easytags_autorecurse
  112
+  if xolox#misc#option#get('easytags_autorecurse', 0)
113 113
     let cdir = s:resolve(expand('%:p:h'))
114 114
     if !isdirectory(cdir)
115 115
       if silent | return '' | endif
@@ -132,7 +132,8 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
132 132
 endfunction
133 133
 
134 134
 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']
136 137
   if a:firstrun
137 138
     call add(cmdline, shellescape('-f' . a:tagsfile))
138 139
     call add(cmdline, '--sort=' . (&ic ? 'foldcase' : 'yes'))
@@ -140,12 +141,12 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
140 141
     call add(cmdline, '--sort=no')
141 142
     call add(cmdline, '-f-')
142 143
   endif
143  
-  if g:easytags_include_members
  144
+  if xolox#misc#option#get('easytags_include_members', 0)
144 145
     call add(cmdline, '--extra=+q')
145 146
   endif
146 147
   let have_args = 0
147 148
   if a:cfile != ''
148  
-    if g:easytags_autorecurse
  149
+    if xolox#misc#option#get('easytags_autorecurse', 0)
149 150
       call add(cmdline, '-R')
150 151
       call add(cmdline, shellescape(a:cfile))
151 152
     else
@@ -504,14 +505,14 @@ endfunction
504 505
 
505 506
 function! xolox#easytags#get_tagsfile() " {{{2
506 507
   " Look for a writable project specific tags file?
507  
-  if g:easytags_dynamic_files
  508
+  if xolox#misc#option#get('easytags_dynamic_files', 0)
508 509
     let files = tagfiles()
509 510
     if len(files) > 0 && filewritable(files[0]) == 1
510 511
       return files[0]
511 512
     endif
512 513
   endif
513 514
   " Default to the global tags file.
514  
-  let tagsfile = expand(g:easytags_file)
  515
+  let tagsfile = expand(xolox#misc#option#get('easytags_file'))
515 516
   " Check if a file type specific tags file is useful?
516 517
   if !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0
517 518
     let directory = xolox#misc#path#absolute(g:easytags_by_filetype)
@@ -583,7 +584,7 @@ endfunction
583 584
 " Miscellaneous script-local functions. {{{1
584 585
 
585 586
 function! s:resolve(filename) " {{{2
586  
-  if g:easytags_resolve_links
  587
+  if xolox#misc#option#get('easytags_resolve_links', 0)
587 588
     return resolve(a:filename)
588 589
   else
589 590
     return a:filename
@@ -618,7 +619,7 @@ function! s:python_available() " {{{2
618 619
 endfunction
619 620
 
620 621
 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()
622 623
     " Gather arguments for Python function.
623 624
     let context = {}
624 625
     let context['tagsfiles'] = tagfiles()
@@ -702,7 +703,7 @@ call xolox#easytags#define_tagkind({
702 703
 highlight def link cEnum Identifier
703 704
 highlight def link cFunction Function
704 705
 
705  
-if g:easytags_include_members
  706
+if xolox#misc#option#get('easytags_include_members', 0)
706 707
   call xolox#easytags#define_tagkind({
707 708
         \ 'filetype': 'c',
708 709
         \ 'hlgroup': 'cMember',
38  doc/easytags.txt
@@ -97,6 +97,20 @@ assuming you haven't changed |g:easytags_on_cursorhold|.
97 97
                                                               *easytags-options*
98 98
 Options ~
99 99
 
  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
+
100 114
 -------------------------------------------------------------------------------
101 115
 The *g:easytags_cmd* option
102 116
 
@@ -207,11 +221,6 @@ keeping automatic highlighting enabled you can set this option to false:
207 221
 >
208 222
     :let g:easytags_auto_update = 0
209 223
 
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  
-
215 224
 -------------------------------------------------------------------------------
216 225
 The *g:easytags_auto_highlight* option
217 226
 
@@ -221,11 +230,6 @@ keeping automatic updating enabled you can set this option to false:
221 230
 >
222 231
     :let g:easytags_auto_highlight = 0
223 232
 
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  
-
229 233
 -------------------------------------------------------------------------------
230 234
 The *g:easytags_autorecurse* option
231 235
 
@@ -240,7 +244,7 @@ You have to explicitly enable this option because it should only be used while
240 244
 navigating around small directory trees. Imagine always having this option
241 245
 enabled and then having to edit a file in e.g. the root of your home
242 246
 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...
244 248
 
245 249
 Note that when you enable this option the 'easytags.vim' plug-in might ignore
246 250
 other options like |g:easytags_resolve_links|. This is an implementation
@@ -433,8 +437,8 @@ is to reduce the number of tagged identifiers...
433 437
 
434 438
 In my case the solution was to move most of the tags from '/usr/include/' over
435 439
 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:
438 442
 >
439 443
     :set tags=./.tags;,~/.vimtags
440 444
 
@@ -444,11 +448,11 @@ also recurses upwards so that you can nest files arbitrarily deep under your
444 448
 project directories.
445 449
 
446 450
 -------------------------------------------------------------------------------
447  
-The plug-in doesn't seem to work in Cygwin [12] ~
  451
+The plug-in doesn't seem to work in Cygwin ~
448 452
 
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!).
452 456
 
453 457
 ===============================================================================
454 458
                                                               *easytags-contact*
24  plugin/easytags.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 26, 2011
  3
+" Last Change: June 27, 2011
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 " Requires: Exuberant Ctags (http://ctags.sf.net)
6 6
 
@@ -12,7 +12,7 @@ if &cp || exists('g:loaded_easytags')
12 12
   finish
13 13
 endif
14 14
 
15  
-let g:easytags_version = '2.4.7'
  15
+let g:easytags_version = '2.4.8'
16 16
 
17 17
 " Configuration defaults and initialization. {{{1
18 18
 
@@ -24,18 +24,10 @@ if !exists('g:easytags_file')
24 24
   endif
25 25
 endif
26 26
 
27  
-if !exists('g:easytags_dynamic_files')
28  
-  let g:easytags_dynamic_files = 0
29  
-endif
30  
-
31 27
 if !exists('g:easytags_by_filetype')
32 28
   let g:easytags_by_filetype = ''
33 29
 endif
34 30
 
35  
-if !exists('g:easytags_resolve_links')
36  
-  let g:easytags_resolve_links = 0
37  
-endif
38  
-
39 31
 if !exists('g:easytags_events')
40 32
   let g:easytags_events = []
41 33
   if !exists('g:easytags_on_cursorhold') || g:easytags_on_cursorhold
@@ -50,18 +42,6 @@ if !exists('g:easytags_ignored_filetypes')
50 42
   let g:easytags_ignored_filetypes = '^tex$'
51 43
 endif
52 44
 
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  
-
65 45
 if !exists('g:easytags_python_script')
66 46
   let g:easytags_python_script = expand('<sfile>:p:h') . '/../misc/easytags/highlight.py'
67 47
 endif

0 notes on commit 2e05e0e

Please sign in to comment.
Something went wrong with that request. Please try again.