diff options
author | Josh Rahm <rahm@google.com> | 2021-09-29 19:55:25 -0600 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2021-09-29 19:56:38 -0600 |
commit | 5faff8446e23633612df91d37d081a598f556f49 (patch) | |
tree | 171ec5107656c742ee200e9575b3189dd344d57e /autoload/spectral.vim | |
parent | 2ccaf8efc08d4609056fc6fb7a29740d4cfa93e6 (diff) | |
download | spectral.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.vim')
-rw-r--r-- | autoload/spectral.vim | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/autoload/spectral.vim b/autoload/spectral.vim index fe70131..d7e3110 100644 --- a/autoload/spectral.vim +++ b/autoload/spectral.vim @@ -50,7 +50,28 @@ function! spectral#desaturate(color, amount) return spectral#toColor(nr, ng, nb) endfunction -function! spectral#set_saturation(color, amount) +function! spectral#getSaturation(color) + let saved = 0 + if exists('g:return') + let old_return = g:return + let saved = 1 + endif + + call s:loadPythonScript() + exec printf('python3 spectral_get_saturation("%s")', a:color) + + let ret = g:return + + if saved + let g:return = old_return + else + unlet g:return + endif + + return ret +endfunction + +function! spectral#setSaturation(color, amount) let saved = 0 if exists('g:return') let old_return = g:return @@ -233,6 +254,9 @@ function! spectral#Hi(bang, fn, name, ...) let bg = "None" let sp = "None" let extra = [] + else + echoerr printf("Incorrect number of arguments for highlight [%s]", a:name) + return endif if extra == [] @@ -307,3 +331,33 @@ function! spectral#useDefaultTerminalColors() abort let g:terminal_color_9="#b30005" endif endfunction + +function! spectral#brightenWord(amnt) abort + let color = expand('<cword>') + + if !(color =~ '^#[A-F-a-f0-9]\{6}') + echo "Not a color" + return + endif + + let new_color = spectral#brighter(color, a:amnt) + exec "norm ciw" . new_color . "" +endfunction + +function! spectral#saturate(color, amnt) abort + let cur_sat = spectral#getSaturation(a:color) + return spectral#setSaturation(a:color, cur_sat * a:amnt) +endfunction + +function! spectral#saturateWord(amnt) abort + let color = expand('<cword>') + + if !(color =~ '^#[A-F-a-f0-9]\{6}') + echo "Not a color" + return + endif + + let cur_sat = spectral#getSaturation(color) + let new_color = spectral#setSaturation(color, cur_sat * a:amnt) + exec "norm ciw" . new_color . "" +endfunction |