Mercurial > ec-dotfiles
comparison vendor/vim-packs/srcery-vim/autoload/srcery/helper.vim @ 704:1e0f578f6752
Update vendor and add support for vim packs
| author | nanaya <me@nanaya.net> | 
|---|---|
| date | Sun, 18 Dec 2022 20:06:46 +0900 | 
| parents | |
| children | 2cf87b7ca09a | 
   comparison
  equal
  deleted
  inserted
  replaced
| 703:b7cd7465cc26 | 704:1e0f578f6752 | 
|---|---|
| 1 " ----------------------------------------------------------------------------- | |
| 2 " File: helper.vim | |
| 3 " Description: Srcery colorscheme helpers functions | |
| 4 " Authors: Daniel Berg <mail@roosta.sh>, Birger J. Nordolum <contact+srcery@mindtooth.no> | |
| 5 " Last Modified: 2020-08-27 | |
| 6 " ----------------------------------------------------------------------------- | |
| 7 | |
| 8 " Helper to get a source color defined in colorscheme | |
| 9 function! srcery#helper#GetColor(group, ...) abort | |
| 10 " Arguments: group, what | |
| 11 | |
| 12 " optionally pass a 'what' argument, defaults to 'fg' | |
| 13 if a:0 > 0 | |
| 14 let l:what = a:1 | |
| 15 else | |
| 16 let l:what = 'fg' | |
| 17 endif | |
| 18 | |
| 19 let l:gui_color = synIDattr(hlID(a:group), l:what, 'gui') | |
| 20 let l:term_color = synIDattr(hlID(a:group), l:what, 'cterm') | |
| 21 | |
| 22 return [ l:gui_color, l:term_color ] | |
| 23 endfunction | |
| 24 | |
| 25 " With the help of dracula! | |
| 26 " Helper function that takes a variadic list of filetypes as args and returns | |
| 27 " whether or not the execution of the ftplugin should be aborted. | |
| 28 function! srcery#helper#ShouldAbort(...) abort | |
| 29 if ! exists('g:colors_name') || g:colors_name !=# 'srcery' | |
| 30 return 1 | |
| 31 elseif a:0 > 0 && (! exists('b:current_syntax') || index(a:000, b:current_syntax) == -1) | |
| 32 return 1 | |
| 33 endif | |
| 34 return 0 | |
| 35 endfunction | |
| 36 | |
| 37 function! srcery#helper#Highlight(group, fg, ...) abort | |
| 38 " Arguments: group, guifg, guibg, gui, guisp | |
| 39 | |
| 40 " foreground | |
| 41 let l:fg = a:fg | |
| 42 | |
| 43 " background | |
| 44 if a:0 >= 1 | |
| 45 let l:bg = a:1 | |
| 46 else | |
| 47 let l:bg = g:srcery#palette.none | |
| 48 endif | |
| 49 | |
| 50 " emphasis | |
| 51 if a:0 >= 2 && strlen(a:2) | |
| 52 let l:emstr = a:2 | |
| 53 else | |
| 54 let l:emstr = 'NONE,' | |
| 55 endif | |
| 56 | |
| 57 " special fallback | |
| 58 if a:0 >= 3 | |
| 59 if g:srcery_guisp_fallback !=# 'NONE' | |
| 60 let fg = a:3 | |
| 61 endif | |
| 62 | |
| 63 " bg fallback mode should invert higlighting | |
| 64 if g:srcery_guisp_fallback ==# 'bg' | |
| 65 let emstr .= 'inverse,' | |
| 66 endif | |
| 67 endif | |
| 68 | |
| 69 let l:histring = [ 'hi', a:group, | |
| 70 \ 'guifg=' . l:fg[0], 'ctermfg=' . l:fg[1], | |
| 71 \ 'guibg=' . l:bg[0], 'ctermbg=' . l:bg[1], | |
| 72 \ 'gui=' . l:emstr[:-2], 'cterm=' . l:emstr[:-2] | |
| 73 \ ] | |
| 74 | |
| 75 " special | |
| 76 if a:0 >= 3 | |
| 77 call add(l:histring, 'guisp=' . a:3[0]) | |
| 78 endif | |
| 79 | |
| 80 execute join(l:histring, ' ') | |
| 81 endfunction | |
| 82 | |
| 83 " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: | 
