Skip to content

Commit 24e6c3f

Browse files
sch0125justinmk
authored andcommitted
label-mode: disable third-party conceal chars #244
save/restore Conceal match syntax groups from other plugins. fix #245
1 parent 27cc3ce commit 24e6c3f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

autoload/sneak/label.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ let g:sneak#target_labels = get(g:, 'sneak#target_labels', ";sftunq/SFGHLTUNRMQZ
1010
let s:clear_syntax = !has('patch-7.4.792')
1111
let s:matchmap = {}
1212
let s:match_ids = []
13+
let s:orig_conceal_matches = []
1314

1415
func! s:placematch(c, pos) abort
1516
let s:matchmap[a:c] = a:pos
@@ -22,6 +23,25 @@ func! s:placematch(c, pos) abort
2223
endif
2324
endf
2425

26+
func! s:save_conceal_matches() abort
27+
for m in getmatches()
28+
if m.group ==# 'Conceal'
29+
call add(s:orig_conceal_matches, m)
30+
silent! call matchdelete(m.id)
31+
endif
32+
endfor
33+
endf
34+
35+
func! s:restore_conceal_matches() abort
36+
for m in s:orig_conceal_matches
37+
let d = {}
38+
if has_key(m, 'conceal') | let d.conceal = m.conceal | endif
39+
if has_key(m, 'window') | let d.window = m.window | endif
40+
silent! call matchadd(m.group, m.pattern, m.priority, m.id, d)
41+
endfor
42+
let s:orig_conceal_matches = []
43+
endf
44+
2545
func! sneak#label#to(s, v, label) abort
2646
let seq = ""
2747
while 1
@@ -101,6 +121,7 @@ func! s:after() abort
101121
let s:match_ids = []
102122
"remove temporary highlight links
103123
exec 'hi! link Conceal '.s:orig_hl_conceal
124+
call s:restore_conceal_matches()
104125
exec 'hi! link Sneak '.s:orig_hl_sneak
105126

106127
if s:clear_syntax
@@ -161,6 +182,7 @@ func! s:before() abort
161182
endif
162183

163184
let s:orig_hl_conceal = sneak#util#links_to('Conceal')
185+
call s:save_conceal_matches()
164186
let s:orig_hl_sneak = sneak#util#links_to('Sneak')
165187
"set temporary link to our custom 'conceal' highlight
166188
hi! link Conceal SneakLabel

0 commit comments

Comments
 (0)