Skip to content
This repository
Browse code

Dynamic highlighting for Ruby source code (issue #9)

  • Loading branch information...
commit 45e97ff1f9d0ca2201e704910d58247afa5ca9d6 1 parent f980d5d
Peter Odding authored May 23, 2011
3  README.md
Source Rendered
@@ -10,7 +10,7 @@ There's just one problem: You have to manually keep your tags files up-to-date a
10 10
 
11 11
 Unzip the most recent [ZIP archive](http://peterodding.com/code/vim/downloads/easytags.zip) file inside your Vim profile directory (usually this is `~/.vim` on UNIX and `%USERPROFILE%\vimfiles` on Windows), restart Vim and execute the command `:helptags ~/.vim/doc` (use `:helptags ~\vimfiles\doc` instead on Windows). Now try it out: Edit any file type supported by Exuberant Ctags and within ten seconds the plug-in should create/update your tags file (`~/.vimtags` on UNIX, `~/_vimtags` on Windows) with the tags defined in the file you just edited! This means that whatever file you're editing in Vim (as long as it's on the local file system), tags will always be available by the time you need them!
12 12
 
13  
-Additionally if the file you just opened is a C, C++, Objective-C, Java, Lua, Python, PHP or Vim source file you should also notice that the function and type names defined in the file have been syntax highlighted.
  13
+Additionally if the file you just opened is a C, C++, Objective-C, Java, Lua, Python, PHP, Ruby or Vim source file you should also notice that the function and type names defined in the file have been syntax highlighted.
14 14
 
15 15
 The `easytags.vim` plug-in is intended to work automatically once it's installed, but if you want to change how it works there are several options you can change and commands you can execute from your own mappings and/or automatic commands. These are all documented below.
16 16
 
@@ -127,6 +127,7 @@ The easytags plug-in defines new highlighting groups for dynamically highlighted
127 127
  * **Python:** `pythonFunctionTag`, `pythonMethodTag`, `pythonClassTag`
128 128
  * **Java:** `javaClassTag`, `javaMethodTag`
129 129
  * **C#:** `csClassOrStructTag`, `csMethodTag`
  130
+ * **Ruby:** `rubyModuleNameTag`, `rubyClassNameTag`, `rubyMethodNameTag`
130 131
 
131 132
 As you can see each of these names ends in `Tag` to avoid conflicts with the syntax modes shipped with Vim. And about the singular/plural confusion: I've tried to match the existing highlighting groups defined by popular syntax modes (except of course for the `Tag` suffix).
132 133
 
23  autoload/xolox/easytags.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: May 6, 2011
  3
+" Last Change: May 23, 2011
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 
6 6
 let s:script = expand('<sfile>:p:~')
@@ -628,6 +628,27 @@ call xolox#easytags#define_tagkind({
628 628
 highlight def link csClass Identifier
629 629
 highlight def link csMethod Function
630 630
 
  631
+" Ruby. {{{2
  632
+
  633
+call xolox#easytags#define_tagkind({
  634
+      \ 'filetype': 'ruby',
  635
+      \ 'hlgroup': 'rubyModuleName',
  636
+      \ 'filter': 'get(v:val, "kind") ==# "m"'})
  637
+
  638
+call xolox#easytags#define_tagkind({
  639
+      \ 'filetype': 'ruby',
  640
+      \ 'hlgroup': 'rubyClassName',
  641
+      \ 'filter': 'get(v:val, "kind") ==# "c"'})
  642
+
  643
+call xolox#easytags#define_tagkind({
  644
+      \ 'filetype': 'ruby',
  645
+      \ 'hlgroup': 'rubyMethodName',
  646
+      \ 'filter': 'get(v:val, "kind") =~# "[fF]"'})
  647
+
  648
+highlight def link rubyModuleName Type
  649
+highlight def link rubyClassName Type
  650
+highlight def link rubyMethodName Function
  651
+
631 652
 " }}}
632 653
 
633 654
 " Restore "cpoptions".
6  doc/easytags.txt
@@ -36,8 +36,8 @@ file you're editing in Vim (as long as it's on the local file system), tags
36 36
 will always be available by the time you need them!
37 37
 
38 38
 Additionally if the file you just opened is a C, C++, Objective-C, Java, Lua,
39  
-Python, PHP or Vim source file you should also notice that the function and
40  
-type names defined in the file have been syntax highlighted.
  39
+Python, PHP, Ruby or Vim source file you should also notice that the function
  40
+and type names defined in the file have been syntax highlighted.
41 41
 
42 42
 The 'easytags.vim' plug-in is intended to work automatically once it's
43 43
 installed, but if you want to change how it works there are several options
@@ -269,6 +269,8 @@ by the easytags plug-in:
269 269
 
270 270
  - C#: 'csClassOrStructTag', 'csMethodTag'
271 271
 
  272
+ - Ruby: 'rubyModuleNameTag', 'rubyClassNameTag', 'rubyMethodNameTag'
  273
+
272 274
 As you can see each of these names ends in 'Tag' to avoid conflicts with the
273 275
 syntax modes shipped with Vim. And about the singular/plural confusion: I've
274 276
 tried to match the existing highlighting groups defined by popular syntax
4  plugin/easytags.vim
... ...
@@ -1,10 +1,10 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: May 2, 2011
  3
+" Last Change: May 23, 2011
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.2.7
  7
+" Version: 2.2.8
8 8
 
9 9
 " Support for automatic update using the GLVS plug-in.
10 10
 " GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip

0 notes on commit 45e97ff

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