Skip to content

Commit 7a72aba

Browse files
Improve markup highlight.
1 parent 3459528 commit 7a72aba

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

syntax/org.vim

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,23 @@ let s:conceal = luaeval('require("orgmode.config").org_hide_emphasis_markers')
1111
if s:conceal
1212
let s:concealends = ' concealends'
1313
endif
14-
exe 'syntax region org_bold matchgroup=org_bold_delimiter start="[^\*]\zs\*\|\*[^\*]\@=" end="\S\zs\*\|\*\S\@=" keepend oneline contains=@Spell' . s:concealends
15-
exe 'syntax region org_italic matchgroup=org_italic_delimiter start="\S\zs\/\|\/\S\@=" end="\S\zs\/\|\/\S\@=" keepend oneline contains=@Spell' . s:concealends
16-
exe 'syntax region org_underline matchgroup=org_underline_delimiter start="\S\zs_\|_\S\@=" end="\S\zs_\|_\S\@=" keepend oneline contains=@Spell' . s:concealends
17-
exe 'syntax region org_code matchgroup=org_code_delimiter start="\S\zs\~\|\~\S\@=" end="\S\zs\~\|\~\S\@=" keepend oneline contains=@Spell' . s:concealends
18-
exe 'syntax region org_verbatim matchgroup=org_verbatim_delimiter start="\S\zs=\|=\S\@=" end="\S\zs=\|=\S\@=" keepend oneline contains=@Spell' . s:concealends
19-
exe 'syntax region org_strike matchgroup=org_strike_delimiter start="\S\zs+\|+\S\@=" end="\S\zs+\|+\S\@=" keepend oneline contains=@Spell' . s:concealends
14+
15+
function s:markup_start(marker) abort
16+
let items = ['^', '\s', '(', '-', "'", '"', '{'] + [a:marker]
17+
return '#\('.join(items, '\|').'\)\zs'.a:marker.'#'
18+
endfunction
19+
20+
function s:markup_end(marker) abort
21+
let items = ['$', '\s', ')', '-', '\}', "'", '"', ':', ';', '!', '\\', '\[', ',', '\.', '?'] + [a:marker]
22+
return '#'.a:marker.'\ze\('.join(items, '\|').'\)#'
23+
endfunction
24+
25+
exe 'syntax region org_bold matchgroup=org_bold_delimiter start='.s:markup_start('\*').' end='.s:markup_end('\*').' keepend oneline contains=@Spell' . s:concealends
26+
exe 'syntax region org_italic matchgroup=org_italic_delimiter start='.s:markup_start('\/').' end='.s:markup_end('\/').' keepend oneline contains=@Spell' . s:concealends
27+
exe 'syntax region org_underline matchgroup=org_underline_delimiter start='.s:markup_start('_').' end='.s:markup_end('_').' keepend oneline contains=@Spell' . s:concealends
28+
exe 'syntax region org_code matchgroup=org_code_delimiter start='.s:markup_start('\~').' end='.s:markup_end('\~').' keepend oneline contains=@Spell' . s:concealends
29+
exe 'syntax region org_verbatim matchgroup=org_verbatim_delimiter start='.s:markup_start('=').' end='.s:markup_end('=').' keepend oneline contains=@Spell' . s:concealends
30+
exe 'syntax region org_strike matchgroup=org_strike_delimiter start='.s:markup_start('+').' end='.s:markup_end('+').' keepend oneline contains=@Spell' . s:concealends
2031

2132
hi link org_bold_delimiter org_bold
2233
hi link org_italic_delimiter org_italic

0 commit comments

Comments
 (0)