Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support scanning & highlighting of struct/class members

  • Loading branch information...
commit 2f73c57c857fc0a4f3bed718a90f0296890778a3 1 parent a536d77
@xolox authored
Showing with 46 additions and 6 deletions.
  1. +15 −1 README.md
  2. +25 −3 autoload.vim
  3. +6 −2 easytags.vim
View
16 README.md
@@ -38,7 +38,7 @@ Note that this command will be executed automatically every once in a while, ass
### 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.vim` 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.:
+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.vim` 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.:
:let g:easytags_cmd = '/usr/local/bin/ctags'
@@ -78,6 +78,20 @@ You have to explicitly enable this option because it should only be used while n
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 detail which I intend to fix.
+### The `g:easytags_include_members` option
+
+Exuberant Ctags knows how to generate tags for struct/class members in C++ and Java source code but doesn't do so by default because it can more than double the size of your tags files, thus taking much longer to read/write the tags file. When you enable the `g:easytags_include_members` option from your [vimrc script][vimrc] (before the `easytags.vim` plug-in is loaded):
+
+ :let g:easytags_include_members = 1
+
+Exuberant Ctags will be instructed to include struct/class members using the `--extra=+q` command line argument and the `easytags.vim` plug-in will highlight them using the `cMember` highlighting group. Because most color schemes don't distinguish the [Identifier and Type](http://vimdoc.sourceforge.net/htmldoc/syntax.html#group-name) highlighting groups all members will now probably look like type definitions. You can change that by executing any of the following Vim commands (from your vimrc script, a file type plug-in, etc.):
+
+ " If you like one of the existing styles you can link them:
+ highlight link cMember Special
+
+ " You can also define your own style if you want:
+ highlight cMember gui=italic
+
### The `g:easytags_resolve_links` option
UNIX has [symbolic links](http://en.wikipedia.org/wiki/Symbolic_link) and [hard links](http://en.wikipedia.org/wiki/Hard_link), both of which conflict with the concept of having one unique location for every identifier. With regards to hard links there's not much anyone can do, but because I use symbolic links quite a lot I've added this option. It's disabled by default since it has a small performance impact and might not do what unknowing users expect it to: When you enable this option the plug-in will resolve symbolic links in pathnames, which means your tags file will only contain entries with [canonical pathnames](http://en.wikipedia.org/wiki/Canonicalization). To enable this option (which I strongly suggest doing when you run UNIX and use symbolic links) execute the following Vim command:
View
28 autoload.vim
@@ -1,6 +1,6 @@
" Vim script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: August 10, 2010
+" Last Change: August 11, 2010
" URL: http://peterodding.com/code/vim/easytags/
let s:script = expand('<sfile>:p:~')
@@ -99,6 +99,10 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
call add(cmdline, '--sort=no')
call add(cmdline, '-f-')
endif
+ if g:easytags_include_members
+ call add(cmdline, '--extra=+q')
+ endif
+ let have_args = 0
if a:cfile != ''
if g:easytags_autorecurse
call add(cmdline, '-R')
@@ -108,14 +112,18 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
call add(cmdline, shellescape('--language-force=' . filetype))
call add(cmdline, shellescape(a:cfile))
endif
+ let have_args = 1
else
for fname in a:arguments
let matches = split(expand(fname), "\n")
- call extend(cmdline, map(matches, 'shellescape(v:val)'))
+ if !empty(matches)
+ call extend(cmdline, map(matches, 'shellescape(v:val)'))
+ let have_args = 1
+ endif
endfor
endif
" No need to run Exuberant Ctags without any filename arguments!
- return len(cmdline) > 4 ? join(cmdline) : ''
+ return have_args ? join(cmdline) : ''
endfunction
function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
@@ -476,6 +484,11 @@ call easytags#define_tagkind({
call easytags#define_tagkind({
\ 'filetype': 'c',
+ \ 'hlgroup': 'cEnum',
+ \ 'filter': 'get(v:val, "kind") ==# "e"'})
+
+call easytags#define_tagkind({
+ \ 'filetype': 'c',
\ 'hlgroup': 'cPreProc',
\ 'filter': 'get(v:val, "kind") ==# "d"'})
@@ -484,8 +497,17 @@ call easytags#define_tagkind({
\ 'hlgroup': 'cFunction',
\ 'filter': 'get(v:val, "kind") =~# "[fp]"'})
+highlight def link cEnum Identifier
highlight def link cFunction Function
+if g:easytags_include_members
+ call easytags#define_tagkind({
+ \ 'filetype': 'c',
+ \ 'hlgroup': 'cMember',
+ \ 'filter': 'get(v:val, "kind") ==# "m"'})
+ highlight def link cMember Identifier
+endif
+
" PHP. {{{2
call easytags#define_tagkind({
View
8 easytags.vim
@@ -1,10 +1,10 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: August 10, 2010
+" Last Change: August 11, 2010
" URL: http://peterodding.com/code/vim/easytags/
" Requires: Exuberant Ctags (http://ctags.sf.net)
" License: MIT
-" Version: 2.1
+" Version: 2.1.2
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
@@ -46,6 +46,10 @@ if !exists('g:easytags_autorecurse')
let g:easytags_autorecurse = 0
endif
+if !exists('g:easytags_include_members')
+ let g:easytags_include_members = 0
+endif
+
function! s:InitEasyTags(version)
" Check that the location of Exuberant Ctags has been configured or that the
" correct version of the program exists in one of its default locations.
Please sign in to comment.
Something went wrong with that request. Please try again.