auto commit
This commit is contained in:
parent
008e81e523
commit
bbd92e49c8
@ -59,6 +59,26 @@
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
" }}}
|
" }}}
|
||||||
" Motion functions {{{
|
" Motion functions {{{
|
||||||
|
function! EasyMotion#LineYank()
|
||||||
|
let orig_pos = [line('.'), col('.')]
|
||||||
|
call EasyMotion#JK(0, 2)
|
||||||
|
if g:EasyMotion_cancelled
|
||||||
|
return ''
|
||||||
|
else
|
||||||
|
let pos1 = [line('.'), col('.')]
|
||||||
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
|
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', 2, '', '', pos1[0])
|
||||||
|
if g:EasyMotion_cancelled
|
||||||
|
return ''
|
||||||
|
else
|
||||||
|
normal! V
|
||||||
|
keepjumps call cursor(pos1[0], pos1[1])
|
||||||
|
normal! y
|
||||||
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
|
normal! p
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
function! EasyMotion#F(visualmode, direction) " {{{
|
function! EasyMotion#F(visualmode, direction) " {{{
|
||||||
let char = s:GetSearchChar(a:visualmode)
|
let char = s:GetSearchChar(a:visualmode)
|
||||||
|
|
||||||
@ -68,7 +88,7 @@
|
|||||||
|
|
||||||
let re = '\C' . escape(char, '.$^~')
|
let re = '\C' . escape(char, '.$^~')
|
||||||
|
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1), 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! EasyMotion#S(visualmode, direction) " {{{
|
function! EasyMotion#S(visualmode, direction) " {{{
|
||||||
@ -80,7 +100,7 @@
|
|||||||
|
|
||||||
let re = '\C' . escape(char, '.$^~')
|
let re = '\C' . escape(char, '.$^~')
|
||||||
|
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1), 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! EasyMotion#T(visualmode, direction) " {{{
|
function! EasyMotion#T(visualmode, direction) " {{{
|
||||||
@ -96,25 +116,25 @@
|
|||||||
let re = '\C.' . escape(char, '.$^~')
|
let re = '\C.' . escape(char, '.$^~')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1), 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#WB(visualmode, direction) " {{{
|
function! EasyMotion#WB(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#WBW(visualmode, direction) " {{{
|
function! EasyMotion#WBW(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\(\(^\|\s\)\@<=\S\|^$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion('\(\(^\|\s\)\@<=\S\|^$\)', a:direction, a:visualmode ? visualmode() : '', '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#E(visualmode, direction) " {{{
|
function! EasyMotion#E(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1), 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#EW(visualmode, direction) " {{{
|
function! EasyMotion#EW(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1), 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#JK(visualmode, direction) " {{{
|
function! EasyMotion#JK(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#Search(visualmode, direction) " {{{
|
function! EasyMotion#Search(visualmode, direction) " {{{
|
||||||
call s:EasyMotion(@/, a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion(@/, a:direction, a:visualmode ? visualmode() : '', '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" }}}
|
" }}}
|
||||||
" Helper functions {{{
|
" Helper functions {{{
|
||||||
@ -506,7 +526,7 @@
|
|||||||
return s:PromptUser(target)
|
return s:PromptUser(target)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
function! s:EasyMotion(regexp, direction, visualmode, mode) " {{{
|
function! s:EasyMotion(regexp, direction, visualmode, mode, hlcurrent) " {{{
|
||||||
let orig_pos = [line('.'), col('.')]
|
let orig_pos = [line('.'), col('.')]
|
||||||
let targets = []
|
let targets = []
|
||||||
|
|
||||||
@ -597,6 +617,9 @@
|
|||||||
|
|
||||||
let shade_hl_id = matchadd(g:EasyMotion_hl_group_shade, shade_hl_re, 0)
|
let shade_hl_id = matchadd(g:EasyMotion_hl_group_shade, shade_hl_re, 0)
|
||||||
endif
|
endif
|
||||||
|
if a:hlcurrent != 0
|
||||||
|
let shade_hl_line_id = matchadd(g:EasyMotion_hl_line_group_shade, '\%'. a:hlcurrent .'l.*', 1)
|
||||||
|
endif
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Prompt user for target group/character
|
" Prompt user for target group/character
|
||||||
@ -626,6 +649,7 @@
|
|||||||
call cursor(coords[0], coords[1])
|
call cursor(coords[0], coords[1])
|
||||||
|
|
||||||
call s:Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
|
call s:Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
|
||||||
|
let g:EasyMotion_cancelled = 0
|
||||||
catch
|
catch
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
@ -639,6 +663,7 @@
|
|||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
endif
|
endif
|
||||||
" }}}
|
" }}}
|
||||||
|
let g:EasyMotion_cancelled = 1
|
||||||
finally
|
finally
|
||||||
" Restore properties {{{
|
" Restore properties {{{
|
||||||
call s:VarReset('&scrolloff')
|
call s:VarReset('&scrolloff')
|
||||||
@ -652,6 +677,9 @@
|
|||||||
if g:EasyMotion_do_shade && exists('shade_hl_id')
|
if g:EasyMotion_do_shade && exists('shade_hl_id')
|
||||||
call matchdelete(shade_hl_id)
|
call matchdelete(shade_hl_id)
|
||||||
endif
|
endif
|
||||||
|
if a:hlcurrent && exists('shade_hl_line_id')
|
||||||
|
call matchdelete(shade_hl_line_id)
|
||||||
|
endif
|
||||||
" }}}
|
" }}}
|
||||||
endtry
|
endtry
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
\ , 'hl2_first_group_target' : 'EasyMotionTarget2First'
|
\ , 'hl2_first_group_target' : 'EasyMotionTarget2First'
|
||||||
\ , 'hl2_second_group_target' : 'EasyMotionTarget2Second'
|
\ , 'hl2_second_group_target' : 'EasyMotionTarget2Second'
|
||||||
\ , 'hl_group_shade' : 'EasyMotionShade'
|
\ , 'hl_group_shade' : 'EasyMotionShade'
|
||||||
|
\ , 'hl_line_group_shade' : 'EasyMotionShadeLine'
|
||||||
\ })
|
\ })
|
||||||
" }}}
|
" }}}
|
||||||
" Default highlighting {{{
|
" Default highlighting {{{
|
||||||
@ -44,17 +45,23 @@
|
|||||||
\ , 'cterm' : ['NONE', 'red' , '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']
|
||||||
\ , 'cterm' : ['NONE', 'grey' , 'NONE']
|
\ , 'cterm' : ['NONE', 'grey' , 'NONE']
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
let s:shade_hl_line_defaults = {
|
||||||
|
\ 'gui' : ['NONE', '#FFFFFF' , 'NONE']
|
||||||
|
\ , 'cterm256': ['NONE', '242' , 'NONE']
|
||||||
|
\ , 'cterm' : ['NONE', 'grey' , 'NONE']
|
||||||
|
\ }
|
||||||
|
|
||||||
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_first_group_target, s:target_hl2_first_defaults)
|
call EasyMotion#InitHL(g:EasyMotion_hl2_first_group_target, s:target_hl2_first_defaults)
|
||||||
call EasyMotion#InitHL(g:EasyMotion_hl2_second_group_target, s:target_hl2_second_defaults)
|
call EasyMotion#InitHL(g:EasyMotion_hl2_second_group_target, s:target_hl2_second_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)
|
||||||
|
call EasyMotion#InitHL(g:EasyMotion_hl_line_group_shade, s:shade_hl_line_defaults)
|
||||||
|
|
||||||
" Reset highlighting after loading a new color scheme {{{
|
" Reset highlighting after loading a new color scheme {{{
|
||||||
augroup EasyMotionInitHL
|
augroup EasyMotionInitHL
|
||||||
@ -64,6 +71,7 @@
|
|||||||
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl2_first_group_target, s:target_hl2_first_defaults)
|
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl2_first_group_target, s:target_hl2_first_defaults)
|
||||||
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl2_second_group_target, s:target_hl2_second_defaults)
|
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl2_second_group_target, s:target_hl2_second_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)
|
||||||
|
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_line_group_shade, s:shade_hl_line_defaults)
|
||||||
augroup end
|
augroup end
|
||||||
" }}}
|
" }}}
|
||||||
" }}}
|
" }}}
|
||||||
@ -84,6 +92,7 @@
|
|||||||
\ , 'gE': { 'name': 'EW' , 'dir': 1 }
|
\ , 'gE': { 'name': 'EW' , 'dir': 1 }
|
||||||
\ , 'j' : { 'name': 'JK' , 'dir': 0 }
|
\ , 'j' : { 'name': 'JK' , 'dir': 0 }
|
||||||
\ , 'k' : { 'name': 'JK' , 'dir': 1 }
|
\ , 'k' : { 'name': 'JK' , 'dir': 1 }
|
||||||
|
\ , 'l' : { 'name': 'JK' , 'dir': 2 }
|
||||||
\ , 'n' : { 'name': 'Search' , 'dir': 0 }
|
\ , 'n' : { 'name': 'Search' , 'dir': 0 }
|
||||||
\ , 'N' : { 'name': 'Search' , 'dir': 1 }
|
\ , 'N' : { 'name': 'Search' , 'dir': 1 }
|
||||||
\ })
|
\ })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user