Merge branch 'improve/highlight' into master
This commit is contained in:
commit
2d5b12ef01
@ -3,7 +3,7 @@
|
||||
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
|
||||
" haya14busa <hayabusa1419@gmail.com>
|
||||
" Source: https://github.com/Lokaltog/vim-easymotion
|
||||
" Last Change: 02 Feb 2014.
|
||||
" Last Change: 04 Feb 2014.
|
||||
"=============================================================================
|
||||
" Saving 'cpoptions' {{{
|
||||
scriptencoding utf-8
|
||||
@ -294,7 +294,7 @@ function! EasyMotion#NextPrevious(visualmode, direction) " {{{
|
||||
|
||||
if g:EasyMotion_move_highlight
|
||||
call EasyMotion#highlight#attach_autocmd()
|
||||
call EasyMotion#highlight#add_highlight(re,'EasyMotionMoveHL')
|
||||
call EasyMotion#highlight#add_highlight(re, g:EasyMotion_hl_move)
|
||||
endif
|
||||
|
||||
if ! empty(a:visualmode)
|
||||
@ -611,7 +611,8 @@ endfunction "}}}
|
||||
function! EasyMotion#activate(is_visual) "{{{
|
||||
let s:EasyMotion_is_active = 1
|
||||
call EasyMotion#attach_active_autocmd()
|
||||
call EasyMotion#highlight#add_highlight(s:previous.regexp, 'EasyMotionMoveHL')
|
||||
call EasyMotion#highlight#add_highlight(s:previous.regexp,
|
||||
\ g:EasyMotion_hl_move)
|
||||
call EasyMotion#highlight#attach_autocmd()
|
||||
if a:is_visual == 1
|
||||
normal! gv
|
||||
@ -821,9 +822,11 @@ function! s:PromptUser(groups) "{{{
|
||||
" Add original line and marker line
|
||||
if ! has_key(lines, line_num)
|
||||
let current_line = getline(line_num)
|
||||
|
||||
let lines[line_num] = { 'orig': current_line, 'marker': current_line, 'mb_compensation': 0 }
|
||||
|
||||
let lines[line_num] = {
|
||||
\ 'orig': current_line,
|
||||
\ 'marker': current_line,
|
||||
\ 'mb_compensation': 0,
|
||||
\ }
|
||||
endif
|
||||
|
||||
" Solve multibyte issues by matching the byte column
|
||||
@ -836,13 +839,17 @@ function! s:PromptUser(groups) "{{{
|
||||
" This has to be done in order to match the correct
|
||||
" column; \%c matches the byte column and not display
|
||||
" column.
|
||||
let target_char_len = strdisplaywidth(matchstr(lines[line_num]['marker'], '\%' . col_num . 'c.'))
|
||||
let target_char_len = strdisplaywidth(
|
||||
\ matchstr(lines[line_num]['marker'],
|
||||
\ '\%' . col_num . 'c.'))
|
||||
let target_key_len = strdisplaywidth(target_key)
|
||||
|
||||
|
||||
let target_line_byte_len = strlen(lines[line_num]['marker'])
|
||||
|
||||
let target_char_byte_len = strlen(matchstr(lines[line_num]['marker'], '\%' . col_num . 'c.'))
|
||||
let target_char_byte_len = strlen(matchstr(
|
||||
\ lines[line_num]['marker'],
|
||||
\ '\%' . col_num . 'c.'))
|
||||
|
||||
if strlen(lines[line_num]['marker']) > 0
|
||||
" Substitute marker character if line length > 0
|
||||
@ -864,7 +871,7 @@ function! s:PromptUser(groups) "{{{
|
||||
\ '')
|
||||
endif
|
||||
else
|
||||
let lines[line_num]['marker'] = lines[line_num]['marker'] . strpart(target_key, c, 1)
|
||||
let lines[line_num]['marker'] .= strpart(target_key, c, 1)
|
||||
endif
|
||||
let c += 1
|
||||
endwhile
|
||||
@ -877,32 +884,35 @@ function! s:PromptUser(groups) "{{{
|
||||
if target_key_len == 1
|
||||
call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c')
|
||||
else
|
||||
call add(hl2_first_coords, '\%' . line_num . 'l\%' . (col_num) . 'c')
|
||||
call add(hl2_second_coords, '\%' . line_num . 'l\%' . (col_num + 1) . 'c')
|
||||
call add(hl2_first_coords,
|
||||
\ '\%' . line_num . 'l\%' . col_num . 'c')
|
||||
call add(hl2_second_coords,
|
||||
\ '\%' . line_num . 'l\%' . (col_num + 1) . 'c')
|
||||
endif
|
||||
|
||||
" Add marker/target length difference for multibyte
|
||||
" compensation
|
||||
let lines[line_num]['mb_compensation'] += (target_line_byte_len - strlen(lines[line_num]['marker']) )
|
||||
let lines[line_num]['mb_compensation'] +=
|
||||
\ (target_line_byte_len - strlen(lines[line_num]['marker']))
|
||||
endfor
|
||||
|
||||
let lines_items = items(lines)
|
||||
" }}}
|
||||
" -- Highlight targets ------------------- {{{
|
||||
if len(hl_coords) > 0
|
||||
let hl_coords_re = '\%(' . join(hl_coords, '\|') . '\)'
|
||||
call EasyMotion#highlight#add_highlight(
|
||||
\ join(hl_coords, '\|'),
|
||||
\ g:EasyMotion_hl_group_target)
|
||||
endif
|
||||
if len(hl2_second_coords) > 0
|
||||
call EasyMotion#highlight#add_highlight(
|
||||
\ join(hl2_second_coords, '\|'),
|
||||
\ g:EasyMotion_hl2_second_group_target)
|
||||
\ hl_coords_re, g:EasyMotion_hl_group_target)
|
||||
endif
|
||||
if len(hl2_first_coords) > 0
|
||||
let hl2_first_coords_re = '\%(' . join(hl2_first_coords, '\|') . '\)'
|
||||
call EasyMotion#highlight#add_highlight(
|
||||
\ join(hl2_first_coords, '\|'),
|
||||
\ g:EasyMotion_hl2_first_group_target)
|
||||
\ hl2_first_coords_re, g:EasyMotion_hl2_first_group_target)
|
||||
endif
|
||||
if len(hl2_second_coords) > 0
|
||||
let hl2_second_coords_re = '\%(' . join(hl2_second_coords, '\|') . '\)'
|
||||
call EasyMotion#highlight#add_highlight(
|
||||
\ hl2_second_coords_re, g:EasyMotion_hl2_second_group_target)
|
||||
endif
|
||||
" }}}
|
||||
|
||||
@ -1200,17 +1210,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive) " {{{
|
||||
endif
|
||||
|
||||
call EasyMotion#highlight#add_highlight(
|
||||
\ shade_hl_re,
|
||||
\ g:EasyMotion_hl_group_shade)
|
||||
if g:EasyMotion_cursor_highlight
|
||||
let cursor_hl_re = '\%#'
|
||||
call EasyMotion#highlight#add_highlight(cursor_hl_re,
|
||||
\ g:EasyMotion_hl_inc_cursor)
|
||||
endif
|
||||
|
||||
call EasyMotion#highlight#add_highlight(
|
||||
\ shade_hl_re,
|
||||
\ g:EasyMotion_hl_group_shade)
|
||||
\ shade_hl_re, g:EasyMotion_hl_group_shade)
|
||||
if g:EasyMotion_cursor_highlight
|
||||
let cursor_hl_re = '\%#'
|
||||
call EasyMotion#highlight#add_highlight(cursor_hl_re,
|
||||
@ -1384,7 +1384,8 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive) " {{{
|
||||
if s:EasyMotion_is_cancelled == 0 " Success
|
||||
" -- Landing Highlight ------------------- {{{
|
||||
if g:EasyMotion_landing_highlight
|
||||
call EasyMotion#highlight#add_highlight(a:regexp, 'EasyMotionMoveHL')
|
||||
call EasyMotion#highlight#add_highlight(a:regexp,
|
||||
\ g:EasyMotion_hl_move)
|
||||
call EasyMotion#highlight#attach_autocmd()
|
||||
endif "}}}
|
||||
" -- Activate EasyMotion ----------------- {{{
|
||||
|
@ -2,7 +2,7 @@
|
||||
" FILE: autoload/EasyMotion/command_line.vim
|
||||
" AUTHOR: haya14busa
|
||||
" Reference: https://github.com/osyo-manga/vim-over
|
||||
" Last Change: 01 Feb 2014.
|
||||
" Last Change: 04 Feb 2014.
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
@ -90,9 +90,10 @@ endfunction "}}}
|
||||
function! s:search.on_enter() "{{{
|
||||
if s:num_strokes == -1
|
||||
call EasyMotion#highlight#delete_highlight()
|
||||
let shade_hl_re = '\_.*'
|
||||
call EasyMotion#highlight#add_highlight(shade_hl_re, g:EasyMotion_hl_group_shade)
|
||||
call EasyMotion#highlight#add_highlight('\%#', g:EasyMotion_hl_inc_cursor)
|
||||
call EasyMotion#highlight#add_highlight('\_.*',
|
||||
\ g:EasyMotion_hl_group_shade)
|
||||
call EasyMotion#highlight#add_highlight('\%#',
|
||||
\ g:EasyMotion_hl_inc_cursor)
|
||||
endif
|
||||
endfunction "}}}
|
||||
function! s:search.on_leave() "{{{
|
||||
|
@ -2,7 +2,7 @@
|
||||
" FILE: highlight.vim
|
||||
" AUTHOR: haya14busa
|
||||
" Reference: https://github.com/t9md/vim-smalls
|
||||
" Last Change: 31 Jan 2014.
|
||||
" Last Change: 04 Feb 2014.
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
@ -34,13 +34,13 @@ set cpo&vim
|
||||
let s:h = {}
|
||||
let s:h.ids = {}
|
||||
let s:priorities = {
|
||||
\ 'EasyMotionTarget' : 1,
|
||||
\ 'EasyMotionTarget2First' : 1,
|
||||
\ 'EasyMotionTarget2Second' : 1,
|
||||
\ 'EasyMotionShade' : 0,
|
||||
\ 'EasyMotionIncSearch' : 1,
|
||||
\ 'EasyMotionIncCursor' : 2,
|
||||
\ 'EasyMotionMoveHL' : 0,
|
||||
\ g:EasyMotion_hl_group_target : 1,
|
||||
\ g:EasyMotion_hl2_first_group_target : 1,
|
||||
\ g:EasyMotion_hl2_second_group_target : 1,
|
||||
\ g:EasyMotion_hl_group_shade : 0,
|
||||
\ g:EasyMotion_hl_inc_search : 1,
|
||||
\ g:EasyMotion_hl_inc_cursor : 2,
|
||||
\ g:EasyMotion_hl_move : 0,
|
||||
\ }
|
||||
for group in keys(s:priorities)
|
||||
let s:h.ids[group] = []
|
||||
|
Loading…
Reference in New Issue
Block a user