Normally, Sorbet signatures are syntax highlighted as normal Ruby:
然而,我想在视觉上淡化嘈杂的签名,也许可以通过将它们突出显示为 comments .
以下是~/.vim/after/syntax/ruby.vim
的部分内容:
" adapted from: https://github.com/zackhsi/sorbet.vim/blob/master/syntax/ruby.vim
syntax region SigBlock matchgroup=SigBlockDelimiter start="{" end="}" contained transparent
syntax region SigBlock matchgroup=SigBlockDelimiter start="\<do\>" end="\<end\>" contained transparent
" Prevent sorbet elements from being contained by vim-ruby elements.
syntax cluster rubyNotTop add=SigBlock
syntax match Sig "\<sig\>" nextgroup=SigBlock skipwhite
" hi def link SigBlockDelimiter rubyDefine
" Match vim-ruby:
" https://github.com/vim-ruby/vim-ruby/commit/19c19a54583c3e7c07dce18b844ae104695c41d7.
syntax match rubyMagicComment "\c\%<10l#\s*\zs\%(typed\):" contained nextgroup=rubyBoolean skipwhite
" de-emphasize Sorbet sig
highlight default link Sig Comment
highlight default link SigBlockDelimiter Comment
如何获取签名块内部的代码也突出显示为Comment
?
作为参考,我使用sheerun/vim-polyglot
(即vim-ruby/vim-ruby
)和nanotech/jellybeans.vim
.此外,更理想的是保留 colored颜色 ,但只是"降低对比度",这是VSCode的byesig扩展,但这可能需要定义很多新 colored颜色 和语法规则?