Vim taglist 插件未检测自定义语言 (racket)

发布于 2024-12-28 19:08:40 字数 2060 浏览 0 评论 0原文

我最近开始使用racket,我做的第一件事就是尝试获取vim TagList 插件 来使用它。然而,却丝毫没有作用。我可以打开球拍文件,并且 TagList 窗口将像打开文本文件一样空白。

根据 扩展页面* 我已将以下内容添加到我的 ~/.vimrc 文件中:

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'

额外的 ctags 内容也在我的 ~/.ctags 文件中,但 TList 吐出关于我的设置行没有任何好处的错误。我最初尝试使用 ctags 现有方案功能,但我没有得到同样的结果。为了使用现有的方案功能,我在 ~/.vimrc 中尝试了以下内容。

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

如果其他人对如何使其工作有任何想法,那么我将非常感激。

谢谢,

  • 我也会在一页上发布一个指向 ctags 的链接,但它不会让我(新用户)这样做。可以在扩展标签列表页面上找到它的链接。

编辑

来自命令行的ctags

我可以从命令行使用ctags。使用 TagList FAQ 页面上的 ctags 行进行测试,我得到以下结果:

 $ 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

如果我使用开关强制语言定义,或者将语言更改为方案,则输出是相同的。

关于 TagBar

在人们建议之前我还没有见过 TagBar。有趣的是,它只适用于我的 .ctags 文件的更改。不幸的是,我还没有找到像 TagList 那样显示所有加载缓冲区中标签的设置,所以我更喜欢使用 TagList。

我会发布比较图像,但我认为它不会让我作为新成员。根据romainl的建议,我可以将vim文件类型设置为scheme,并且它确实有效。然而,当根据扩展页面的文档似乎表明我所拥有的应该有效时,这似乎只是一个 80% 的解决方案。也许我应该考虑提交一份错误报告。

再次感谢,

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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

此岸叶落 2025-01-04 19:08:40

这是我从 官方文档 中提取的一个小球拍片段,并保存为 < code>tt.rkt:

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

如果没有球拍特定的语法/缩进文件,则无论 ft 设置为 racket (当然)还是什么都不显示(默认值),都不会显示任何内容)。如果我 :set ft=scheme,TagList 和 TagBarchecker 列为“函数”。

从左到右:文件、TagBar、TagList。

TagList 和 TagBar against aracket file

据我了解,“Racket”是某些 Scheme 衍生品的品牌重塑。如果它没有偏离标准太多,在 ~/.vimrc 中添加这一行可能会有所帮助:

autocmd BufRead,BufNewFile *.rkt set filetype=scheme

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
最佳男配角 2025-01-04 19:08:40

我一直在努力解决同样的问题,尽管对于 xslt 文件...我的解决方案是通过在 taglist.vim 中查找找到的,其中我添加了一行来

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

尝试搜索 Vim 代码的 s:tlist_def_ 部分,并且放入一些看起来合理的东西。 Tagbar 中也有类似的机制。我没有详细阅读代码,所以我不知道为什么它需要这个而不使用 cta 的输出

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文