blob: 6bbde346ea2011bb2131040c7c1d34338cf08745 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
let s:done = {}
function! spectral#highlight#highlight() abort
%s/#[a-fA-F0-9]\{6}/\=spectral#highlight#highlightOne(submatch(0))/g
endfunction
function! spectral#highlight#highlightLine() abort
let curpos = getcurpos()
silent! '[,']s/#[a-fA-F0-9]\{6}/\=spectral#highlight#highlightOne(submatch(0))/g
call cursor(curpos[1:])
endfunction
function! spectral#highlight#highlightOne(match) abort
let match = a:match
let nohash = match[1:]
if has_key(s:done, match)
return a:match
else
let s:done[match] = 1
endif
exec printf("syn match %s +%s+ containedIn=vimComment,vim9Comment,vimString,vimIsCommand,vimHiGuiRgb", nohash, match)
exec printf("hi %s guifg=#000000 guibg=%s", nohash, match)
" Return exactly what was put in. We only care about the side effets.
return a:match
endfunction
function! spectral#highlight#clearCache() abort
let s:done = {}
call spectral#highlight#highlight()
endfunction
|