- The VimClojure plugin, for syntax highlighting.
- The TagList plugin. Very useful plugin which shows the content of tags files.
- Exuberant Ctags, used by the TagList plugin.
VimClojure plugin
The installation is straight forward, and is fully explained in a readme file in the archive. The following settings has to added in your .vimrc (_vimrc) :syntax on filetype plugin indent onI've also added the following two settings:
let vimclojure#HighlightBuiltins=1 let vimclojure#ParenRainbow=1The rainbow parenthesis might be distracting, but I quite like it this way.
I'm leaving the plugin in offline mode, so I didn't configure the Nailgun server. This allows to use nice features like dynamic documentation lookup and Repl running in a Vim buffer, but I'll configure that when I get more familiar with Clojure. For the moment, I use Repl in another window and load the file I'm editing using (load "filename").
(UPDATE: the explanations for configuring the Nailgun client and server are here)
Exuberant Ctags
Nothing more than downloading the latest archive, extracting it, and setting the directory where the ctags executable is into the path.
TagList plugin
One problem: the taglist plugin relies on the filetype detected by Vim and passes the filetype to the exuberant ctags utility to parse the tags. With the VimClojure plugin on, the filetype is set to "clojure", which is not recognized by the taglist plugin. In order to tell the plugin to use the Lisp syntax, the following line should be added to the .vimrc (_vimrc) file :let tlist_clojure_settings = 'lisp;f:function'A useful setting is "let Tlist_Exit_OnlyWindow=1", which will close the TagList window if the last file was closed.
In Vim, the ":Tlist" command shows the tag list in a new window.
That's it. With a couple of plugins, using Clojure in Vim becomes much more fun.To generate the help documentation of both plugins, just type ":helptags ~/vimfiles/doc"(or another path where the docs are) in Vim. Take some time to go through the help and check useful settings can be used.
Using Exuberant Ctags on the command line with Clojure files
The following steps are not necessary in order to use the TagList plugin. It should be done only if you want to generate the tags file for Clojure files from the command line.I downloaded the latest version (5.8). Unfortunately, Clojure is not supported yet. But lisp is. Exuberant Ctags autodetects a file type by looking at its file extension. We can for it to use a different language by using the --language-force option (--language-force=lisp), but it's annoying to do it all the time. What can we do then ? It is possible to override the file mappings via the --langmap option. Let's see how it's done:
Check the supported languages
ctags --list-languages Ant Asm Asp Awk Basic BETA C C++ C# Cobol DosBatch ...Clojure is not there.
Check the file mappings
ctags --list-maps ... Lisp *.cl *.clisp *.el *.l *.lisp *.lsp ...The extension above are associated to Lisp.
Adding Clojure file extensions to the Lisp mapping
New extensions can be added via the --langmap option:ctags --langmap=lisp:+.clj --list-maps ... Lisp *.cl *.clisp *.el *.l *.lisp *.lsp *.clj ...To set it permanently, we have to set this option in the CTAGS environment variable (e.g. set CTAGS=--langmap=lisp:+.clj), or in one of the setting files used by Exuberant Tags (e.g. $HOME/.ctags)
After everything was set, looking at a tags file generated by "ctags *.clj" will confirm that the Clojure extension is properly recognized.
Great tip!
ReplyDeleteThanks for this, worked great for me.
ReplyDeleteThanks and that i have a nifty give: Where To Start With Whole House Renovation home depot renovation services
ReplyDelete