auto commit

This commit is contained in:
Supasorn Suwajanakorn 2013-05-13 21:43:58 -07:00
parent c58b10b59f
commit 229a190ceb
2 changed files with 35 additions and 11 deletions

View File

@ -314,8 +314,8 @@
let group_key = a:0 == 1 ? a:1 : '' let group_key = a:0 == 1 ? a:1 : ''
for [key, item] in items(a:groups) for [key, item] in items(a:groups)
"let key = group_key . key "( ! empty(group_key) ? group_key : key) let key = group_key . key "( ! empty(group_key) ? group_key : key)
let key = ( ! empty(group_key) ? group_key : key) "let key = ( ! empty(group_key) ? group_key : key)
if type(item) == 3 if type(item) == 3
" Destination coords " Destination coords
@ -359,6 +359,8 @@
" Prepare marker lines {{{ " Prepare marker lines {{{
let lines = {} let lines = {}
let hl_coords = [] let hl_coords = []
let hl_coords2 = [] " Highlight for two characters
let coord_key_dict = s:CreateCoordKeyDict(a:groups) let coord_key_dict = s:CreateCoordKeyDict(a:groups)
for dict_key in sort(coord_key_dict[0]) for dict_key in sort(coord_key_dict[0])
@ -391,29 +393,39 @@
if strlen(lines[line_num]['marker']) > 0 if strlen(lines[line_num]['marker']) > 0
" Substitute marker character if line length > 0 " Substitute marker character if line length > 0
let lines[line_num]['marker'] = substitute(lines[line_num]['marker'], '\%' . col_num . 'c.', target_key, '') let c = 0
"let c = 0 while c < target_key_len
"while c < target_key_len let lines[line_num]['marker'] = substitute(lines[line_num]['marker'], '\%' . (col_num + c) . 'c.', strpart(target_key, c, 1), '')
"let lines[line_num]['marker'] = substitute(lines[line_num]['marker'], '\%' . (col_num + c) . 'c.', strpart(target_key, c, 1), '') let c += 1
"let c += 1 endwhile
"endwhile
else else
" Set the line to the marker character if the line is empty " Set the line to the marker character if the line is empty
let lines[line_num]['marker'] = target_key let lines[line_num]['marker'] = target_key
endif endif
" Add highlighting coordinates " Add highlighting coordinates
if target_key_len == 1
call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c') call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c')
else
let c = 0
while c < target_key_len
call add(hl_coords2, '\%' . line_num . 'l\%' . (col_num + c) . 'c')
let c += 1
endwhile
endif
" Add marker/target lenght difference for multibyte " Add marker/target lenght difference for multibyte
" compensation " compensation
let lines[line_num]['mb_compensation'] += (target_char_len - target_key_len) "let lines[line_num]['mb_compensation'] += (target_char_len - target_key_len)
let lines[line_num]['mb_compensation'] += (target_char_len - 1)
endfor endfor
let lines_items = items(lines) let lines_items = items(lines)
" }}} " }}}
" Highlight targets {{{ " Highlight targets {{{
let target_hl_id = matchadd(g:EasyMotion_hl_group_target, join(hl_coords, '\|'), 1) let target_hl_id = matchadd(g:EasyMotion_hl_group_target, join(hl_coords, '\|'), 1)
let target_hl2_id = matchadd(g:EasyMotion_hl2_group_target, join(hl_coords2, '\|'), 1)
" }}} " }}}
try try
@ -435,6 +447,9 @@
if exists('target_hl_id') if exists('target_hl_id')
call matchdelete(target_hl_id) call matchdelete(target_hl_id)
endif endif
if exists('target_hl2_id')
call matchdelete(target_hl2_id)
endif
" }}} " }}}
redraw redraw

View File

@ -14,12 +14,13 @@
" Default options {{{ " Default options {{{
call EasyMotion#InitOptions({ call EasyMotion#InitOptions({
\ 'leader_key' : '<Leader><Leader>' \ 'leader_key' : '<Leader><Leader>'
\ , 'keys' : 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \ , 'keys' : 'abcdeghiklmnopqrstuvwxyzfj'
\ , 'do_shade' : 1 \ , 'do_shade' : 1
\ , 'do_mapping' : 1 \ , 'do_mapping' : 1
\ , 'grouping' : 1 \ , 'grouping' : 1
\ \
\ , 'hl_group_target' : 'EasyMotionTarget' \ , 'hl_group_target' : 'EasyMotionTarget'
\ , 'hl2_group_target' : 'EasyMotionTarget2'
\ , 'hl_group_shade' : 'EasyMotionShade' \ , 'hl_group_shade' : 'EasyMotionShade'
\ }) \ })
" }}} " }}}
@ -30,6 +31,12 @@
\ , 'cterm' : ['NONE', 'red' , 'bold'] \ , 'cterm' : ['NONE', 'red' , 'bold']
\ } \ }
let s:target_hl2_defaults = {
\ 'gui' : ['NONE', '#ffb400' , 'bold']
\ , 'cterm256': ['NONE', '196' , 'bold']
\ , 'cterm' : ['NONE', 'red' , 'bold']
\ }
let s:shade_hl_defaults = { let s:shade_hl_defaults = {
\ 'gui' : ['NONE', '#777777' , 'NONE'] \ 'gui' : ['NONE', '#777777' , 'NONE']
\ , 'cterm256': ['NONE', '242' , 'NONE'] \ , 'cterm256': ['NONE', '242' , 'NONE']
@ -37,6 +44,7 @@
\ } \ }
call EasyMotion#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults) call EasyMotion#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults)
call EasyMotion#InitHL(g:EasyMotion_hl2_group_target, s:target_hl2_defaults)
call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults) call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults)
" Reset highlighting after loading a new color scheme {{{ " Reset highlighting after loading a new color scheme {{{
@ -44,6 +52,7 @@
autocmd! autocmd!
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults) autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults)
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl2_group_target, s:target_hl2_defaults)
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults) autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults)
augroup end augroup end
" }}} " }}}