annotate vendor/vim-packs/srcery-vim/autoload/srcery/helper.vim @ 723:440e800e9be0

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