@@ -2,32 +2,26 @@ if filereadable($VIMRUNTIME . '/syntax/markdown.vim')
22 source $VIMRUNTIME /syntax/ markdown.vim
33endif
44
5- syntax match Date " \v\d +\s +\w +\s +ago"
6- highlight link Date GitlabDate
7-
8- execute ' syntax match Unresolved /\s' . g: gitlab_discussion_tree_unresolved . ' \s\?/'
9- highlight link Unresolved GitlabUnresolved
10-
11- execute ' syntax match Unlinked /\s' . g: gitlab_discussion_tree_unlinked . ' \s\?/'
12- highlight link Unlinked GitlabUnlinked
13-
14- execute ' syntax match Resolved /\s' . g: gitlab_discussion_tree_resolved . ' \s\?/'
15- highlight link Resolved GitlabResolved
16-
17- execute ' syntax match GitlabDiscussionOpen /^\s*' . g: gitlab_discussion_tree_expander_open . ' /'
18- highlight link GitlabDiscussionOpen GitlabExpander
19-
20- execute ' syntax match GitlabDiscussionClosed /^\s*' . g: gitlab_discussion_tree_expander_closed . ' /'
21- highlight link GitlabDiscussionClosed GitlabExpander
22-
23- execute ' syntax match Draft /' . g: gitlab_discussion_tree_draft . ' /'
24- highlight link Draft GitlabDraft
25-
26- execute ' syntax match Username "@[a-zA-Z0-9.]\+"'
27- highlight link Username GitlabUsername
28-
29- execute ' syntax match Mention "\%(' . g: gitlab_discussion_tree_expander_open . ' \|'
30- \ . g: gitlab_discussion_tree_expander_closed . ' \)\@<!@[a-zA-Z0-9.]*"'
31- highlight link Mention GitlabMention
5+ let expanders = ' ^\s*\%(' . g: gitlab_discussion_tree_expander_open . ' \|' . g: gitlab_discussion_tree_expander_closed . ' \)'
6+ let username = ' @[a-zA-Z0-9.]\+'
7+
8+ " Covers times like '14 days ago', 'just now', as well as 'October 3, 2024'
9+ let time_ago = ' \d\+ \w\+ ago'
10+ let formatted_date = ' \w\+ \{1,2}\d\{1,2}, \d\{4}'
11+ let date = ' \%(' . time_ago . ' \|' . formatted_date . ' \|just now\)'
12+
13+ let published = date . ' \%(' . g: gitlab_discussion_tree_resolved . ' \|' . g: gitlab_discussion_tree_unresolved . ' \|' . g: gitlab_discussion_tree_unlinked . ' \)\?'
14+ let state = ' \%(' . published . ' \|' . g: gitlab_discussion_tree_draft . ' \)'
15+
16+ execute ' syntax match GitlabNoteHeader "' . expanders . username . state . ' " contains=GitlabDate,GitlabUnresolved,GitlabUnlinked,GitlabResolved,GitlabExpander,GitlabDraft,GitlabUsername'
17+
18+ execute ' syntax match GitlabDate "' . date . ' " contained'
19+ execute ' syntax match GitlabUnresolved "' . g: gitlab_discussion_tree_unresolved . ' " contained'
20+ execute ' syntax match GitlabUnlinked "' . g: gitlab_discussion_tree_unlinked . ' " contained'
21+ execute ' syntax match GitlabResolved "' . g: gitlab_discussion_tree_resolved . ' " contained'
22+ execute ' syntax match GitlabExpander "' . expanders . ' " contained'
23+ execute ' syntax match GitlabDraft "' . g: gitlab_discussion_tree_draft . ' " contained'
24+ execute ' syntax match GitlabUsername "' . username . ' " contained'
25+ execute ' syntax match GitlabMention "' . username . ' "'
3226
3327let b: current_syntax = ' gitlab'
0 commit comments