Clojure & Vim & Ctags (oh my!)

511 views
Skip to first unread message

Alan Thompson

unread,
Sep 4, 2014, 2:42:01 PM9/4/14
to clo...@googlegroups.com
Hi,

I've been using Clojure & Vim for a year now, with fireplace, etc.  However, it seems that Exuberant Ctags is a bit crippled since I have not found a way to make it understand namespace aliases. In my current work it seems that nearly every function is in a separate namespace with a namespace alias.  

Unless there is already a tool (or a ~/.ctags regex) to do that, I was thinking about writing a lein plugin (in clojure) to decode namespace aliases in the (ns...) form and create a tags file from scratch. About a year ago (in a previous job), I had to write a similar tool (in Groovy) to create the tags file for PL/I code, so I'm familiar with the ctags file format.

Any thoughts?

Alan

P.S.  I have been experimenting with LightTable but GVim is still my day-to-day workhorse.

Jason Felice

unread,
Sep 4, 2014, 2:52:56 PM9/4/14
to clo...@googlegroups.com
Is using tools.analyzer.jvm overkill?  Do you want to capture pre-macro-expansion, post-marco-expanion, both?


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alan Thompson

unread,
Sep 4, 2014, 3:13:36 PM9/4/14
to clo...@googlegroups.com
Nothing that fancy.  Just trying to make ctags understand namespaces & namespace aliases.  Vim/Ctags works fine for non-namspaced function references, like:

(parseLong  "5")

However, the following won't work:

(ns demo
  (:require [mylib.parse :as parse]))

  (parse/parseLong        "5")  ; fail "parse/parseLong" tag not found
  (mylib.parse/parseLong  "5")  ; fail "mylib.parse/parseLong" tag not found

The problem is that the entire namespace part of a reference (either aliased or nor) is not recognized by ctags.  Since ctags does not know anything about clojure namespaces, it thinks the whole thing is the function name, not just the part after the "/" character.
Alan

Gary Verhaegen

unread,
Sep 4, 2014, 6:48:51 PM9/4/14
to clo...@googlegroups.com
Not sure what you're trying to get from ctags, but fireplace itself gives you some ability to jump around: gf on an external symbol will jump to that symbol's definition.

Alan Thompson

unread,
Sep 5, 2014, 2:47:39 PM9/5/14
to clo...@googlegroups.com
Thanks for the 'gf' reference.  I can't seem to find a way to go back, though (like popping the tag stack with crtl-T).
Alan

Dave Ray

unread,
Sep 5, 2014, 3:25:05 PM9/5/14
to clo...@googlegroups.com
ctrl-o will take you back to your previous position after gf. At least it does for me.

Dave

Alan Thompson

unread,
Sep 5, 2014, 3:36:48 PM9/5/14
to clo...@googlegroups.com
Ah!  Thank you!
Alan
Reply all
Reply to author
Forward
0 new messages