wlangstroth / vim-racket

vim bundle for Racket
MIT License
234 stars 60 forks source link

Add support for s-expression comments #36

Open cwfoo opened 6 years ago

cwfoo commented 6 years ago

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.

c42f commented 4 years ago

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
cwfoo commented 3 years ago

@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 commented 3 years ago

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