vim-signify/autoload/sy/highlight.vim

92 lines
3.9 KiB
VimL
Raw Normal View History

2013-09-30 04:19:31 -04:00
" vim: et sw=2 sts=2
scriptencoding utf-8
2013-07-17 06:30:58 -04:00
" Init: values {{{1
if get(g:, 'signify_sign_show_text', 1)
let s:sign_add = get(g:, 'signify_sign_add', '+')
let s:sign_delete_first_line = get(g:, 'signify_sign_delete_first_line', '‾')
let s:sign_change = get(g:, 'signify_sign_change', '!')
let s:sign_changedelete = get(g:, 'signify_sign_changedelete', s:sign_change)
else
let s:sign_add = ' '
let s:sign_delete_first_line = ' '
let s:sign_change = ' '
let s:sign_changedelete = ' '
endif
let s:sign_show_count = get(g:, 'signify_sign_show_count', 1)
2013-07-17 06:30:58 -04:00
" Function: #setup {{{1
function! sy#highlight#setup() abort
Add finer grained control over signs and highlights I wanted to be able to customize signify in a way that wasn't possible with the current set of options. This commit adds 2 new options and 2 new highlight groups. Specifically, we can now 1. differentiate between changes, deletes AND signs that have both with the `signify_sign_changedelete` option. 2. disable showing the number of deleted lines in the sign column with the `signify_sign_delete_use_count` option. 3. highlight lines with changes and deletes specifically with the `SignifySignChangeDelete` highlight group. 4. highlight the first line differently with the `SignifySignDeleteFirstLine` highlight group. All of these default to existing settings/highlight groups, so everything should continue working the way it does now. -------------------------------------------------------------------------------- For those that are curious, I wanted to configure signify to show no symbols in the sign column, and to just use the highlight groups to give me all the information I needed. I am able to achieve that now with the following settings and the Solarized colorscheme: let g:signify_sign_add = "\<Char-0xa0>\<Char-0xa0>" let g:signify_sign_change = "\<Char-0xa0>\<Char-0xa0>" let g:signify_sign_changedelete = "__" let g:signify_sign_delete = "__" let g:signify_sign_delete_first_line = "‾‾" let g:signify_sign_delete_use_count = 0 hi SignifySignDelete term=bold,underline cterm=bold,underline ctermfg=1 ctermbg=12 hi SignifySignDeleteFirstLine ctermfg=1 ctermbg=12 hi SignifySignChangeDelete term=bold,underline cterm=bold,underline ctermfg=1 ctermbg=3 You can see it in action here: https://twitter.com/_bentomas/status/486266117204090880
2014-10-04 13:35:51 -04:00
highlight default link SignifyLineAdd DiffAdd
highlight default link SignifyLineDelete DiffDelete
highlight default link SignifyLineDeleteFirstLine SignifyLineDelete
highlight default link SignifyLineChange DiffChange
highlight default link SignifyLineChangeDelete SignifyLineChange
2013-07-17 06:30:58 -04:00
Add finer grained control over signs and highlights I wanted to be able to customize signify in a way that wasn't possible with the current set of options. This commit adds 2 new options and 2 new highlight groups. Specifically, we can now 1. differentiate between changes, deletes AND signs that have both with the `signify_sign_changedelete` option. 2. disable showing the number of deleted lines in the sign column with the `signify_sign_delete_use_count` option. 3. highlight lines with changes and deletes specifically with the `SignifySignChangeDelete` highlight group. 4. highlight the first line differently with the `SignifySignDeleteFirstLine` highlight group. All of these default to existing settings/highlight groups, so everything should continue working the way it does now. -------------------------------------------------------------------------------- For those that are curious, I wanted to configure signify to show no symbols in the sign column, and to just use the highlight groups to give me all the information I needed. I am able to achieve that now with the following settings and the Solarized colorscheme: let g:signify_sign_add = "\<Char-0xa0>\<Char-0xa0>" let g:signify_sign_change = "\<Char-0xa0>\<Char-0xa0>" let g:signify_sign_changedelete = "__" let g:signify_sign_delete = "__" let g:signify_sign_delete_first_line = "‾‾" let g:signify_sign_delete_use_count = 0 hi SignifySignDelete term=bold,underline cterm=bold,underline ctermfg=1 ctermbg=12 hi SignifySignDeleteFirstLine ctermfg=1 ctermbg=12 hi SignifySignChangeDelete term=bold,underline cterm=bold,underline ctermfg=1 ctermbg=3 You can see it in action here: https://twitter.com/_bentomas/status/486266117204090880
2014-10-04 13:35:51 -04:00
highlight default link SignifySignAdd DiffAdd
highlight default link SignifySignDelete DiffDelete
highlight default link SignifySignDeleteFirstLine SignifySignDelete
highlight default link SignifySignChange DiffChange
highlight default link SignifySignChangeDelete SignifySignChange
2013-07-17 06:30:58 -04:00
endfunction
" Function: #line_enable {{{1
function! sy#highlight#line_enable() abort
execute 'sign define SignifyAdd text='. s:sign_add 'texthl=SignifySignAdd linehl=SignifyLineAdd'
execute 'sign define SignifyChange text='. s:sign_change 'texthl=SignifySignChange linehl=SignifyLineChange'
execute 'sign define SignifyRemoveFirstLine text='. s:sign_delete_first_line 'texthl=SignifySignDeleteFirstLine linehl=SignifyLineDeleteFirstLine'
if s:sign_show_count
let s:sign_changedelete = substitute(s:sign_changedelete, '^.\zs.*', '', '')
for n in range(1, 9)
execute 'sign define SignifyChangeDelete'. n 'text='. s:sign_changedelete . n 'texthl=SignifySignChangeDelete linehl=SignifyLineChangeDelete'
endfor
execute 'sign define SignifyChangeDeleteMore text='. s:sign_changedelete .'> texthl=SignifySignChangeDelete linehl=SignifyLineChangeDelete'
else
for n in range(1, 9)
execute 'sign define SignifyChangeDelete'. n 'text='. s:sign_changedelete 'texthl=SignifySignChangeDelete linehl=SignifyLineChangeDelete'
endfor
execute 'sign define SignifyChangeDeleteMore text='. s:sign_changedelete 'texthl=SignifySignChangeDelete linehl=SignifyLineChangeDelete'
endif
2013-07-17 06:30:58 -04:00
let g:signify_line_highlight = 1
endfunction
" Function: #line_disable {{{1
function! sy#highlight#line_disable() abort
execute 'sign define SignifyAdd text='. s:sign_add 'texthl=SignifySignAdd linehl='
execute 'sign define SignifyChange text='. s:sign_change 'texthl=SignifySignChange linehl='
execute 'sign define SignifyRemoveFirstLine text='. s:sign_delete_first_line 'texthl=SignifySignDeleteFirstLine linehl='
if s:sign_show_count
let s:sign_changedelete = substitute(s:sign_changedelete, '^.\zs.*', '', '')
for n in range(1, 9)
execute 'sign define SignifyChangeDelete'. n 'text='. s:sign_changedelete . n 'texthl=SignifySignChangeDelete linehl='
endfor
execute 'sign define SignifyChangeDeleteMore text='. s:sign_changedelete .'> texthl=SignifySignChangeDelete linehl='
else
for n in range(1, 9)
execute 'sign define SignifyChangeDelete'. n 'text='. s:sign_changedelete 'texthl=SignifySignChangeDelete linehl='
endfor
execute 'sign define SignifyChangeDeleteMore text='. s:sign_changedelete 'texthl=SignifySignChangeDelete linehl='
endif
2013-07-17 06:30:58 -04:00
let g:signify_line_highlight = 0
endfunction
" Function: #line_toggle {{{1
function! sy#highlight#line_toggle() abort
if get(g:, 'signify_line_highlight')
2013-07-17 06:30:58 -04:00
call sy#highlight#line_disable()
else
call sy#highlight#line_enable()
endif
redraw!
call sy#start()
2013-07-17 06:30:58 -04:00
endfunction
2014-10-24 05:39:05 -04:00
" }}}
call sy#highlight#setup()