Skip to content

Commit e74c797

Browse files
committed
Add syntax for tags and sections
1 parent 340bbbc commit e74c797

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

plugin/cheatsheet.vim

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ command -bar -nargs=0 CheatSheetFloat lua require'cheatsheet'.show_cheats_float(
22
command -bar -nargs=0 CheatSheetTelescope lua require'cheatsheet.telescope'.pick_cheat()
33

44
highlight default link cheatComment Comment
5+
highlight default link cheatMetadataComment Comment
6+
highlight default link cheatMetadataTag Include
7+
highlight default link cheatMetadataSection Structure
8+
59
highlight default link cheatDescription String
610
highlight default link cheatSeparator Keyword
711
highlight default link cheatCode Statement

syntax/cheatsheet.vim

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,18 @@ let b:current_syntax = "cheatsheet"
77
syn clear
88
syn sync fromstart
99

10-
syn match cheatComment /#.*$/
10+
syn region cheatComment start=/\v#[^#]/ end=/$/ keepend
11+
12+
" ## plugin-name @tag @tag
13+
" ^^ ^^^^^^^^^^^ ^^^^
14+
" metadata-comment section tag
15+
syn match cheatMetadataSection /##\s\+\S\+/ms=s+2 skipwhite nextgroup=cheatMetadataTag contained
16+
syn match cheatMetadataTag /@\S\+/ contained
17+
syn region cheatMetadataComment start=/##/ end=/$/ keepend skipwhite contains=cheatMetadataSection,cheatMetadataTag
18+
19+
" Some useful text | :Command
20+
" ^^^^^^^^^^^^^^^^ ^ ^^^^^^^^
21+
" description separator cheatcode
1122
syn match cheatDescription /\v^[^\#][^|]*/ contained skipwhite nextgroup=cheatSeparator
1223
syn match cheatSeparator '|' nextgroup=cheatCode skipwhite contained
1324
syn match cheatCode '.*' contained

0 commit comments

Comments
 (0)