Skip to content
This repository
Browse code

Support scanning & highlighting of struct/class members

  • Loading branch information...
commit 2f73c57c857fc0a4f3bed718a90f0296890778a3 1 parent a536d77
Peter Odding authored August 11, 2010
16  README.md
Source Rendered
@@ -38,7 +38,7 @@ Note that this command will be executed automatically every once in a while, ass
38 38
 
39 39
 ### The `g:easytags_cmd` option
40 40
 
41  
-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.:
  41
+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.:
42 42
 
43 43
     :let g:easytags_cmd = '/usr/local/bin/ctags'
44 44
 
@@ -78,6 +78,20 @@ You have to explicitly enable this option because it should only be used while n
78 78
 
79 79
 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.
80 80
 
  81
+### The `g:easytags_include_members` option
  82
+
  83
+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):
  84
+
  85
+    :let g:easytags_include_members = 1
  86
+
  87
+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.):
  88
+
  89
+    " If you like one of the existing styles you can link them:
  90
+    highlight link cMember Special
  91
+
  92
+    " You can also define your own style if you want:
  93
+    highlight cMember gui=italic
  94
+
81 95
 ### The `g:easytags_resolve_links` option
82 96
 
83 97
 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:
28  autoload.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: August 10, 2010
  3
+" Last Change: August 11, 2010
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 
6 6
 let s:script = expand('<sfile>:p:~')
@@ -99,6 +99,10 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
99 99
     call add(cmdline, '--sort=no')
100 100
     call add(cmdline, '-f-')
101 101
   endif
  102
+  if g:easytags_include_members
  103
+    call add(cmdline, '--extra=+q')
  104
+  endif
  105
+  let have_args = 0
102 106
   if a:cfile != ''
103 107
     if g:easytags_autorecurse
104 108
       call add(cmdline, '-R')
@@ -108,14 +112,18 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
108 112
       call add(cmdline, shellescape('--language-force=' . filetype))
109 113
       call add(cmdline, shellescape(a:cfile))
110 114
     endif
  115
+    let have_args = 1
111 116
   else
112 117
     for fname in a:arguments
113 118
       let matches = split(expand(fname), "\n")
114  
-      call extend(cmdline, map(matches, 'shellescape(v:val)'))
  119
+      if !empty(matches)
  120
+        call extend(cmdline, map(matches, 'shellescape(v:val)'))
  121
+        let have_args = 1
  122
+      endif
115 123
     endfor
116 124
   endif
117 125
   " No need to run Exuberant Ctags without any filename arguments!
118  
-  return len(cmdline) > 4 ? join(cmdline) : ''
  126
+  return have_args ? join(cmdline) : ''
119 127
 endfunction
120 128
 
121 129
 function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
@@ -476,6 +484,11 @@ call easytags#define_tagkind({
476 484
 
477 485
 call easytags#define_tagkind({
478 486
       \ 'filetype': 'c',
  487
+      \ 'hlgroup': 'cEnum',
  488
+      \ 'filter': 'get(v:val, "kind") ==# "e"'})
  489
+
  490
+call easytags#define_tagkind({
  491
+      \ 'filetype': 'c',
479 492
       \ 'hlgroup': 'cPreProc',
480 493
       \ 'filter': 'get(v:val, "kind") ==# "d"'})
481 494
 
@@ -484,8 +497,17 @@ call easytags#define_tagkind({
484 497
       \ 'hlgroup': 'cFunction',
485 498
       \ 'filter': 'get(v:val, "kind") =~# "[fp]"'})
486 499
 
  500
+highlight def link cEnum Identifier
487 501
 highlight def link cFunction Function
488 502
 
  503
+if g:easytags_include_members
  504
+  call easytags#define_tagkind({
  505
+        \ 'filetype': 'c',
  506
+        \ 'hlgroup': 'cMember',
  507
+        \ 'filter': 'get(v:val, "kind") ==# "m"'})
  508
+ highlight def link cMember Identifier
  509
+endif
  510
+
489 511
 " PHP. {{{2
490 512
 
491 513
 call easytags#define_tagkind({
8  easytags.vim
... ...
@@ -1,10 +1,10 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: August 10, 2010
  3
+" Last Change: August 11, 2010
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 " Requires: Exuberant Ctags (http://ctags.sf.net)
6 6
 " License: MIT
7  
-" Version: 2.1
  7
+" Version: 2.1.2
8 8
 
9 9
 " Support for automatic update using the GLVS plug-in.
10 10
 " GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
@@ -46,6 +46,10 @@ if !exists('g:easytags_autorecurse')
46 46
   let g:easytags_autorecurse = 0
47 47
 endif
48 48
 
  49
+if !exists('g:easytags_include_members')
  50
+  let g:easytags_include_members = 0
  51
+endif
  52
+
49 53
 function! s:InitEasyTags(version)
50 54
   " Check that the location of Exuberant Ctags has been configured or that the
51 55
   " correct version of the program exists in one of its default locations.

0 notes on commit 2f73c57

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