在vim中用clojure的注释宏突出显示一个表单

时间:2017-09-06 11:07:28

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

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

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

将注释掉上面的列表,符号和地图。和Emacs一样,我希望并希望表单能够获得评论的语法高亮

在vim中,没有用于注释掉表单的默认语法高亮显示。我也没有找到任何插件来做到这一点。有没有人试图配置这个?感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

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

在解决此问题(上面链接)的问题中,@ guns在语法文件中添加了以下内容,以便突出显示注释:

" 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,并且注释和REPL集成都可以正常工作,但我相信你已经意识到这一点。