Skip to content

Commit 8a252cc

Browse files
committed
fix: limit syntax highlighting to note header
1 parent 19cec83 commit 8a252cc

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

after/syntax/gitlab.vim

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ let time_ago = '\d\+ \w\+ ago'
1010
let formatted_date = '\w\+ \{1,2}\d\{1,2}, \d\{4}'
1111
let date = '\%(' . time_ago . '\|' . formatted_date . '\|just now\)'
1212

13-
execute 'syntax match GitlabDate "' . date . '"'
14-
execute 'syntax match GitlabUnresolved "\s' . g:gitlab_discussion_tree_unresolved . '\s\?"'
15-
execute 'syntax match GitlabUnlinked "\s' . g:gitlab_discussion_tree_unlinked . '\s\?"'
16-
execute 'syntax match GitlabResolved "\s' . g:gitlab_discussion_tree_resolved . '\s\?"'
17-
execute 'syntax match GitlabExpander "' . expanders . '"'
18-
execute 'syntax match GitlabDraft "' . g:gitlab_discussion_tree_draft . '"'
19-
execute 'syntax match GitlabUsername "' . username . '"'
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 "\s' . g:gitlab_discussion_tree_unresolved . '\s\?" contained'
20+
execute 'syntax match GitlabUnlinked "\s' . g:gitlab_discussion_tree_unlinked . '\s\?" contained'
21+
execute 'syntax match GitlabResolved "\s' . g:gitlab_discussion_tree_resolved . '\s\?" 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'
2025
execute 'syntax match GitlabMention "\%(' . expanders . '\)\@<!' . username . '"'
2126

2227
let b:current_syntax = 'gitlab'

0 commit comments

Comments
 (0)