Vim tagslist plugin not detecting custom language (racket)

1k views Asked by At

I've recently started using racket, and one of the first things I've done has been to try and get the vim TagList plugin to work with it. However, it doesn't work in the slightest. I can open racket files and the TagList window will be as blank as if I had opened a text file.

According to the extending page* I have added the following to my ~/.vimrc file:

let Tlist_Ctags_Cmd = 'ctags --langdef=racket --langmap=racket:.rkt --regex-racket=/^\(def[a-zA-Z0-9\-_\?\/\\]+[ \t]+([a-zA-Z0-9\-_\/\\\?]+)/\1/d,definition/'
let Tlist_racket_settings = 'racket;d:Definition'

The extra ctags stuff is also in my ~/.ctags file, but TList was spitting out errors about my setting line not being any good. I did original try to use ctags existing scheme functionality, but I had the same nothing results. To use the existing scheme functionality, i tried the following in my ~/.vimrc

let Tlist_Ctags_Cmd = 'ctags --langmap=scheme:.rkt'
let Tlist_racket_settings = 'racket;f:Functions'

If anyone else has any ideas on how to get it working, then I would be extremely grateful.

Thanks,

  • I'd post a link to the ctags one page as well, but it wont let me (new user). A link to it can be found on the extending taglist page.

EDIT

ctags from the command line

I can use ctags from the command line. Testing with the ctags line on the TagList FAQ page I get the following:

 $ cat ~/.ctags
--langdef=racket
--langmap=racket:.rkt
--regex-racket=/^\(def[a-zA-Z0-9\-_\?\/\\]+[ \t]+([a-zA-Z0-9\-_\/\\\?]+)/\1/d,definition/
--regex-racket=/^\(define\-syntax(\-rule)?[ \t]+([a-zA-Z0-9\-_\/\\\?]+)/\2/m,macro/
--regex-racket=/^\(define?[ \t]+(([a-zA-Z0-9\-_\/\\\?]+)[ \t]+\(lambda|\(([a-zA-Z0-9\-_\/\\\?]+))/\2\3/f,function/
$ ctags  -f - --format=2 --excmd=pattern --fields=nks XMMSClient.rkt 
defenum XMMSClient.rkt  /^(define-syntax defenum$/;"    m   line:11
defxmmsc    XMMSClient.rkt  /^(define-syntax defxmmsc$/;"   m   line:20
libxmmsclient   XMMSClient.rkt  /^(define libxmmsclient (ffi-lib "libxmmsclient"))$/;"  d   line:5

Output is the same if I force the language definition with switches, or if I change the language to scheme.

About TagBar

I had not seen TagBar before people had suggested it. Interestingly enough, it just worked with the changes to my .ctags file. Unfortunately, I've not found a setting for showing the tags from all loaded buffers the way TagList does, so I would prefer to use TagList.

I'd post comparison images, but I don't think its going to let me, as a new member. As per romainl's suggestion, I can set the vim filetype to scheme, and it does work. This however only seems like an 80% solution, when the documentation according to the extending pages seems to suggest that what I have should work. Perhaps I should be looking at filing a bug report.

Thanks again,

2

There are 2 answers

2
romainl On

Here is a small racket snippet I lifted from the official documentation and saved as tt.rkt:

(define (checker p1 p2)
  (let ([p12 (hc-append p1 p2)]
        [p21 (hc-append p2 p1)])
    (vc-append p12 p21)))

Without racket-specific syntax/indent files nothing is shown whether ft is set to racket (of course) or nothing (the default). If I :set ft=scheme, both TagList and TagBar list checker as "function".

From left to right: the file, TagBar, TagList.

TagList and TagBar against a racket file

From what I understand, "Racket" is a rebranding of some Scheme derivative. If it doesn't deviate too much from the norm, adding this line in your ~/.vimrc may help:

autocmd BufRead,BufNewFile *.rkt set filetype=scheme
1
Goody On

I've been struggling with the same issue, though for xslt files... My solution was found by poking around in taglist.vim, whereby I added a line for

let s:tlist_def_xslt_settings = 'xslt;f:function:v:variable'

try doing a search for the s:tlist_def_ parts of the Vim code and put in something which looks sensible. There's a similar mechanism within Tagbar. I've not read the code through in detail, so I don't know why it would need this and not use the output from cta