From 27a8f3ddb47c7b323e8f405b1b5b4816b23d44fe Mon Sep 17 00:00:00 2001 From: Supasorn Suwajanakorn Date: Mon, 13 May 2013 22:53:51 -0700 Subject: [PATCH] auto commit --- autoload/EasyMotion.vim | 31 ++++++++++++++++++++++++++++--- plugin/EasyMotion.vim | 10 ++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 47aefd4..5fd61c8 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -358,8 +358,10 @@ " }}} " Prepare marker lines {{{ let lines = {} + let lines_marks = {} let hl_coords = [] let hl_coords2 = [] " Highlight for two characters + let overlap_coords = [] " Highlight for two characters let coord_key_dict = s:CreateCoordKeyDict(a:groups) @@ -375,6 +377,8 @@ let current_line = getline(line_num) let lines[line_num] = { 'orig': current_line, 'marker': current_line, 'mb_compensation': 0 } + let lines_marks[line_num] = {} + endif " Compensate for byte difference between marker @@ -405,12 +409,24 @@ " Add highlighting coordinates if target_key_len == 1 - call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c') + if has_key(lines_marks[line_num], col_num) + call add(overlap_coords, '\%' . line_num . 'l\%' . col_num . 'c') + else + call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c') + endif + + let lines_marks[line_num][col_num] = 1 else let c = 0 while c < target_key_len - call add(hl_coords2, '\%' . line_num . 'l\%' . (col_num + c) . 'c') + if has_key(lines_marks[line_num], col_num + c) + call add(overlap_coords, '\%' . line_num . 'l\%' . (col_num + c) . 'c') + else + call add(hl_coords2, '\%' . line_num . 'l\%' . (col_num + c) . 'c') + endif + let lines_marks[line_num][col_num + c] = 1 + let c += 1 endwhile endif @@ -425,7 +441,13 @@ " }}} " Highlight targets {{{ 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) + if len(hl_coords2) > 0 + let target_hl2_id = matchadd(g:EasyMotion_hl2_group_target, join(hl_coords2, '\|'), 1) + endif + if len(overlap_coords) > 0 + let target_overlap_id = matchadd(g:EasyMotion_hl_group_overlap, join(overlap_coords, '\|'), 1) + endif + " }}} try @@ -450,6 +472,9 @@ if exists('target_hl2_id') call matchdelete(target_hl2_id) endif + if exists('target_overlap_id') + call matchdelete(target_overlap_id) + endif " }}} redraw diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index 44b6f13..7633a8f 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -21,6 +21,7 @@ \ \ , 'hl_group_target' : 'EasyMotionTarget' \ , 'hl2_group_target' : 'EasyMotionTarget2' + \ , 'hl_group_overlap' : 'EasyMotionOverlap' \ , 'hl_group_shade' : 'EasyMotionShade' \ }) " }}} @@ -37,6 +38,13 @@ \ , 'cterm' : ['NONE', 'red' , 'bold'] \ } + let s:target_hl_overlap_defaults = { + \ 'gui' : ['NONE', '#ff0000' , 'bold'] + \ , 'cterm256': ['NONE', '196' , 'bold'] + \ , 'cterm' : ['NONE', 'red' , 'bold'] + \ } + + let s:shade_hl_defaults = { \ 'gui' : ['NONE', '#777777' , 'NONE'] \ , 'cterm256': ['NONE', '242' , 'NONE'] @@ -45,6 +53,7 @@ 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_overlap, s:target_hl_overlap_defaults) call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults) " Reset highlighting after loading a new color scheme {{{ @@ -53,6 +62,7 @@ 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_overlap, s:target_hl_overlap_defaults) autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults) augroup end " }}}