aboutsummaryrefslogtreecommitdiff
path: root/autoload/spectral
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2021-09-29 19:55:25 -0600
committerJosh Rahm <rahm@google.com>2021-09-29 19:56:38 -0600
commit5faff8446e23633612df91d37d081a598f556f49 (patch)
tree171ec5107656c742ee200e9575b3189dd344d57e /autoload/spectral
parent2ccaf8efc08d4609056fc6fb7a29740d4cfa93e6 (diff)
downloadspectral.vim-5faff8446e23633612df91d37d081a598f556f49.tar.gz
spectral.vim-5faff8446e23633612df91d37d081a598f556f49.tar.bz2
spectral.vim-5faff8446e23633612df91d37d081a598f556f49.zip
More features added to spcetral.
Ability to saturate/desaturate current colors. Highlighting for guicolors in the spectral/colors directory.
Diffstat (limited to 'autoload/spectral')
-rw-r--r--autoload/spectral/highlight.vim33
1 files changed, 33 insertions, 0 deletions
diff --git a/autoload/spectral/highlight.vim b/autoload/spectral/highlight.vim
new file mode 100644
index 0000000..6bbde34
--- /dev/null
+++ b/autoload/spectral/highlight.vim
@@ -0,0 +1,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