aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2011-06-27 03:31:25 +0200
committerPeter Odding <peter@peterodding.com>2011-06-27 03:31:25 +0200
commit2e05e0ea8370f4f83163a3a6383476135445a463 (patch)
tree190bfd344f41916daaaa5fd6d2878232233f9104
parent82d2b7eb53f57bdae77e0f9f1ad2b8a0bf9dcac5 (diff)
downloadvim-easytags-2e05e0ea8370f4f83163a3a6383476135445a463.tar.gz
Support buffer local variants of most options
-rw-r--r--README.md16
-rw-r--r--autoload/xolox/easytags.vim21
-rw-r--r--doc/easytags.txt38
-rw-r--r--plugin/easytags.vim24
4 files changed, 42 insertions, 57 deletions
diff --git a/README.md b/README.md
index 32538b4..dfcff98 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,14 @@ Note that this command will be executed automatically every once in a while, ass
## Options
+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]:
+
+ :autocmd FileType python let b:easytags_auto_highlight = 0
+
+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]:
+
+ :unlet b:easytags_auto_highlight
+
### The `g:easytags_cmd` option
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
:let g:easytags_auto_update = 0
-If you want to disable automatic updating for a single file you can execute the following command while editing the file:
-
- :let b:easytags_auto_update = 0
-
### The `g:easytags_auto_highlight` option
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:
:let g:easytags_auto_highlight = 0
-If you want to disable automatic highlighting for a single file you can execute the following command while editing the file:
-
- :let b:easytags_auto_highlight = 0
-
### The `g:easytags_autorecurse` option
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):
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index 88a7562..941dcd2 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -1,6 +1,6 @@
" Vim script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: June 26, 2011
+" Last Change: June 27, 2011
" URL: http://peterodding.com/code/vim/easytags/
" Public interface through (automatic) commands. {{{1
@@ -109,7 +109,7 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
return ''
endif
let silent = a:silent || a:filter_tags
- if g:easytags_autorecurse
+ if xolox#misc#option#get('easytags_autorecurse', 0)
let cdir = s:resolve(expand('%:p:h'))
if !isdirectory(cdir)
if silent | return '' | endif
@@ -132,7 +132,8 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
endfunction
function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
- let cmdline = [g:easytags_cmd, '--fields=+l', '--c-kinds=+p', '--c++-kinds=+p']
+ let program = xolox#misc#option#get('easytags_cmd')
+ let cmdline = [program, '--fields=+l', '--c-kinds=+p', '--c++-kinds=+p']
if a:firstrun
call add(cmdline, shellescape('-f' . a:tagsfile))
call add(cmdline, '--sort=' . (&ic ? 'foldcase' : 'yes'))
@@ -140,12 +141,12 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
call add(cmdline, '--sort=no')
call add(cmdline, '-f-')
endif
- if g:easytags_include_members
+ if xolox#misc#option#get('easytags_include_members', 0)
call add(cmdline, '--extra=+q')
endif
let have_args = 0
if a:cfile != ''
- if g:easytags_autorecurse
+ if xolox#misc#option#get('easytags_autorecurse', 0)
call add(cmdline, '-R')
call add(cmdline, shellescape(a:cfile))
else
@@ -504,14 +505,14 @@ endfunction
function! xolox#easytags#get_tagsfile() " {{{2
" Look for a writable project specific tags file?
- if g:easytags_dynamic_files
+ if xolox#misc#option#get('easytags_dynamic_files', 0)
let files = tagfiles()
if len(files) > 0 && filewritable(files[0]) == 1
return files[0]
endif
endif
" Default to the global tags file.
- let tagsfile = expand(g:easytags_file)
+ let tagsfile = expand(xolox#misc#option#get('easytags_file'))
" Check if a file type specific tags file is useful?
if !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0
let directory = xolox#misc#path#absolute(g:easytags_by_filetype)
@@ -583,7 +584,7 @@ endfunction
" Miscellaneous script-local functions. {{{1
function! s:resolve(filename) " {{{2
- if g:easytags_resolve_links
+ if xolox#misc#option#get('easytags_resolve_links', 0)
return resolve(a:filename)
else
return a:filename
@@ -618,7 +619,7 @@ function! s:python_available() " {{{2
endfunction
function! s:highlight_with_python(syntax_group, tagkind) " {{{2
- if g:easytags_python_enabled && s:python_available()
+ if xolox#misc#option#get('easytags_python_enabled', 1) && s:python_available()
" Gather arguments for Python function.
let context = {}
let context['tagsfiles'] = tagfiles()
@@ -702,7 +703,7 @@ call xolox#easytags#define_tagkind({
highlight def link cEnum Identifier
highlight def link cFunction Function
-if g:easytags_include_members
+if xolox#misc#option#get('easytags_include_members', 0)
call xolox#easytags#define_tagkind({
\ 'filetype': 'c',
\ 'hlgroup': 'cMember',
diff --git a/doc/easytags.txt b/doc/easytags.txt
index 7579a9c..6642511 100644
--- a/doc/easytags.txt
+++ b/doc/easytags.txt
@@ -97,6 +97,20 @@ assuming you haven't changed |g:easytags_on_cursorhold|.
*easytags-options*
Options ~
+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:
+>
+ :autocmd FileType python let b:easytags_auto_highlight = 0
+
+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 b:easytags_auto_highlight
+
-------------------------------------------------------------------------------
The *g:easytags_cmd* option
@@ -207,11 +221,6 @@ keeping automatic highlighting enabled you can set this option to false:
>
:let g:easytags_auto_update = 0
-If you want to disable automatic updating for a single file you can execute
-the following command while editing the file:
->
- :let b:easytags_auto_update = 0
-
-------------------------------------------------------------------------------
The *g:easytags_auto_highlight* option
@@ -221,11 +230,6 @@ keeping automatic updating enabled you can set this option to false:
>
:let g:easytags_auto_highlight = 0
-If you want to disable automatic highlighting for a single file you can
-execute the following command while editing the file:
->
- :let b:easytags_auto_highlight = 0
-
-------------------------------------------------------------------------------
The *g:easytags_autorecurse* option
@@ -240,7 +244,7 @@ You have to explicitly enable this option because it should only be used while
navigating around small directory trees. Imagine always having this option
enabled and then having to edit a file in e.g. the root of your home
directory: The 'easytags.vim' plug-in would freeze Vim for a long time while
-you'd have to wait for Exuberant Cags to scan thousands of files...
+you'd have to wait for Exuberant Ctags to scan thousands of files...
Note that when you enable this option the 'easytags.vim' plug-in might ignore
other options like |g:easytags_resolve_links|. This is an implementation
@@ -433,8 +437,8 @@ is to reduce the number of tagged identifiers...
In my case the solution was to move most of the tags from '/usr/include/' over
to project specific tags files which are automatically loaded by Vim when I
-edit files in different projects because I've set the |'tags'| option as
-follows:
+edit files in different projects because I've set the ['tags' option] ['tags']
+as follows:
>
:set tags=./.tags;,~/.vimtags
@@ -444,11 +448,11 @@ also recurses upwards so that you can nest files arbitrarily deep under your
project directories.
-------------------------------------------------------------------------------
-The plug-in doesn't seem to work in Cygwin [12] ~
+The plug-in doesn't seem to work in Cygwin ~
-If you want to use the plug-in with Vim under Cygwin, you need to have the
-Cygwin version of Ctags installed instead of the Windows version (thanks to
-Alex Zuroff for reporting this!).
+If you want to use the plug-in with Vim under Cygwin [12], you need to have
+the Cygwin version of Ctags installed instead of the Windows version (thanks
+to Alex Zuroff for reporting this!).
===============================================================================
*easytags-contact*
diff --git a/plugin/easytags.vim b/plugin/easytags.vim
index 96155ae..c989783 100644
--- a/plugin/easytags.vim
+++ b/plugin/easytags.vim
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: June 26, 2011
+" Last Change: June 27, 2011
" URL: http://peterodding.com/code/vim/easytags/
" Requires: Exuberant Ctags (http://ctags.sf.net)
@@ -12,7 +12,7 @@ if &cp || exists('g:loaded_easytags')
finish
endif
-let g:easytags_version = '2.4.7'
+let g:easytags_version = '2.4.8'
" Configuration defaults and initialization. {{{1
@@ -24,18 +24,10 @@ if !exists('g:easytags_file')
endif
endif
-if !exists('g:easytags_dynamic_files')
- let g:easytags_dynamic_files = 0
-endif
-
if !exists('g:easytags_by_filetype')
let g:easytags_by_filetype = ''
endif
-if !exists('g:easytags_resolve_links')
- let g:easytags_resolve_links = 0
-endif
-
if !exists('g:easytags_events')
let g:easytags_events = []
if !exists('g:easytags_on_cursorhold') || g:easytags_on_cursorhold
@@ -50,18 +42,6 @@ if !exists('g:easytags_ignored_filetypes')
let g:easytags_ignored_filetypes = '^tex$'
endif
-if !exists('g:easytags_autorecurse')
- let g:easytags_autorecurse = 0
-endif
-
-if !exists('g:easytags_include_members')
- let g:easytags_include_members = 0
-endif
-
-if !exists('g:easytags_python_enabled')
- let g:easytags_python_enabled = 1
-endif
-
if !exists('g:easytags_python_script')
let g:easytags_python_script = expand('<sfile>:p:h') . '/../misc/easytags/highlight.py'
endif