vim-racket icon indicating copy to clipboard operation
vim-racket copied to clipboard

Add support for s-expression comments

Open cwfoo opened this issue 7 years ago • 3 comments
trafficstars

Add support for s-expression comments. For example:

#;(define (double x)
  (* 2 x))

Currently, the second line is highlighted as code. It should be highlighted as a comment.

cwfoo avatar Sep 17 '18 21:09 cwfoo

Something like the following seems to do it:

    syn region racketData start=/(/ end=/)/ contained transparent contains=racketData
    syn region racketSExpressionComment matchgroup=racketSExpressionComment start=/#;(/ end=/)/ contains=racketData
    syn cluster racketNormal  add=racketSExpressionComment
    syn cluster racketQuotedOrNormal  add=racketSExpressionComment
    hi def link racketSExpressionComment Comment

c42f avatar Mar 23 '20 07:03 c42f

@c42f Your proposed solution does not handle this case:

(/ 6 #;0 2)

The 2) part will be incorrectly highlighted as a comment.

Refer to SRFI 62: S-expression comments for more examples.

cwfoo avatar Mar 27 '21 13:03 cwfoo

A solution already exists in Vim's Scheme syntax file:

https://github.com/vim/vim/blob/v8.2.2663/runtime/syntax/scheme.vim#L70-L74

cwfoo avatar Mar 27 '21 14:03 cwfoo