【问题标题】:highlight a form with clojure's comment macro in vim在 vim 中使用 clojure 的注释宏突出显示表单
【发布时间】:2017-09-06 11:07:28
【问题描述】:

在 clojure 中,您可以使用 #_ 注释掉下一个表单。例如

#_(foo 2 3 4)
#_foo
#_{:a '(1 2 3) :b [1 2 3]}

将注释掉上面的列表、符号和地图。像 Emacs 一样,我希望 并希望表单能够突出显示注释的语法

在 vim 中,注释掉的表单没有默认的语法高亮。我也没有找到任何这样做的插件。有没有人尝试过配置这个?感谢您的帮助。

【问题讨论】:

  • 为什么不用分号评论呢?这对我来说适用于 Vim,甚至插件也支持它
  • 因为你不能在不破坏括号对称性的情况下用分号注释掉表单

标签: vim syntax clojure lisp vim-syntax-highlighting


【解决方案1】:

vim-clojure-static 插件未启用使用 #_ 表单进行注释,因为它禁用了已注释块的 REPL 集成(请参阅 https://github.com/guns/vim-clojure-static/issues/60)。

在解决这个问题的问题(上面链接)中,@guns 为语法文件提供了以下补充,以启用 cmets 的突出显示:

" WARNING: This code has the following KNOWN deficiencies: " " · Consecutive #_ macros are not matched correctly: " (list #_#_ 1 2 3) ;; => (3) " · Bracket character literals within #_ comment regions break syntax: " #_[\a \[ \] \b] ;; broken " · Compound forms preceded by reader metacharacters are unmatched: " #_'(α β γ) ;; broken " · Atomic forms preceded by reader metacharacters + whitespace are unmatched: " #_' foo ;; broken " syntax match clojureCommentAtom /\v#_[ \t\r\n]*[^()\[\]{} \t\r\n]+/ syntax region clojureCommentListContained start=/(/ end=/)/ contains=clojureCommentListContained,clojureCommentVectorContained,clojureCommentMapContained,clojureCommentStringContained contained syntax region clojureCommentVectorContained start=/\[/ end=/]/ contains=clojureCommentListContained,clojureCommentVectorContained,clojureCommentMapContained,clojureCommentStringContained contained syntax region clojureCommentMapContained start=/{/ end=/}/ contains=clojureCommentListContained,clojureCommentVectorContained,clojureCommentMapContained,clojureCommentStringContained contained syntax region clojureCommentStringContained start=/"/ skip=/\v\\\\|\\"/ end=/"/ contained syntax region clojureCommentList matchgroup=clojureCommentDelimiter start=/\v#_[ \t\r\n]*\(/ end=/)/ contains=clojureCommentListContained,clojureCommentVectorContained,clojureCommentMapContained,clojureCommentStringContained syntax region clojureCommentVector matchgroup=clojureCommentDelimiter start=/\v#_[ \t\r\n]*\[/ end=/]/ contains=clojureCommentListContained,clojureCommentVectorContained,clojureCommentMapContained,clojureCommentStringContained syntax region clojureCommentMap matchgroup=clojureCommentDelimiter start=/\v#_[ \t\r\n]*\{/ end=/}/ contains=clojureCommentListContained,clojureCommentVectorContained,clojureCommentMapContained,clojureCommentStringContained syntax region clojureCommentString matchgroup=clojureCommentDelimiter start=/\v#_[ \t\r\n]*"/ skip=/\v\\\\|\\"/ end=/"/ highlight link clojureCommentDelimiter clojureComment highlight link clojureCommentAtom clojureComment highlight link clojureCommentListContained clojureComment highlight link clojureCommentVectorContained clojureComment highlight link clojureCommentMapContained clojureComment highlight link clojureCommentStringContained clojureComment highlight link clojureCommentList clojureComment highlight link clojureCommentVector clojureComment highlight link clojureCommentMap clojureComment highlight link clojureCommentString clojureComment

我个人使用Spacemacs(包含 Vim 绑定和电池的 Emacs)和 Clojure layer,并且 cmets 和 REPL 集成都可以正常工作,但我相信您已经意识到这一点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 2011-03-10
    • 2012-05-15
    • 2014-06-14
    • 2011-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多