2011-11-07 08:33:20 -05:00
|
|
|
" EasyMotion - Vim motions on speed!
|
|
|
|
"
|
2014-02-01 12:26:06 -05:00
|
|
|
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
|
|
|
|
" haya14busa <hayabusa1419@gmail.com>
|
|
|
|
" Source: https://github.com/Lokaltog/vim-easymotion
|
2014-02-19 13:19:59 -05:00
|
|
|
" Last Change: 20 Feb 2014.
|
2014-01-17 12:46:48 -05:00
|
|
|
"=============================================================================
|
|
|
|
" Saving 'cpoptions' {{{
|
|
|
|
scriptencoding utf-8
|
2013-12-18 07:42:56 -05:00
|
|
|
let s:save_cpo = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
" }}}
|
2014-01-17 12:46:48 -05:00
|
|
|
" Init: {{{
|
2014-01-08 23:45:32 -05:00
|
|
|
function! EasyMotion#init()
|
2014-02-05 09:15:57 -05:00
|
|
|
call EasyMotion#highlight#load()
|
2014-01-21 03:22:27 -05:00
|
|
|
" Store previous motion info
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:previous = {}
|
2014-01-21 03:22:27 -05:00
|
|
|
" Store previous operator-pending motion info for '.' repeat
|
2014-01-19 07:12:17 -05:00
|
|
|
let s:dot_repeat = {}
|
2014-01-21 03:22:27 -05:00
|
|
|
" Prepare 1-key Migemo Dictionary
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:migemo_dicts = {}
|
2014-01-20 00:33:58 -05:00
|
|
|
let s:EasyMotion_is_active = 0
|
2014-01-17 05:39:06 -05:00
|
|
|
call EasyMotion#reset()
|
2014-01-17 03:39:26 -05:00
|
|
|
" Anywhere regular expression: {{{
|
|
|
|
let re = '\v' .
|
|
|
|
\ '(<.|^$)' . '|' .
|
|
|
|
\ '(.>|^$)' . '|' .
|
|
|
|
\ '(\l)\zs(\u)' . '|' .
|
|
|
|
\ '(_\zs.)' . '|' .
|
|
|
|
\ '(#\zs.)'
|
|
|
|
" 1. word
|
|
|
|
" 2. end of word
|
|
|
|
" 3. CamelCase
|
|
|
|
" 4. after '_' hoge_foo
|
|
|
|
" 5. after '#' hoge#foo
|
|
|
|
let g:EasyMotion_re_anywhere = get(g:, 'EasyMotion_re_anywhere', re)
|
|
|
|
|
|
|
|
" Anywhere regular expression within line:
|
|
|
|
let re = '\v' .
|
|
|
|
\ '(<.|^$)' . '|' .
|
|
|
|
\ '(.>|^$)' . '|' .
|
|
|
|
\ '(\l)\zs(\u)' . '|' .
|
|
|
|
\ '(_\zs.)' . '|' .
|
|
|
|
\ '(#\zs.)'
|
|
|
|
let g:EasyMotion_re_line_anywhere = get(g:, 'EasyMotion_re_line_anywhere', re)
|
|
|
|
"}}}
|
2014-01-22 00:08:48 -05:00
|
|
|
" For other plugin
|
|
|
|
let s:EasyMotion_is_cancelled = 0
|
|
|
|
" 0 -> Success
|
|
|
|
" 1 -> Cancel
|
|
|
|
let g:EasyMotion_ignore_exception = 0
|
2014-01-17 03:39:26 -05:00
|
|
|
return ""
|
2014-01-08 23:45:32 -05:00
|
|
|
endfunction "}}}
|
2014-01-17 12:46:48 -05:00
|
|
|
" Reset: {{{
|
2013-12-18 08:39:41 -05:00
|
|
|
function! EasyMotion#reset()
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:flag = {
|
|
|
|
\ 'within_line' : 0,
|
|
|
|
\ 'dot_repeat' : 0,
|
2014-01-17 06:59:41 -05:00
|
|
|
\ 'regexp' : 0,
|
2014-01-20 21:10:12 -05:00
|
|
|
\ 'bd_t' : 0,
|
|
|
|
\ 'find_bd' : 0,
|
2014-01-17 03:39:26 -05:00
|
|
|
\ }
|
2014-01-21 03:22:27 -05:00
|
|
|
" regexp: -> regular expression
|
|
|
|
" This value is used when multi input find motion. If this values is
|
|
|
|
" 1, input text is treated as regexp.(Default: escaped)
|
|
|
|
" bd_t: -> bi-directional 't' motion
|
|
|
|
" This value is used to re-define regexp only for bi-directional 't'
|
|
|
|
" motion
|
|
|
|
" find_bd: -> bi-directional find motion
|
|
|
|
" This value is used to recheck the motion is inclusive or exclusive
|
|
|
|
" because 'f' & 't' forward find motion is inclusive, but 'F' & 'T'
|
|
|
|
" backward find motion is exclusive
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current = {
|
|
|
|
\ 'is_operator' : 0,
|
2014-02-06 08:12:52 -05:00
|
|
|
\ 'is_search' : 0,
|
2014-01-17 03:39:26 -05:00
|
|
|
\ 'dot_repeat_target_cnt' : 0,
|
|
|
|
\ 'dot_prompt_user_cnt' : 0,
|
2014-01-19 07:17:51 -05:00
|
|
|
\ 'changedtick' : 0,
|
2014-01-17 03:39:26 -05:00
|
|
|
\ }
|
2014-01-22 21:47:31 -05:00
|
|
|
" \ 'start_position' : [],
|
|
|
|
" \ 'cursor_position' : [],
|
|
|
|
|
2014-01-21 03:22:27 -05:00
|
|
|
" is_operator:
|
|
|
|
" Store is_operator value first because mode(1) value will be
|
|
|
|
" changed by some operation.
|
|
|
|
" dot_* :
|
|
|
|
" These values are used when '.' repeat for automatically
|
|
|
|
" select marker/label characters.(Using count avoid recursive
|
|
|
|
" prompt)
|
|
|
|
" changedtick:
|
|
|
|
" :h b:changedtick
|
|
|
|
" This value is used to avoid side effect of overwriting buffer text
|
|
|
|
" which will change b:changedtick value. To overwrite g:repeat_tick
|
|
|
|
" value(defined tpope/vim-repeat), I can avoid this side effect of
|
|
|
|
" conflicting with tpope/vim-repeat
|
2014-01-22 21:47:31 -05:00
|
|
|
" start_position:
|
|
|
|
" Original, start cursor position.
|
|
|
|
" cursor_position:
|
|
|
|
" Usually, this valuse is same with start_position, but in
|
|
|
|
" visualmode and 'n' key motion, this value could be different.
|
2014-01-17 03:39:26 -05:00
|
|
|
return ""
|
2013-12-18 08:39:41 -05:00
|
|
|
endfunction "}}}
|
2014-01-17 12:46:48 -05:00
|
|
|
" Motion Functions: {{{
|
2014-01-07 03:02:16 -05:00
|
|
|
" -- Find Motion -------------------------
|
2014-01-21 03:22:27 -05:00
|
|
|
" Note: {{{
|
|
|
|
" num_strokes:
|
|
|
|
" The number of input characters. Currently provide 1, 2, or -1.
|
|
|
|
" '-1' means no limit.
|
|
|
|
" visualmode:
|
|
|
|
" Vim script couldn't detect the function is called in visual mode by
|
|
|
|
" mode(1), so tell whether it is in visual mode by argument explicitly
|
|
|
|
" direction:
|
|
|
|
" 0 -> forward
|
|
|
|
" 1 -> backward
|
|
|
|
" 2 -> bi-direction (handle forward & backward at the same time) }}}
|
2014-01-13 10:57:02 -05:00
|
|
|
function! EasyMotion#S(num_strokes, visualmode, direction) " {{{
|
2014-01-20 21:10:12 -05:00
|
|
|
if a:direction == 1
|
|
|
|
let is_inclusive = 0
|
|
|
|
else
|
2014-01-21 03:22:27 -05:00
|
|
|
" Note: Handle bi-direction later because 'f' motion is inclusive but
|
|
|
|
" 'F' motion is exclusive
|
2014-01-20 21:10:12 -05:00
|
|
|
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
|
|
|
|
endif
|
|
|
|
let s:flag.find_bd = a:direction == 2 ? 1 : 0
|
2014-01-22 21:47:31 -05:00
|
|
|
let re = s:findMotion(a:num_strokes, a:direction)
|
2014-01-17 05:39:06 -05:00
|
|
|
if s:handleEmpty(re, a:visualmode) | return | endif
|
2014-01-20 21:10:12 -05:00
|
|
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_inclusive)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-10 15:56:41 -05:00
|
|
|
endfunction " }}}
|
2014-01-13 10:57:02 -05:00
|
|
|
function! EasyMotion#T(num_strokes, visualmode, direction) " {{{
|
2014-01-20 21:10:12 -05:00
|
|
|
if a:direction == 1
|
|
|
|
let is_inclusive = 0
|
|
|
|
else
|
2014-01-21 03:22:27 -05:00
|
|
|
" Note: Handle bi-direction later because 't' motion is inclusive but
|
|
|
|
" 'T' motion is exclusive
|
2014-01-20 21:10:12 -05:00
|
|
|
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
|
|
|
|
endif
|
|
|
|
let s:flag.find_bd = a:direction == 2 ? 1 : 0
|
2014-01-22 21:47:31 -05:00
|
|
|
let re = s:findMotion(a:num_strokes, a:direction)
|
2014-01-17 05:39:06 -05:00
|
|
|
if s:handleEmpty(re, a:visualmode) | return | endif
|
2014-01-20 21:10:12 -05:00
|
|
|
if a:direction == 2
|
|
|
|
let s:flag.bd_t = 1
|
|
|
|
elseif a:direction == 1
|
2014-02-17 23:56:21 -05:00
|
|
|
let re = s:convert_t_regexp(re, 1) " backward
|
2014-01-20 21:10:12 -05:00
|
|
|
else
|
2014-02-17 23:56:21 -05:00
|
|
|
let re = s:convert_t_regexp(re, 0) " forward
|
2014-01-20 21:10:12 -05:00
|
|
|
endif
|
|
|
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_inclusive)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
" -- Word Motion -------------------------
|
|
|
|
function! EasyMotion#WB(visualmode, direction) " {{{
|
2014-01-20 21:10:12 -05:00
|
|
|
"FIXME: inconsistent with default vim motion
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
function! EasyMotion#WBW(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
call s:EasyMotion('\(\(^\|\s\)\@<=\S\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
2014-02-17 22:02:37 -05:00
|
|
|
function! EasyMotion#WBK(visualmode, direction) " {{{
|
|
|
|
" vim's iskeyword style word motion
|
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
call s:EasyMotion('\(\(\<\|\>\|\s\)\@<=\S\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
|
|
|
return s:EasyMotion_is_cancelled
|
|
|
|
endfunction " }}}
|
2014-01-07 03:02:16 -05:00
|
|
|
function! EasyMotion#E(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
2014-01-20 21:10:12 -05:00
|
|
|
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
|
|
|
|
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_inclusive)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
function! EasyMotion#EW(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
2014-01-20 21:10:12 -05:00
|
|
|
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
|
|
|
|
call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_inclusive)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
2014-02-17 22:02:37 -05:00
|
|
|
function! EasyMotion#EK(visualmode, direction) " {{{
|
|
|
|
" vim's iskeyword style word motion
|
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
|
|
|
|
call s:EasyMotion('\(\S\(\>\|\<\|\s\)\@=\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_inclusive)
|
|
|
|
return s:EasyMotion_is_cancelled
|
|
|
|
endfunction " }}}
|
2014-01-07 03:02:16 -05:00
|
|
|
" -- JK Motion ---------------------------
|
|
|
|
function! EasyMotion#JK(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
"FIXME: support exclusive
|
|
|
|
if g:EasyMotion_startofline
|
|
|
|
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
|
|
|
else
|
|
|
|
let prev_column = getpos('.')[2] - 1
|
|
|
|
call s:EasyMotion('^.\{,' . prev_column . '}\zs\(.\|$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
|
|
|
endif
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
2014-01-14 20:29:17 -05:00
|
|
|
function! EasyMotion#Sol(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-14 20:29:17 -05:00
|
|
|
endfunction " }}}
|
2014-01-13 20:00:06 -05:00
|
|
|
function! EasyMotion#Eol(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
2014-01-14 19:11:22 -05:00
|
|
|
call s:EasyMotion('\(\w\|\s*\zs\|.\|^\)$', a:direction, a:visualmode ? visualmode() : '', '')
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-13 20:00:06 -05:00
|
|
|
endfunction " }}}
|
2014-01-07 03:02:16 -05:00
|
|
|
" -- Search Motion -----------------------
|
|
|
|
function! EasyMotion#Search(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
call s:EasyMotion(@/, a:direction, a:visualmode ? visualmode() : '', 0)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
" -- JumpToAnywhere Motion ---------------
|
|
|
|
function! EasyMotion#JumpToAnywhere(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
call s:EasyMotion( g:EasyMotion_re_anywhere, a:direction, a:visualmode ? visualmode() : '', 0)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
" -- Line Motion -------------------------
|
2014-01-13 10:57:02 -05:00
|
|
|
function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:flag.within_line = 1
|
2014-01-22 01:14:40 -05:00
|
|
|
call EasyMotion#S(a:num_strokes, a:visualmode, a:direction)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
2014-01-13 10:57:02 -05:00
|
|
|
function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:flag.within_line = 1
|
2014-01-22 01:14:40 -05:00
|
|
|
call EasyMotion#T(a:num_strokes, a:visualmode, a:direction)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-08 23:45:32 -05:00
|
|
|
endfunction " }}}
|
|
|
|
function! EasyMotion#WBL(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:flag.within_line = 1
|
2014-02-17 23:54:44 -05:00
|
|
|
call EasyMotion#WBK(a:visualmode, a:direction)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
function! EasyMotion#EL(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:flag.within_line = 1
|
2014-02-17 23:54:44 -05:00
|
|
|
call EasyMotion#EK(a:visualmode, a:direction)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
function! EasyMotion#LineAnywhere(visualmode, direction) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:flag.within_line = 1
|
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
|
|
|
let re = g:EasyMotion_re_line_anywhere
|
|
|
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', 0)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
" -- User Motion -------------------------
|
2014-01-22 02:23:24 -05:00
|
|
|
function! EasyMotion#User(pattern, visualmode, direction, inclusive) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
2014-01-22 02:23:24 -05:00
|
|
|
let is_inclusive = mode(1) ==# 'no' ? a:inclusive : 0
|
|
|
|
let re = a:pattern
|
|
|
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_inclusive)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
2014-01-08 23:52:07 -05:00
|
|
|
" -- Repeat Motion -----------------------
|
2014-01-13 10:57:02 -05:00
|
|
|
function! EasyMotion#Repeat(visualmode) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
" Repeat previous motion with previous targets
|
|
|
|
if s:previous ==# {}
|
|
|
|
call s:Message("Previous targets doesn't exist")
|
2014-01-22 00:08:48 -05:00
|
|
|
let s:EasyMotion_is_cancelled = 1
|
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
let re = s:previous.regexp
|
|
|
|
let direction = s:previous.direction
|
|
|
|
let s:flag.within_line = s:previous.line_flag
|
2014-01-21 03:22:27 -05:00
|
|
|
let s:flag.bd_t = s:previous.bd_t_flag
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
2014-01-21 03:22:27 -05:00
|
|
|
" FIXME: is_inclusive value is inappropriate but handling this value is
|
2014-01-22 01:14:40 -05:00
|
|
|
" difficult and priorities is low because this motion maybe used usually
|
2014-01-21 03:22:27 -05:00
|
|
|
" as a 'normal' motion.
|
2014-01-20 21:10:12 -05:00
|
|
|
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
|
2014-01-17 03:39:26 -05:00
|
|
|
|
2014-01-20 21:10:12 -05:00
|
|
|
call s:EasyMotion(re, direction, a:visualmode ? visualmode() : '', is_inclusive)
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-08 23:52:07 -05:00
|
|
|
endfunction " }}}
|
2014-01-15 23:36:36 -05:00
|
|
|
function! EasyMotion#DotRepeat(visualmode) " {{{
|
2014-01-21 03:22:27 -05:00
|
|
|
" Repeat previous '.' motion with previous targets and operator
|
2014-01-19 07:12:17 -05:00
|
|
|
if s:dot_repeat ==# {}
|
2014-01-17 03:39:26 -05:00
|
|
|
call s:Message("Previous motion doesn't exist")
|
2014-01-22 00:08:48 -05:00
|
|
|
let s:EasyMotion_is_cancelled = 1
|
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
|
2014-01-19 07:12:17 -05:00
|
|
|
let re = s:dot_repeat.regexp
|
|
|
|
let direction = s:dot_repeat.direction
|
2014-01-20 21:10:12 -05:00
|
|
|
let is_inclusive = s:dot_repeat.is_inclusive
|
2014-01-19 07:12:17 -05:00
|
|
|
let s:flag.within_line = s:dot_repeat.line_flag
|
2014-01-21 03:22:27 -05:00
|
|
|
let s:flag.bd_t = s:dot_repeat.bd_t_flag
|
2014-01-19 07:12:17 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:current.is_operator = 1
|
|
|
|
for cnt in range(v:count1)
|
2014-01-17 11:02:37 -05:00
|
|
|
let s:flag.dot_repeat = 1 " s:EasyMotion() always call reset
|
2014-01-20 21:10:12 -05:00
|
|
|
silent call s:EasyMotion(re, direction, 0, is_inclusive)
|
2014-01-17 03:39:26 -05:00
|
|
|
endfor
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-15 23:36:36 -05:00
|
|
|
endfunction " }}}
|
2014-01-16 09:18:56 -05:00
|
|
|
function! EasyMotion#NextPrevious(visualmode, direction) " {{{
|
2014-01-21 03:22:27 -05:00
|
|
|
" Move next/previous destination using previous motion regexp
|
2014-01-17 03:39:26 -05:00
|
|
|
if s:previous ==# {}
|
|
|
|
call s:Message("Previous targets doesn't exist")
|
2014-01-22 00:08:48 -05:00
|
|
|
let s:EasyMotion_is_cancelled = 1
|
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
let re = s:previous.regexp
|
|
|
|
let search_direction = (a:direction >= 1 ? 'b' : '')
|
|
|
|
|
2014-01-20 16:28:04 -05:00
|
|
|
if g:EasyMotion_move_highlight
|
|
|
|
call EasyMotion#highlight#attach_autocmd()
|
2014-02-04 03:30:11 -05:00
|
|
|
call EasyMotion#highlight#add_highlight(re, g:EasyMotion_hl_move)
|
2014-01-20 16:28:04 -05:00
|
|
|
endif
|
2014-01-19 11:28:48 -05:00
|
|
|
|
|
|
|
if ! empty(a:visualmode)
|
|
|
|
" FIXME: blink highlight
|
|
|
|
silent exec 'normal! gv'
|
|
|
|
endif
|
2014-01-17 03:39:26 -05:00
|
|
|
for i in range(v:count1)
|
2014-01-21 03:22:27 -05:00
|
|
|
" Do not treat this motion as 'jump' motion
|
|
|
|
keepjumps call searchpos(re, search_direction)
|
2014-01-17 03:39:26 -05:00
|
|
|
endfor
|
|
|
|
call EasyMotion#reset()
|
2014-01-20 00:33:58 -05:00
|
|
|
" -- Activate EasyMotion ----------------- {{{
|
|
|
|
let s:EasyMotion_is_active = 1
|
|
|
|
call EasyMotion#attach_active_autocmd() "}}}
|
2014-01-22 00:08:48 -05:00
|
|
|
return s:EasyMotion_is_cancelled
|
2014-01-16 09:18:56 -05:00
|
|
|
endfunction " }}}
|
2011-11-07 08:33:20 -05:00
|
|
|
" }}}
|
2014-01-17 12:46:48 -05:00
|
|
|
" Helper Functions: {{{
|
2014-01-07 03:02:16 -05:00
|
|
|
" -- Message -----------------------------
|
|
|
|
function! s:Message(message) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
echo 'EasyMotion: ' . a:message
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
function! s:Prompt(message) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
echohl Question
|
|
|
|
echo a:message . ': '
|
|
|
|
echohl None
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
" -- Save & Restore values ---------------
|
|
|
|
function! s:VarReset(var, ...) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
if ! exists('s:var_reset')
|
|
|
|
let s:var_reset = {}
|
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
if a:0 == 0 && has_key(s:var_reset, a:var)
|
|
|
|
" Reset var to original value
|
|
|
|
" setbufbar( or bufname): '' or '%' can be used for the current buffer
|
|
|
|
call setbufvar("", a:var, s:var_reset[a:var])
|
|
|
|
elseif a:0 == 1
|
|
|
|
" Save original value and set new var value
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
let new_value = a:0 == 1 ? a:1 : ''
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Store original value
|
|
|
|
let s:var_reset[a:var] = getbufvar("", a:var)
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Set new var value
|
|
|
|
call setbufvar("", a:var, new_value)
|
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
function! s:SaveValue() "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
call s:VarReset('&scrolloff', 0)
|
|
|
|
call s:VarReset('&modified', 0)
|
|
|
|
call s:VarReset('&modifiable', 1)
|
|
|
|
call s:VarReset('&readonly', 0)
|
|
|
|
call s:VarReset('&spell', 0)
|
|
|
|
call s:VarReset('&virtualedit', '')
|
|
|
|
call s:VarReset('&foldmethod', 'manual')
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
|
|
|
function! s:RestoreValue() "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
call s:VarReset('&scrolloff')
|
|
|
|
call s:VarReset('&modified')
|
|
|
|
call s:VarReset('&modifiable')
|
|
|
|
call s:VarReset('&readonly')
|
|
|
|
call s:VarReset('&spell')
|
|
|
|
call s:VarReset('&virtualedit')
|
|
|
|
call s:VarReset('&foldmethod')
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
2014-02-06 20:25:43 -05:00
|
|
|
function! s:turn_off_hl_error() "{{{
|
2014-02-11 23:30:08 -05:00
|
|
|
let s:error_hl = EasyMotion#highlight#capture('Error')
|
|
|
|
call EasyMotion#highlight#turn_off(s:error_hl)
|
|
|
|
let s:matchparen_hl = EasyMotion#highlight#capture('MatchParen')
|
|
|
|
call EasyMotion#highlight#turn_off(s:matchparen_hl)
|
|
|
|
endfunction "}}}
|
|
|
|
function! s:turn_on_hl_error() "{{{
|
|
|
|
if exists('s:error_hl')
|
|
|
|
call EasyMotion#highlight#turn_on(s:error_hl)
|
|
|
|
unlet s:error_hl
|
2014-02-06 20:25:43 -05:00
|
|
|
endif
|
2014-02-11 23:30:08 -05:00
|
|
|
|
|
|
|
if exists('s:matchparen_hl')
|
|
|
|
call EasyMotion#highlight#turn_on(s:matchparen_hl)
|
|
|
|
unlet s:matchparen_hl
|
2014-02-06 20:25:43 -05:00
|
|
|
endif
|
|
|
|
endfunction "}}}
|
2014-01-07 03:02:16 -05:00
|
|
|
" -- Draw --------------------------------
|
|
|
|
function! s:SetLines(lines, key) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
for [line_num, line] in a:lines
|
|
|
|
call setline(line_num, line[a:key])
|
|
|
|
endfor
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
" -- Get characters from user input ------
|
|
|
|
function! s:GetChar() " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let char = getchar()
|
|
|
|
if char == 27
|
|
|
|
" Escape key pressed
|
|
|
|
redraw
|
|
|
|
call s:Message('Cancelled')
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
return nr2char(char)
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
" -- Find Motion Helper ------------------
|
2014-01-22 21:47:31 -05:00
|
|
|
function! s:findMotion(num_strokes, direction) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
" Find Motion: S,F,T
|
2014-01-17 05:39:06 -05:00
|
|
|
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
|
2014-01-22 21:47:31 -05:00
|
|
|
" store cursor pos because 'n' key find motion could be jump to offscreen
|
|
|
|
let s:current.original_position = [line('.'), col('.')]
|
2014-02-06 08:12:52 -05:00
|
|
|
let s:current.is_search = a:num_strokes == -1 ? 1: 0
|
|
|
|
let s:flag.regexp = a:num_strokes == -1 ? 1 : 0 " TODO: remove?
|
2013-12-29 00:29:05 -05:00
|
|
|
|
2014-01-22 21:41:43 -05:00
|
|
|
if g:EasyMotion_add_search_history && a:num_strokes == -1
|
|
|
|
let s:previous['input'] = @/
|
|
|
|
else
|
|
|
|
let s:previous['input'] = get(s:previous, 'input', '')
|
|
|
|
endif
|
2014-01-22 21:47:31 -05:00
|
|
|
let input = EasyMotion#command_line#GetInput(
|
|
|
|
\ a:num_strokes, s:previous.input, a:direction)
|
2014-01-17 05:39:06 -05:00
|
|
|
let s:previous['input'] = input
|
|
|
|
|
|
|
|
" Check that we have an input char
|
|
|
|
if empty(input)
|
2014-01-30 01:31:25 -05:00
|
|
|
return ''
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 05:39:06 -05:00
|
|
|
let re = s:convertRegep(input)
|
2014-01-22 21:41:43 -05:00
|
|
|
|
|
|
|
if g:EasyMotion_add_search_history && a:num_strokes == -1
|
2014-02-10 11:57:50 -05:00
|
|
|
let history_re = substitute(re, '\\c\|\\C', '', '')
|
|
|
|
let @/ = history_re "For textobject: 'gn'
|
|
|
|
call histadd('search', history_re)
|
2014-01-22 21:41:43 -05:00
|
|
|
endif
|
|
|
|
|
2014-01-17 05:39:06 -05:00
|
|
|
return re
|
|
|
|
endfunction "}}}
|
|
|
|
function! s:convertRegep(input) "{{{
|
2014-01-21 03:22:27 -05:00
|
|
|
" 1. regexp
|
|
|
|
" 2. migemo
|
|
|
|
" 3. smartsign
|
|
|
|
" 4. smartcase
|
2014-01-17 06:59:41 -05:00
|
|
|
let re = s:should_use_regexp() ? a:input : escape(a:input, '.$^~\[]')
|
2014-01-17 05:39:06 -05:00
|
|
|
|
2014-01-27 07:42:55 -05:00
|
|
|
" Convert space to match only start of spaces
|
2014-01-27 07:47:10 -05:00
|
|
|
if re ==# ' '
|
2014-01-27 07:42:55 -05:00
|
|
|
let re = '\s\+'
|
|
|
|
endif
|
|
|
|
|
2014-01-17 05:39:06 -05:00
|
|
|
if s:should_use_migemo(a:input)
|
|
|
|
let re = s:convertMigemo(re)
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-10 07:33:17 -05:00
|
|
|
|
2014-01-17 05:39:06 -05:00
|
|
|
if s:should_use_smartsign(a:input)
|
|
|
|
let re = s:convertSmartsign(re, a:input)
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-02-06 08:12:52 -05:00
|
|
|
let case_flag = EasyMotion#helper#should_case_sensitive(
|
|
|
|
\ a:input, s:current.is_search) ? '\c' : '\C'
|
2014-01-25 01:03:01 -05:00
|
|
|
let re = case_flag . re
|
2014-01-17 03:39:26 -05:00
|
|
|
return re
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
|
|
|
function! s:convertMigemo(re) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let re = a:re
|
|
|
|
|
|
|
|
if len(re) > 1
|
|
|
|
" System cmigemo
|
|
|
|
return EasyMotion#cmigemo#getMigemoPattern(re)
|
|
|
|
endif
|
|
|
|
|
2014-01-23 08:56:58 -05:00
|
|
|
" EasyMotion migemo one key dict
|
2014-01-17 03:39:26 -05:00
|
|
|
if ! has_key(s:migemo_dicts, &l:encoding)
|
|
|
|
let s:migemo_dicts[&l:encoding] = EasyMotion#helper#load_migemo_dict()
|
|
|
|
endif
|
|
|
|
if re =~# '^\a$'
|
|
|
|
let re = get(s:migemo_dicts[&l:encoding], re, a:re)
|
|
|
|
endif
|
|
|
|
return re
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
2014-01-17 05:39:06 -05:00
|
|
|
function! s:convertSmartsign(re, char) "{{{
|
|
|
|
let smart_dict = s:load_smart_dict()
|
|
|
|
let upper_sign = escape(get(smart_dict, a:char, ''), '.$^~')
|
|
|
|
if upper_sign ==# ''
|
|
|
|
return a:re
|
|
|
|
else
|
|
|
|
let re = a:re . '\|' . upper_sign
|
|
|
|
return re
|
|
|
|
endif
|
|
|
|
endfunction "}}}
|
2014-01-07 03:02:16 -05:00
|
|
|
function! s:convertSmartcase(re, char) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let re = a:re
|
|
|
|
if a:char =~# '\U' "nonuppercase
|
|
|
|
return '\c' . re
|
|
|
|
else "uppercase
|
|
|
|
return '\C' . re
|
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
2014-01-17 06:59:41 -05:00
|
|
|
function! s:should_use_regexp() "{{{
|
|
|
|
return g:EasyMotion_use_regexp == 1 && s:flag.regexp == 1
|
|
|
|
endfunction "}}}
|
2014-01-17 05:39:06 -05:00
|
|
|
function! s:should_use_migemo(char) "{{{
|
|
|
|
if ! g:EasyMotion_use_migemo || match(a:char, '\A') != -1
|
|
|
|
return 0
|
|
|
|
endif
|
|
|
|
|
2014-01-21 03:22:27 -05:00
|
|
|
" TODO: use direction to improve
|
2014-01-17 05:39:06 -05:00
|
|
|
if s:flag.within_line == 1
|
|
|
|
let first_line = line('.')
|
|
|
|
let end_line = line('.')
|
2014-01-17 03:39:26 -05:00
|
|
|
else
|
2014-01-17 05:39:06 -05:00
|
|
|
let first_line = line('w0')
|
|
|
|
let end_line = line('w$')
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-17 05:39:06 -05:00
|
|
|
|
|
|
|
|
2014-01-21 03:22:27 -05:00
|
|
|
" Skip folded line and check if text include multibyte haracters
|
2014-01-17 05:39:06 -05:00
|
|
|
for line in range(first_line, end_line)
|
2014-01-26 03:25:11 -05:00
|
|
|
if EasyMotion#helper#is_folded(line)
|
2014-01-17 05:39:06 -05:00
|
|
|
continue
|
|
|
|
endif
|
|
|
|
|
|
|
|
if EasyMotion#helper#include_multibyte_char(getline(line)) == 1
|
|
|
|
return 1
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return 0
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
2014-01-17 05:39:06 -05:00
|
|
|
function! s:should_use_smartsign(char) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
if (exists('g:EasyMotion_use_smartsign_us') ||
|
|
|
|
\ exists('g:EasyMotion_use_smartsign_jp')) &&
|
2014-01-17 05:39:06 -05:00
|
|
|
\ match(a:char, '\A') != -1
|
2014-01-17 03:39:26 -05:00
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
2014-02-17 23:56:21 -05:00
|
|
|
function! s:convert_t_regexp(re, direction)
|
|
|
|
if a:direction == 0 "forward
|
|
|
|
return '\_.\ze\('.a:re.'\)'
|
|
|
|
elseif a:direction == 1 "backward
|
|
|
|
return '\('.a:re.'\)\@<=\_.'
|
|
|
|
endif
|
|
|
|
endfunction
|
2014-02-05 15:11:06 -05:00
|
|
|
|
2014-01-17 05:39:06 -05:00
|
|
|
function! s:handleEmpty(input, visualmode) "{{{
|
|
|
|
" if empty, reselect and return 1
|
|
|
|
if empty(a:input)
|
|
|
|
if ! empty(a:visualmode)
|
|
|
|
silent exec 'normal! gv'
|
|
|
|
endif
|
2014-01-22 00:08:48 -05:00
|
|
|
let s:EasyMotion_is_cancelled = 1 " Cancel
|
2014-01-17 05:39:06 -05:00
|
|
|
return 1
|
|
|
|
endif
|
|
|
|
return 0
|
|
|
|
endfunction "}}}
|
2014-01-07 03:02:16 -05:00
|
|
|
function! s:load_smart_dict() "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
if exists('g:EasyMotion_use_smartsign_us')
|
|
|
|
return g:EasyMotion#sticky_table#us
|
|
|
|
elseif exists('g:EasyMotion_use_smartsign_jp')
|
|
|
|
return g:EasyMotion#sticky_table#jp
|
|
|
|
else
|
2014-01-21 03:22:27 -05:00
|
|
|
return {}
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
2014-01-08 16:27:37 -05:00
|
|
|
" -- Handle Visual Mode ------------------
|
2014-01-08 15:07:17 -05:00
|
|
|
function! s:GetVisualStartPosition(c_pos, v_start, v_end, search_direction) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let vmode = mode(1)
|
2014-02-06 12:17:56 -05:00
|
|
|
if vmode !~# "^[Vv\<C-v>]"
|
2014-01-17 03:39:26 -05:00
|
|
|
throw 'Unkown visual mode:'.vmode
|
|
|
|
endif
|
|
|
|
|
|
|
|
if vmode ==# 'V' "line-wise Visual
|
|
|
|
" Line-wise Visual {{{
|
|
|
|
if a:v_start[0] == a:v_end[0]
|
|
|
|
if a:search_direction == ''
|
|
|
|
return a:v_start
|
|
|
|
elseif a:search_direction == 'b'
|
|
|
|
return a:v_end
|
|
|
|
else
|
|
|
|
throw 'Unkown search_direction'
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
if a:c_pos[0] == a:v_start[0]
|
|
|
|
return a:v_end
|
|
|
|
elseif a:c_pos[0] == a:v_end[0]
|
|
|
|
return a:v_start
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
else
|
|
|
|
" Character-wise or Block-wise Visual"{{{
|
|
|
|
if a:c_pos == a:v_start
|
|
|
|
return a:v_end
|
|
|
|
elseif a:c_pos == a:v_end
|
|
|
|
return a:v_start
|
|
|
|
endif
|
|
|
|
|
|
|
|
" virtualedit
|
|
|
|
if a:c_pos[0] == a:v_start[0]
|
|
|
|
return a:v_end
|
|
|
|
elseif a:c_pos[0] == a:v_end[0]
|
|
|
|
return a:v_start
|
2014-01-22 21:47:31 -05:00
|
|
|
elseif EasyMotion#helper#is_greater_coords(a:c_pos, a:v_start) == 1
|
|
|
|
return a:v_end
|
2014-01-17 03:39:26 -05:00
|
|
|
else
|
2014-01-22 21:47:31 -05:00
|
|
|
return a:v_start
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
2014-01-08 16:27:37 -05:00
|
|
|
" -- Others ------------------------------
|
2014-01-08 13:01:00 -05:00
|
|
|
function! s:is_cmdwin() "{{{
|
|
|
|
return bufname('%') ==# '[Command Line]'
|
|
|
|
endfunction "}}}
|
2014-01-17 05:39:06 -05:00
|
|
|
function! s:should_use_wundo() "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
" wundu cannot use in command-line window and
|
|
|
|
" unless undolist is not empty
|
|
|
|
return ! s:is_cmdwin() && undotree().seq_last != 0
|
2014-01-08 13:01:00 -05:00
|
|
|
endfunction "}}}
|
2014-01-21 03:22:27 -05:00
|
|
|
function! EasyMotion#attach_active_autocmd() "{{{
|
|
|
|
" Reference: https://github.com/justinmk/vim-sneak
|
|
|
|
augroup plugin-easymotion-active
|
|
|
|
autocmd!
|
|
|
|
autocmd InsertEnter,WinLeave,BufLeave <buffer>
|
|
|
|
\ let s:EasyMotion_is_active = 0
|
|
|
|
\ | autocmd! plugin-easymotion-active * <buffer>
|
|
|
|
autocmd CursorMoved <buffer>
|
|
|
|
\ autocmd plugin-easymotion-active CursorMoved <buffer>
|
|
|
|
\ let s:EasyMotion_is_active = 0
|
|
|
|
\ | autocmd! plugin-easymotion-active * <buffer>
|
|
|
|
augroup END
|
|
|
|
endfunction "}}}
|
|
|
|
function! EasyMotion#is_active() "{{{
|
|
|
|
return s:EasyMotion_is_active
|
|
|
|
endfunction "}}}
|
2014-01-22 21:38:00 -05:00
|
|
|
function! EasyMotion#activate(is_visual) "{{{
|
|
|
|
let s:EasyMotion_is_active = 1
|
|
|
|
call EasyMotion#attach_active_autocmd()
|
2014-02-04 03:30:11 -05:00
|
|
|
call EasyMotion#highlight#add_highlight(s:previous.regexp,
|
|
|
|
\ g:EasyMotion_hl_move)
|
2014-01-22 21:38:00 -05:00
|
|
|
call EasyMotion#highlight#attach_autocmd()
|
|
|
|
if a:is_visual == 1
|
|
|
|
normal! gv
|
|
|
|
endif
|
|
|
|
endfunction "}}}
|
2014-01-08 16:27:37 -05:00
|
|
|
"}}}
|
2014-01-17 12:46:48 -05:00
|
|
|
" Grouping Algorithms: {{{
|
2014-01-07 03:02:16 -05:00
|
|
|
let s:grouping_algorithms = {
|
|
|
|
\ 1: 'SCTree'
|
|
|
|
\ , 2: 'Original'
|
|
|
|
\ }
|
|
|
|
" -- Single-key/closest target priority tree {{{
|
|
|
|
" This algorithm tries to assign one-key jumps to all the targets closest to the cursor.
|
|
|
|
" It works recursively and will work correctly with as few keys as two.
|
|
|
|
function! s:GroupingAlgorithmSCTree(targets, keys) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
" Prepare variables for working
|
|
|
|
let targets_len = len(a:targets)
|
|
|
|
let keys_len = len(a:keys)
|
|
|
|
|
|
|
|
let groups = {}
|
|
|
|
|
|
|
|
let keys = reverse(copy(a:keys))
|
|
|
|
|
|
|
|
" Semi-recursively count targets {{{
|
|
|
|
" We need to know exactly how many child nodes (targets) this branch will have
|
|
|
|
" in order to pass the correct amount of targets to the recursive function.
|
|
|
|
|
|
|
|
" Prepare sorted target count list {{{
|
|
|
|
" This is horrible, I know. But dicts aren't sorted in vim, so we need to
|
|
|
|
" work around that. That is done by having one sorted list with key counts,
|
|
|
|
" and a dict which connects the key with the keys_count list.
|
|
|
|
|
|
|
|
let keys_count = []
|
|
|
|
let keys_count_keys = {}
|
|
|
|
|
|
|
|
let i = 0
|
|
|
|
for key in keys
|
|
|
|
call add(keys_count, 0)
|
|
|
|
|
|
|
|
let keys_count_keys[key] = i
|
|
|
|
|
|
|
|
let i += 1
|
|
|
|
endfor
|
|
|
|
" }}}
|
|
|
|
|
|
|
|
let targets_left = targets_len
|
|
|
|
let level = 0
|
|
|
|
let i = 0
|
|
|
|
|
|
|
|
while targets_left > 0
|
|
|
|
" Calculate the amount of child nodes based on the current level
|
|
|
|
let childs_len = (level == 0 ? 1 : (keys_len - 1) )
|
|
|
|
|
|
|
|
for key in keys
|
|
|
|
" Add child node count to the keys_count array
|
|
|
|
let keys_count[keys_count_keys[key]] += childs_len
|
|
|
|
|
|
|
|
" Subtract the child node count
|
|
|
|
let targets_left -= childs_len
|
|
|
|
|
|
|
|
if targets_left <= 0
|
|
|
|
" Subtract the targets left if we added too many too
|
|
|
|
" many child nodes to the key count
|
|
|
|
let keys_count[keys_count_keys[key]] += targets_left
|
|
|
|
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
|
|
|
|
let i += 1
|
|
|
|
endfor
|
|
|
|
|
|
|
|
let level += 1
|
|
|
|
endwhile
|
|
|
|
" }}}
|
|
|
|
" Create group tree {{{
|
|
|
|
let i = 0
|
|
|
|
let key = 0
|
|
|
|
|
|
|
|
call reverse(keys_count)
|
|
|
|
|
|
|
|
for key_count in keys_count
|
|
|
|
if key_count > 1
|
|
|
|
" We need to create a subgroup
|
|
|
|
" Recurse one level deeper
|
|
|
|
let groups[a:keys[key]] = s:GroupingAlgorithmSCTree(a:targets[i : i + key_count - 1], a:keys)
|
|
|
|
elseif key_count == 1
|
|
|
|
" Assign single target key
|
|
|
|
let groups[a:keys[key]] = a:targets[i]
|
|
|
|
else
|
|
|
|
" No target
|
|
|
|
continue
|
|
|
|
endif
|
|
|
|
|
|
|
|
let key += 1
|
|
|
|
let i += key_count
|
|
|
|
endfor
|
|
|
|
" }}}
|
|
|
|
|
|
|
|
" Finally!
|
|
|
|
return groups
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
|
|
|
" }}}
|
|
|
|
" -- Original ---------------------------- {{{
|
|
|
|
function! s:GroupingAlgorithmOriginal(targets, keys)
|
2014-01-17 03:39:26 -05:00
|
|
|
" Split targets into groups (1 level)
|
|
|
|
let targets_len = len(a:targets)
|
|
|
|
let keys_len = len(a:keys)
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
let groups = {}
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
let i = 0
|
|
|
|
let root_group = 0
|
|
|
|
try
|
|
|
|
while root_group < targets_len
|
|
|
|
let groups[a:keys[root_group]] = {}
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
for key in a:keys
|
|
|
|
let groups[a:keys[root_group]][key] = a:targets[i]
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
let i += 1
|
|
|
|
endfor
|
2011-11-07 08:33:20 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
let root_group += 1
|
|
|
|
endwhile
|
|
|
|
catch | endtry
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Flatten the group array
|
|
|
|
if len(groups) == 1
|
|
|
|
let groups = groups[a:keys[0]]
|
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
return groups
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction
|
2011-11-07 08:33:20 -05:00
|
|
|
" }}}
|
2013-06-03 17:24:44 -04:00
|
|
|
|
2014-01-07 03:02:16 -05:00
|
|
|
" -- Coord/key dictionary creation ------- {{{
|
|
|
|
function! s:CreateCoordKeyDict(groups, ...)
|
2014-01-17 03:39:26 -05:00
|
|
|
" Dict structure:
|
|
|
|
" 1,2 : a
|
|
|
|
" 2,3 : b
|
|
|
|
let sort_list = []
|
|
|
|
let coord_keys = {}
|
|
|
|
let group_key = a:0 == 1 ? a:1 : ''
|
|
|
|
|
|
|
|
for [key, item] in items(a:groups)
|
|
|
|
let key = group_key . key
|
|
|
|
"let key = ( ! empty(group_key) ? group_key : key)
|
|
|
|
|
|
|
|
if type(item) == 3 " List
|
|
|
|
" Destination coords
|
|
|
|
|
|
|
|
" The key needs to be zero-padded in order to
|
|
|
|
" sort correctly
|
|
|
|
let dict_key = printf('%05d,%05d', item[0], item[1])
|
|
|
|
let coord_keys[dict_key] = key
|
|
|
|
|
|
|
|
" We need a sorting list to loop correctly in
|
|
|
|
" PromptUser, dicts are unsorted
|
|
|
|
call add(sort_list, dict_key)
|
|
|
|
else
|
|
|
|
" Item is a dict (has children)
|
|
|
|
let coord_key_dict = s:CreateCoordKeyDict(item, key)
|
|
|
|
|
|
|
|
" Make sure to extend both the sort list and the
|
|
|
|
" coord key dict
|
|
|
|
call extend(sort_list, coord_key_dict[0])
|
|
|
|
call extend(coord_keys, coord_key_dict[1])
|
|
|
|
endif
|
|
|
|
|
|
|
|
unlet item
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return [sort_list, coord_keys]
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction
|
|
|
|
" }}}
|
|
|
|
" }}}
|
2014-01-17 12:46:48 -05:00
|
|
|
" Core Functions: {{{
|
2014-01-31 02:53:26 -05:00
|
|
|
function! s:PromptUser(groups) "{{{
|
2014-01-22 02:17:20 -05:00
|
|
|
" Recursive
|
2014-01-17 03:39:26 -05:00
|
|
|
let group_values = values(a:groups)
|
|
|
|
|
2014-01-17 12:46:48 -05:00
|
|
|
" -- If only one possible match, jump directly to it {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
if len(group_values) == 1
|
2014-01-22 02:17:20 -05:00
|
|
|
if mode(1) ==# 'no'
|
|
|
|
" Consider jump to first match
|
2014-02-10 02:32:01 -05:00
|
|
|
" NOTE: matchstr() handles multibyte characters.
|
|
|
|
let s:dot_repeat['target'] = matchstr(g:EasyMotion_keys, '^.')
|
2014-01-22 02:17:20 -05:00
|
|
|
endif
|
2014-01-17 03:39:26 -05:00
|
|
|
redraw
|
|
|
|
return group_values[0]
|
|
|
|
endif
|
|
|
|
" }}}
|
|
|
|
" -- Prepare marker lines ---------------- {{{
|
|
|
|
let lines = {}
|
|
|
|
|
|
|
|
let coord_key_dict = s:CreateCoordKeyDict(a:groups)
|
|
|
|
|
|
|
|
for dict_key in sort(coord_key_dict[0])
|
2014-02-19 13:43:44 -05:00
|
|
|
" NOTE: {{{
|
|
|
|
" let g:EasyMotion_keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
|
|
" Perform <Plug>(easymotion-w)
|
|
|
|
"
|
|
|
|
" lines[line_num]['orig']:
|
|
|
|
" Lorem ipsum dolor sit amet consectetur adipisicing
|
|
|
|
"
|
|
|
|
" {target_char}:
|
|
|
|
" {L}orem {i}psum {d}olor {s}it {a}met {c}onsectetur {a}dipisicing
|
|
|
|
"
|
|
|
|
" lines[line_num]['marker'], {marker_chars}:
|
|
|
|
" {A}orem {B}psum {C}olor {D}it {E}met {F}onsectetur {G}dipisicing
|
|
|
|
" 2-key-combo: {marker_chars} could be 1 or 2 chars like {AB}
|
|
|
|
"
|
|
|
|
" }}}
|
|
|
|
|
|
|
|
" Prepare original line and marker line {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let [line_num, col_num] = split(dict_key, ',')
|
|
|
|
|
|
|
|
let line_num = str2nr(line_num)
|
|
|
|
let col_num = str2nr(col_num)
|
|
|
|
if ! has_key(lines, line_num)
|
|
|
|
let current_line = getline(line_num)
|
2014-02-04 02:48:05 -05:00
|
|
|
let lines[line_num] = {
|
|
|
|
\ 'orig': current_line,
|
|
|
|
\ 'marker': current_line,
|
|
|
|
\ 'mb_compensation': 0,
|
|
|
|
\ }
|
2014-02-19 13:43:44 -05:00
|
|
|
" mb_compensation -> multibyte compensation
|
|
|
|
endif "}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
|
2014-02-19 13:43:44 -05:00
|
|
|
" Multibyt Compensation: {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
" Solve multibyte issues by matching the byte column
|
|
|
|
" number instead of the visual column
|
|
|
|
" Compensate for byte difference between marker
|
|
|
|
" character and target character
|
|
|
|
"
|
|
|
|
" This has to be done in order to match the correct
|
|
|
|
" column; \%c matches the byte column and not display
|
|
|
|
" column.
|
2014-02-19 13:43:44 -05:00
|
|
|
let col_num -= lines[line_num]['mb_compensation']
|
|
|
|
"}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
|
2014-02-19 13:43:44 -05:00
|
|
|
" Prepare marker characters {{{
|
|
|
|
let marker_chars = coord_key_dict[1][dict_key]
|
|
|
|
let marker_chars_len = EasyMotion#helper#strchars(marker_chars)
|
|
|
|
let marker_chars_first = matchstr(marker_chars, '^.')
|
|
|
|
let marker_chars_first_byte_len = strlen(marker_chars_first)
|
|
|
|
"}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
|
2014-02-19 13:43:44 -05:00
|
|
|
" Prepare targets characters {{{
|
|
|
|
let target_char = matchstr(lines[line_num]['orig'],
|
|
|
|
\ '\%' . col_num . 'c.')
|
|
|
|
let target_char_disp_len = strdisplaywidth(target_char)
|
|
|
|
let target_char_byte_len = strlen(target_char)
|
|
|
|
let target_line_byte_len = strlen(lines[line_num]['orig'])
|
|
|
|
"}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
|
2014-01-31 02:53:26 -05:00
|
|
|
if strlen(lines[line_num]['marker']) > 0
|
|
|
|
" Substitute marker character if line length > 0
|
2014-02-19 13:43:44 -05:00
|
|
|
let col_add = 0 " Column add byte length
|
|
|
|
" Disable two-key-combo feature?
|
2014-02-18 03:41:32 -05:00
|
|
|
let marker_max_length = g:EasyMotion_disable_two_key_combo == 1
|
|
|
|
\ ? 1 : 2
|
2014-02-19 13:43:44 -05:00
|
|
|
let marker_limit = min([marker_chars_len, marker_max_length])
|
|
|
|
for i in range(marker_limit)
|
2014-02-19 13:19:59 -05:00
|
|
|
if strlen(lines[line_num]['marker']) >= col_num + col_add
|
2014-01-31 02:53:26 -05:00
|
|
|
" Substitute marker character if line length > 0
|
2014-02-19 13:43:44 -05:00
|
|
|
if i == 0
|
2014-01-31 02:53:26 -05:00
|
|
|
let lines[line_num]['marker'] = substitute(
|
|
|
|
\ lines[line_num]['marker'],
|
2014-02-19 13:19:59 -05:00
|
|
|
\ '\%' . (col_num + col_add) . 'c.',
|
2014-02-19 13:43:44 -05:00
|
|
|
\ marker_chars_first
|
|
|
|
\ . repeat(' ', target_char_disp_len - 1),
|
2014-01-31 02:53:26 -05:00
|
|
|
\ '')
|
2014-01-17 03:39:26 -05:00
|
|
|
else
|
2014-01-31 02:53:26 -05:00
|
|
|
let lines[line_num]['marker'] = substitute(
|
|
|
|
\ lines[line_num]['marker'],
|
2014-02-19 13:19:59 -05:00
|
|
|
\ '\%' . (col_num + col_add) . 'c.',
|
2014-02-19 13:43:44 -05:00
|
|
|
\ matchstr(marker_chars, '^.\zs.'),
|
2014-01-31 02:53:26 -05:00
|
|
|
\ '')
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-31 02:53:26 -05:00
|
|
|
else
|
2014-02-19 13:19:59 -05:00
|
|
|
" EOL
|
2014-02-19 13:43:44 -05:00
|
|
|
let lines[line_num]['marker'] .= split(marker_chars, '\zs')[i]
|
2014-01-31 02:53:26 -05:00
|
|
|
endif
|
2014-02-19 13:43:44 -05:00
|
|
|
let col_add += marker_chars_first_byte_len
|
|
|
|
endfor
|
2014-01-31 02:53:26 -05:00
|
|
|
else
|
|
|
|
" Set the line to the marker character if the line is empty
|
2014-02-19 13:43:44 -05:00
|
|
|
let lines[line_num]['marker'] = marker_chars
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
|
2014-02-05 02:03:40 -05:00
|
|
|
" -- Highlight targets ------------------- {{{
|
2014-02-19 13:43:44 -05:00
|
|
|
if marker_chars_len == 1
|
2014-02-05 02:03:40 -05:00
|
|
|
call EasyMotion#highlight#add_highlight(
|
|
|
|
\ '\%' . line_num . 'l\%' . col_num . 'c',
|
|
|
|
\ g:EasyMotion_hl_group_target)
|
2014-01-31 02:53:26 -05:00
|
|
|
else
|
2014-02-05 02:03:40 -05:00
|
|
|
call EasyMotion#highlight#add_highlight(
|
|
|
|
\ '\%' . line_num . 'l\%' . col_num . 'c',
|
|
|
|
\ g:EasyMotion_hl2_first_group_target)
|
2014-02-18 10:46:36 -05:00
|
|
|
if g:EasyMotion_disable_two_key_combo != 1
|
2014-02-18 03:41:32 -05:00
|
|
|
call EasyMotion#highlight#add_highlight(
|
2014-02-19 13:43:44 -05:00
|
|
|
\ '\%' . line_num . 'l\%' . (col_num + marker_chars_first_byte_len) . 'c',
|
2014-02-18 03:41:32 -05:00
|
|
|
\ g:EasyMotion_hl2_second_group_target)
|
|
|
|
endif
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-02-05 02:03:40 -05:00
|
|
|
"}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
|
|
|
|
" Add marker/target length difference for multibyte
|
|
|
|
" compensation
|
2014-02-04 02:48:05 -05:00
|
|
|
let lines[line_num]['mb_compensation'] +=
|
|
|
|
\ (target_line_byte_len - strlen(lines[line_num]['marker']))
|
2014-01-17 03:39:26 -05:00
|
|
|
endfor
|
|
|
|
|
|
|
|
let lines_items = items(lines)
|
|
|
|
" }}}
|
|
|
|
|
|
|
|
" -- Put labels on targets & Get User Input & Restore all {{{
|
|
|
|
" Save undo tree {{{
|
|
|
|
let s:undo_file = tempname()
|
2014-01-17 05:39:06 -05:00
|
|
|
if s:should_use_wundo()
|
2014-01-17 03:39:26 -05:00
|
|
|
execute "wundo" s:undo_file
|
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
try
|
|
|
|
" Set lines with markers {{{
|
|
|
|
call s:SetLines(lines_items, 'marker')
|
|
|
|
redraw "}}}
|
|
|
|
|
|
|
|
" Get target character {{{
|
|
|
|
call s:Prompt('Target key')
|
|
|
|
let char = s:GetChar()
|
|
|
|
"}}}
|
|
|
|
|
|
|
|
" Convert uppercase {{{
|
|
|
|
if g:EasyMotion_use_upper == 1 && match(g:EasyMotion_keys, '\l') == -1
|
|
|
|
let char = toupper(char)
|
|
|
|
endif "}}}
|
|
|
|
|
2014-02-06 07:22:25 -05:00
|
|
|
" Jump first target when Enter or Space key is pressed "{{{
|
|
|
|
if (char ==# "\<CR>" && g:EasyMotion_enter_jump_first == 1) ||
|
|
|
|
\ (char ==# " " && g:EasyMotion_space_jump_first == 1)
|
2014-02-10 02:32:01 -05:00
|
|
|
" NOTE: matchstr() is multibyte aware.
|
|
|
|
let char = matchstr(g:EasyMotion_keys, '^.')
|
2014-01-17 03:39:26 -05:00
|
|
|
endif "}}}
|
|
|
|
|
|
|
|
" For dot repeat {{{
|
|
|
|
if mode(1) ==# 'no'
|
|
|
|
" Store previous target when operator pending mode
|
|
|
|
if s:current.dot_prompt_user_cnt == 0
|
|
|
|
" Store
|
2014-01-22 02:17:20 -05:00
|
|
|
let s:dot_repeat['target'] = char
|
2014-01-17 03:39:26 -05:00
|
|
|
else
|
|
|
|
" Append target chars
|
2014-01-22 02:17:20 -05:00
|
|
|
let s:dot_repeat['target'] .= char
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
endif "}}}
|
|
|
|
|
|
|
|
finally
|
|
|
|
" Restore original lines
|
|
|
|
call s:SetLines(lines_items, 'orig')
|
|
|
|
|
|
|
|
" Un-highlight targets {{{
|
2014-01-19 11:28:48 -05:00
|
|
|
call EasyMotion#highlight#delete_highlight(
|
|
|
|
\ g:EasyMotion_hl_group_target,
|
|
|
|
\ g:EasyMotion_hl2_first_group_target,
|
|
|
|
\ g:EasyMotion_hl2_second_group_target,
|
|
|
|
\ )
|
2014-01-17 03:39:26 -05:00
|
|
|
" }}}
|
|
|
|
|
|
|
|
" Restore undo tree {{{
|
2014-01-17 05:39:06 -05:00
|
|
|
if s:should_use_wundo() && filereadable(s:undo_file)
|
2014-01-17 03:39:26 -05:00
|
|
|
silent execute "rundo" s:undo_file
|
|
|
|
unlet s:undo_file
|
|
|
|
else
|
|
|
|
" Break undo history (undobreak)
|
|
|
|
let old_undolevels = &undolevels
|
|
|
|
set undolevels=-1
|
|
|
|
call setline('.', getline('.'))
|
|
|
|
let &undolevels = old_undolevels
|
|
|
|
unlet old_undolevels
|
|
|
|
" FIXME: Error occur by GundoToggle for undo number 2 is empty
|
|
|
|
call setline('.', getline('.'))
|
|
|
|
endif "}}}
|
|
|
|
|
|
|
|
redraw
|
|
|
|
endtry "}}}
|
|
|
|
|
|
|
|
" -- Check if we have an input char ------ {{{
|
|
|
|
if empty(char)
|
|
|
|
throw 'Cancelled'
|
|
|
|
endif
|
|
|
|
" }}}
|
|
|
|
" -- Check if the input char is valid ---- {{{
|
|
|
|
if ! has_key(a:groups, char)
|
|
|
|
throw 'Invalid target'
|
|
|
|
endif
|
|
|
|
" }}}
|
|
|
|
|
|
|
|
let target = a:groups[char]
|
|
|
|
|
|
|
|
if type(target) == 3
|
|
|
|
" Return target coordinates
|
|
|
|
return target
|
|
|
|
else
|
|
|
|
" Prompt for new target character
|
|
|
|
let s:current.dot_prompt_user_cnt += 1
|
2014-01-31 02:53:26 -05:00
|
|
|
return s:PromptUser(target)
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-15 23:36:36 -05:00
|
|
|
endfunction "}}}
|
|
|
|
function! s:DotPromptUser(groups) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
" Get char from previous target
|
2014-01-22 02:17:20 -05:00
|
|
|
let char = s:dot_repeat.target[s:current.dot_repeat_target_cnt]
|
2014-01-17 03:39:26 -05:00
|
|
|
" For dot repeat target chars
|
|
|
|
let s:current.dot_repeat_target_cnt += 1
|
|
|
|
|
|
|
|
let target = a:groups[char]
|
|
|
|
|
|
|
|
if type(target) == 3
|
|
|
|
" Return target coordinates
|
|
|
|
return target
|
|
|
|
else
|
|
|
|
" Prompt for new target character
|
2014-01-31 02:53:26 -05:00
|
|
|
return s:PromptUser(target)
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction "}}}
|
2014-01-31 02:53:26 -05:00
|
|
|
function! s:EasyMotion(regexp, direction, visualmode, is_inclusive) " {{{
|
2014-01-22 21:47:31 -05:00
|
|
|
" Store s:current original_position & cursor_position {{{
|
|
|
|
" current cursor pos.
|
|
|
|
let s:current.cursor_position = [line('.'), col('.')]
|
|
|
|
" original start position. This value could be changed later in visual
|
|
|
|
" mode
|
|
|
|
let s:current.original_position =
|
|
|
|
\ get(s:current, 'original_position', s:current.cursor_position)
|
|
|
|
"}}}
|
|
|
|
|
|
|
|
let win_first_line = line('w0') " visible first line num
|
|
|
|
let win_last_line = line('w$') " visible last line num
|
2014-01-17 03:39:26 -05:00
|
|
|
|
|
|
|
let targets = []
|
|
|
|
|
2014-01-22 21:47:31 -05:00
|
|
|
" Store info for Repeat motion {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
if s:flag.dot_repeat != 1
|
|
|
|
" Store Regular Expression
|
|
|
|
let s:previous['regexp'] = a:regexp
|
|
|
|
let s:previous['direction'] = a:direction
|
|
|
|
let s:previous['operator'] = v:operator
|
2014-01-21 03:22:27 -05:00
|
|
|
|
|
|
|
" Note: 'is_inclusive' value could be changed later when
|
|
|
|
" bi-directional find motion depend on 'true' direction the cursor
|
|
|
|
" will move.
|
|
|
|
let s:previous['is_inclusive'] = a:is_inclusive
|
|
|
|
|
|
|
|
" For special motion flag
|
|
|
|
let s:previous['line_flag'] = s:flag.within_line
|
|
|
|
let s:previous['bd_t_flag'] = s:flag.bd_t " bi-directional t motion
|
2014-01-22 21:47:31 -05:00
|
|
|
endif "}}}
|
|
|
|
|
2014-01-19 07:17:51 -05:00
|
|
|
" To avoid side effect of overwriting buffer for tpope/repeat
|
2014-01-21 03:22:27 -05:00
|
|
|
" store current b:changedtick. Use this value later
|
2014-01-19 07:17:51 -05:00
|
|
|
let s:current.changedtick = b:changedtick
|
2014-01-17 03:39:26 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
" -- Reset properties -------------------- {{{
|
|
|
|
" Save original value and set new value
|
|
|
|
call s:SaveValue()
|
2014-02-06 20:25:43 -05:00
|
|
|
call s:turn_off_hl_error()
|
2014-01-17 03:39:26 -05:00
|
|
|
" }}}
|
|
|
|
" Setup searchpos args {{{
|
|
|
|
let search_direction = (a:direction >= 1 ? 'b' : '')
|
|
|
|
let search_stopline = a:direction >= 1 ? win_first_line : win_last_line
|
|
|
|
|
|
|
|
if s:flag.within_line == 1
|
2014-01-22 21:47:31 -05:00
|
|
|
let search_stopline = s:current.original_position[0]
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
|
|
|
|
" Handle visual mode {{{
|
|
|
|
if ! empty(a:visualmode)
|
|
|
|
" Decide at where visual mode start {{{
|
|
|
|
normal! gv
|
|
|
|
let v_start = [line("'<"),col("'<")] " visual_start_position
|
|
|
|
let v_end = [line("'>"),col("'>")] " visual_end_position
|
|
|
|
|
2014-01-22 21:47:31 -05:00
|
|
|
let v_original_pos = s:GetVisualStartPosition(
|
|
|
|
\ s:current.cursor_position, v_start, v_end, search_direction)
|
2014-01-17 03:39:26 -05:00
|
|
|
"}}}
|
|
|
|
|
|
|
|
" Reselect visual text {{{
|
|
|
|
keepjumps call cursor(v_original_pos)
|
|
|
|
exec "normal! " . a:visualmode
|
2014-01-22 21:47:31 -05:00
|
|
|
keepjumps call cursor(s:current.cursor_position)
|
2014-01-17 03:39:26 -05:00
|
|
|
"}}}
|
2014-01-22 21:47:31 -05:00
|
|
|
" Update s:current.original_position
|
|
|
|
let s:current.original_position = v_original_pos " overwrite original start positio
|
|
|
|
endif "}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
|
2014-01-20 21:10:12 -05:00
|
|
|
" Handle bi-directional t motion {{{
|
|
|
|
if s:flag.bd_t == 1
|
2014-02-17 23:56:21 -05:00
|
|
|
let regexp = s:convert_t_regexp(a:regexp, 1) "backward
|
2014-01-20 21:10:12 -05:00
|
|
|
else
|
|
|
|
let regexp = a:regexp
|
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Construct match dict {{{
|
|
|
|
while 1
|
2014-01-21 03:22:27 -05:00
|
|
|
" Note: searchpos() has side effect which jump cursor position.
|
2014-01-17 03:39:26 -05:00
|
|
|
" You can disable this side effect by add 'n' flags,
|
2014-01-21 03:22:27 -05:00
|
|
|
" but in this case, it's better to allows jump side effect
|
|
|
|
" to gathering matched targets coordinates.
|
2014-01-31 02:53:26 -05:00
|
|
|
let pos = searchpos(regexp, search_direction, search_stopline)
|
2014-01-17 03:39:26 -05:00
|
|
|
|
|
|
|
" Reached end of search range
|
|
|
|
if pos == [0, 0]
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Skip folded lines {{{
|
2014-01-26 03:25:11 -05:00
|
|
|
if EasyMotion#helper#is_folded(pos[0])
|
2014-01-17 03:39:26 -05:00
|
|
|
if search_direction ==# 'b'
|
|
|
|
keepjumps call cursor(foldclosed(pos[0]-1), 0)
|
|
|
|
else
|
|
|
|
keepjumps call cursor(foldclosedend(pos[0]+1), 0)
|
|
|
|
endif
|
|
|
|
continue
|
|
|
|
endif "}}}
|
|
|
|
|
|
|
|
call add(targets, pos)
|
|
|
|
endwhile
|
|
|
|
"}}}
|
|
|
|
|
|
|
|
" Handle bidirection "{{{
|
2014-01-20 21:10:12 -05:00
|
|
|
" For bi-directional t motion {{{
|
|
|
|
if s:flag.bd_t == 1
|
2014-02-17 23:56:21 -05:00
|
|
|
let regexp = s:convert_t_regexp(a:regexp, 0) "forward
|
2014-01-20 21:10:12 -05:00
|
|
|
endif
|
|
|
|
"}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
" Reconstruct match dict
|
|
|
|
if a:direction == 2
|
|
|
|
" Forward
|
2014-01-21 03:22:27 -05:00
|
|
|
|
2014-01-22 21:47:31 -05:00
|
|
|
" Jump back cursor_position
|
|
|
|
keepjumps call cursor(s:current.cursor_position[0],
|
|
|
|
\ s:current.cursor_position[1])
|
2014-01-17 03:39:26 -05:00
|
|
|
|
|
|
|
let targets2 = []
|
|
|
|
if s:flag.within_line == 0
|
|
|
|
let search_stopline = win_last_line
|
|
|
|
else
|
2014-01-22 21:47:31 -05:00
|
|
|
let search_stopline = s:current.cursor_position[0]
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
while 1
|
2014-01-21 03:22:27 -05:00
|
|
|
" TODO: refactoring
|
2014-01-20 21:10:12 -05:00
|
|
|
let pos = searchpos(regexp, '', search_stopline)
|
2014-01-17 03:39:26 -05:00
|
|
|
" Reached end of search range
|
|
|
|
if pos == [0, 0]
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Skip folded lines {{{
|
2014-01-26 03:25:11 -05:00
|
|
|
if EasyMotion#helper#is_folded(pos[0])
|
2014-01-17 03:39:26 -05:00
|
|
|
" Always forward
|
|
|
|
keepjumps call cursor(foldclosedend(pos[0]+1), 0)
|
|
|
|
continue
|
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
|
|
|
|
call add(targets2, pos)
|
|
|
|
endwhile
|
|
|
|
" Merge match target dict"{{{
|
|
|
|
let t1 = 0 " backward
|
|
|
|
let t2 = 0 " forward
|
|
|
|
let targets3 = []
|
|
|
|
while t1 < len(targets) || t2 < len(targets2)
|
|
|
|
" Forward -> Backward -> F -> B -> ...
|
|
|
|
if t2 < len(targets2)
|
|
|
|
call add(targets3, targets2[t2])
|
|
|
|
let t2 += 1
|
|
|
|
endif
|
|
|
|
if t1 < len(targets)
|
|
|
|
call add(targets3, targets[t1])
|
|
|
|
let t1 += 1
|
|
|
|
endif
|
|
|
|
endwhile
|
|
|
|
let targets = targets3
|
|
|
|
"}}}
|
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
" Handle no match"{{{
|
|
|
|
let targets_len = len(targets)
|
|
|
|
if targets_len == 0
|
|
|
|
throw 'No matches'
|
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
|
2014-01-21 03:22:27 -05:00
|
|
|
" Attach specific key as marker to gathered matched coordinates
|
2014-01-17 03:39:26 -05:00
|
|
|
let GroupingFn = function('s:GroupingAlgorithm' . s:grouping_algorithms[g:EasyMotion_grouping])
|
|
|
|
let groups = GroupingFn(targets, split(g:EasyMotion_keys, '\zs'))
|
|
|
|
|
|
|
|
" -- Shade inactive source --------------- {{{
|
2014-01-21 03:22:27 -05:00
|
|
|
if g:EasyMotion_do_shade && targets_len != 1 && s:flag.dot_repeat != 1
|
|
|
|
if a:direction == 1
|
|
|
|
" Backward
|
2014-01-23 11:03:48 -05:00
|
|
|
let shade_hl_re = '\%'. win_first_line .'l\_.*\%#'
|
2014-01-21 03:22:27 -05:00
|
|
|
elseif a:direction == 0
|
|
|
|
" Forward
|
2014-01-23 11:03:48 -05:00
|
|
|
let shade_hl_re = '\%#\_.*\%'. win_last_line .'l'
|
2014-01-21 03:22:27 -05:00
|
|
|
elseif a:direction == 2
|
|
|
|
" Both directions"
|
2014-01-23 11:03:48 -05:00
|
|
|
let shade_hl_re = '\_.*'
|
2014-01-21 03:22:27 -05:00
|
|
|
endif
|
|
|
|
|
2014-01-31 02:53:26 -05:00
|
|
|
call EasyMotion#highlight#add_highlight(
|
2014-02-04 02:48:05 -05:00
|
|
|
\ shade_hl_re, g:EasyMotion_hl_group_shade)
|
2014-01-31 02:53:26 -05:00
|
|
|
if g:EasyMotion_cursor_highlight
|
|
|
|
let cursor_hl_re = '\%#'
|
|
|
|
call EasyMotion#highlight#add_highlight(cursor_hl_re,
|
|
|
|
\ g:EasyMotion_hl_inc_cursor)
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
2014-01-21 03:22:27 -05:00
|
|
|
endif
|
2014-01-17 03:39:26 -05:00
|
|
|
" }}}
|
|
|
|
|
|
|
|
" -- Jump back before prompt for visual scroll {{{
|
|
|
|
" Because searchpos() change current cursor position and
|
2014-01-22 21:47:31 -05:00
|
|
|
" if you just use cursor(s:current.cursor_position) to jump back,
|
2014-01-21 03:22:27 -05:00
|
|
|
" current line will become middle of line window
|
2014-01-17 03:39:26 -05:00
|
|
|
if ! empty(a:visualmode)
|
|
|
|
keepjumps call cursor(win_first_line,0)
|
|
|
|
normal! zt
|
2014-01-20 14:20:25 -05:00
|
|
|
else
|
2014-01-22 21:47:31 -05:00
|
|
|
" for adjusting cursorline
|
|
|
|
keepjumps call cursor(s:current.cursor_position)
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
|
|
|
|
" -- Prompt user for target group/character {{{
|
|
|
|
if s:flag.dot_repeat != 1
|
2014-01-31 02:53:26 -05:00
|
|
|
let coords = s:PromptUser(groups)
|
2014-01-17 03:39:26 -05:00
|
|
|
let s:previous_target_coord = coords
|
|
|
|
else
|
|
|
|
let coords = s:DotPromptUser(groups)
|
|
|
|
endif
|
|
|
|
"}}}
|
|
|
|
|
|
|
|
" -- Update cursor position -------------- {{{
|
2014-01-21 03:22:27 -05:00
|
|
|
" First, jump back cursor to original position
|
2014-01-22 21:47:31 -05:00
|
|
|
keepjumps call cursor(s:current.original_position)
|
2014-01-21 03:22:27 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Consider EasyMotion as jump motion :h jump-motion
|
|
|
|
normal! m`
|
|
|
|
|
2014-01-21 03:22:27 -05:00
|
|
|
" Update selection for visual mode {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
if ! empty(a:visualmode)
|
|
|
|
exec 'normal! ' . a:visualmode
|
|
|
|
endif
|
|
|
|
" }}}
|
|
|
|
|
2014-01-21 03:22:27 -05:00
|
|
|
" For bi-directional motion, checking again whether the motion is
|
|
|
|
" inclusive is necessary. This value will might be updated later
|
|
|
|
let is_inclusive_check = a:is_inclusive
|
|
|
|
" For bi-directional motion, store 'true' direction for dot repeat
|
|
|
|
" to handling inclusive/exclusive motion
|
|
|
|
if a:direction == 2
|
|
|
|
let true_direction =
|
2014-01-22 21:47:31 -05:00
|
|
|
\ EasyMotion#helper#is_greater_coords(
|
|
|
|
\ s:current.original_position, coords) > 0 ?
|
2014-01-21 03:22:27 -05:00
|
|
|
\ 0 : 1
|
|
|
|
" forward : backward
|
|
|
|
else
|
|
|
|
let true_direction = a:direction
|
|
|
|
endif
|
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
if s:flag.dot_repeat == 1
|
|
|
|
" support dot repeat {{{
|
|
|
|
" Use visual mode to emulate dot repeat
|
|
|
|
normal! v
|
2014-01-21 03:22:27 -05:00
|
|
|
|
|
|
|
" Deal with exclusive {{{
|
2014-01-20 21:10:12 -05:00
|
|
|
if s:dot_repeat.is_inclusive == 0
|
2014-01-21 03:22:27 -05:00
|
|
|
" exclusive
|
|
|
|
if s:dot_repeat.true_direction == 0 "Forward
|
2014-01-17 03:39:26 -05:00
|
|
|
let coords[1] -= 1
|
2014-01-21 03:22:27 -05:00
|
|
|
elseif s:dot_repeat.true_direction == 1 "Backward
|
2014-01-17 03:39:26 -05:00
|
|
|
" Shift visual selection to left by making cursor one key
|
|
|
|
" left.
|
|
|
|
normal! hoh
|
|
|
|
endif
|
2014-01-21 03:22:27 -05:00
|
|
|
endif "}}}
|
|
|
|
|
|
|
|
" Jump to destination
|
2014-01-17 03:39:26 -05:00
|
|
|
keepjumps call cursor(coords[0], coords[1])
|
2014-01-21 03:22:27 -05:00
|
|
|
|
|
|
|
" Execute previous operator
|
2014-01-19 07:12:17 -05:00
|
|
|
let cmd = s:dot_repeat.operator
|
|
|
|
if s:dot_repeat.operator ==# 'c'
|
2014-01-17 03:39:26 -05:00
|
|
|
let cmd .= getreg('.')
|
|
|
|
endif
|
|
|
|
exec 'normal! ' . cmd
|
|
|
|
"}}}
|
|
|
|
else
|
2014-01-20 21:10:12 -05:00
|
|
|
" Handle inclusive & exclusive {{{
|
2014-01-21 03:22:27 -05:00
|
|
|
" Overwrite inclusive flag for special case {{{
|
|
|
|
if s:flag.find_bd == 1 && true_direction == 1
|
|
|
|
" Note: For bi-directional find motion s(f) & t
|
|
|
|
" If true_direction is backward, the motion is 'exclusive'
|
|
|
|
let is_inclusive_check = 0 " overwrite
|
|
|
|
let s:previous.is_inclusive = 0 " overwrite
|
|
|
|
endif "}}}
|
|
|
|
if is_inclusive_check
|
|
|
|
" Note: {{{
|
|
|
|
" Inclusive motion requires that we eat one more
|
|
|
|
" character to the right by forcing the motion to inclusive
|
|
|
|
" if we're using a forward motion because
|
|
|
|
" > :h exclusive
|
|
|
|
" > Note that when using ':' any motion becomes characterwise
|
|
|
|
" > exclusive.
|
|
|
|
" and EasyMotion use ':'
|
|
|
|
" See: h: o_v }}}
|
2014-01-17 03:39:26 -05:00
|
|
|
normal! v
|
|
|
|
endif " }}}
|
|
|
|
|
2014-01-22 21:47:31 -05:00
|
|
|
" Adjust screen especially for visual scroll & offscreen search {{{
|
2014-01-21 03:22:27 -05:00
|
|
|
" Otherwise, cursor line will move middle line of window
|
2014-01-22 21:47:31 -05:00
|
|
|
keepjumps call cursor(win_first_line, 0)
|
|
|
|
normal! zt
|
2014-01-17 03:39:26 -05:00
|
|
|
|
2014-01-21 03:22:27 -05:00
|
|
|
" Jump to destination
|
2014-01-17 03:39:26 -05:00
|
|
|
keepjumps call cursor(coords[0], coords[1])
|
|
|
|
|
2014-01-19 07:17:51 -05:00
|
|
|
" To avoid side effect of overwriting buffer {{{
|
|
|
|
" for tpope/vim-repeat
|
2014-01-21 03:22:27 -05:00
|
|
|
" See: :h b:changedtick
|
2014-01-19 07:17:51 -05:00
|
|
|
if exists('g:repeat_tick')
|
|
|
|
if g:repeat_tick == s:current.changedtick
|
|
|
|
let g:repeat_tick = b:changedtick
|
|
|
|
endif
|
|
|
|
endif "}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
|
2014-01-19 07:12:17 -05:00
|
|
|
" Set tpope/vim-repeat {{{
|
2014-01-19 03:59:30 -05:00
|
|
|
if s:current.is_operator == 1 &&
|
|
|
|
\ !(v:operator ==# 'y' && match(&cpo, 'y') == -1)
|
2014-01-19 07:12:17 -05:00
|
|
|
" Store previous info for dot repeat {{{
|
|
|
|
let s:dot_repeat.regexp = a:regexp
|
|
|
|
let s:dot_repeat.direction = a:direction
|
2014-01-21 03:22:27 -05:00
|
|
|
let s:dot_repeat.line_flag = s:flag.within_line
|
|
|
|
let s:dot_repeat.is_inclusive = is_inclusive_check
|
2014-01-19 07:12:17 -05:00
|
|
|
let s:dot_repeat.operator = v:operator
|
2014-01-21 03:22:27 -05:00
|
|
|
let s:dot_repeat.bd_t_flag = s:flag.bd_t " Bidirectional t motion
|
|
|
|
let s:dot_repeat.true_direction = true_direction " Check inclusive
|
2014-01-19 07:12:17 -05:00
|
|
|
"}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
silent! call repeat#set("\<Plug>(easymotion-dotrepeat)")
|
2014-01-19 07:12:17 -05:00
|
|
|
endif "}}}
|
2014-01-17 03:39:26 -05:00
|
|
|
|
2014-02-12 21:27:07 -05:00
|
|
|
" Highlight all the matches by n-key find motions {{{
|
2014-02-16 01:21:37 -05:00
|
|
|
if s:current.is_search == 1 && s:current.is_operator == 0
|
2014-02-12 21:40:01 -05:00
|
|
|
" It seems let &hlsearch=&hlsearch doesn't work when called
|
|
|
|
" in script, so use :h feedkeys() instead.
|
|
|
|
" Ref: :h v:hlsearch
|
2014-02-16 01:21:37 -05:00
|
|
|
" FIXME: doesn't work with `c` operator
|
2014-02-12 21:27:07 -05:00
|
|
|
call EasyMotion#helper#silent_feedkeys(
|
|
|
|
\ ":let &hlsearch=&hlsearch\<CR>",
|
|
|
|
\ 'hlsearch', 'n')
|
|
|
|
endif "}}}
|
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
call s:Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
|
2014-01-22 00:08:48 -05:00
|
|
|
let s:EasyMotion_is_cancelled = 0 " Success
|
2014-01-17 03:39:26 -05:00
|
|
|
"}}}
|
|
|
|
|
|
|
|
catch
|
|
|
|
redraw
|
|
|
|
|
|
|
|
" Show exception message
|
2014-01-22 00:08:48 -05:00
|
|
|
if g:EasyMotion_ignore_exception != 1
|
|
|
|
call s:Message(v:exception)
|
|
|
|
endif
|
2014-01-17 03:39:26 -05:00
|
|
|
|
|
|
|
" -- Restore original cursor position/selection {{{
|
|
|
|
if ! empty(a:visualmode)
|
|
|
|
silent exec 'normal! gv'
|
2014-01-22 21:47:31 -05:00
|
|
|
keepjumps call cursor(s:current.cursor_position)
|
2014-01-17 03:39:26 -05:00
|
|
|
else
|
2014-01-22 21:47:31 -05:00
|
|
|
keepjumps call cursor(s:current.original_position)
|
2014-01-17 03:39:26 -05:00
|
|
|
endif
|
|
|
|
" }}}
|
2014-01-22 00:08:48 -05:00
|
|
|
let s:EasyMotion_is_cancelled = 1 " Cancel
|
2014-01-17 03:39:26 -05:00
|
|
|
finally
|
|
|
|
" -- Restore properties ------------------ {{{
|
|
|
|
call s:RestoreValue()
|
2014-02-06 20:25:43 -05:00
|
|
|
call s:turn_on_hl_error()
|
2014-01-17 03:39:26 -05:00
|
|
|
call EasyMotion#reset()
|
|
|
|
" }}}
|
|
|
|
" -- Remove shading ---------------------- {{{
|
2014-01-19 11:28:48 -05:00
|
|
|
call EasyMotion#highlight#delete_highlight()
|
2014-01-17 03:39:26 -05:00
|
|
|
" }}}
|
2014-01-19 11:28:48 -05:00
|
|
|
|
2014-01-22 00:08:48 -05:00
|
|
|
if s:EasyMotion_is_cancelled == 0 " Success
|
2014-01-21 03:22:27 -05:00
|
|
|
" -- Landing Highlight ------------------- {{{
|
|
|
|
if g:EasyMotion_landing_highlight
|
2014-02-04 03:30:11 -05:00
|
|
|
call EasyMotion#highlight#add_highlight(a:regexp,
|
|
|
|
\ g:EasyMotion_hl_move)
|
2014-01-21 03:22:27 -05:00
|
|
|
call EasyMotion#highlight#attach_autocmd()
|
|
|
|
endif "}}}
|
|
|
|
" -- Activate EasyMotion ----------------- {{{
|
|
|
|
let s:EasyMotion_is_active = 1
|
|
|
|
call EasyMotion#attach_active_autocmd() "}}}
|
|
|
|
endif
|
2014-01-17 03:39:26 -05:00
|
|
|
endtry
|
2014-01-07 03:02:16 -05:00
|
|
|
endfunction " }}}
|
|
|
|
"}}}
|
2014-01-17 12:46:48 -05:00
|
|
|
" Call Init: {{{
|
2014-01-08 23:45:32 -05:00
|
|
|
call EasyMotion#init()
|
2013-12-18 08:39:41 -05:00
|
|
|
"}}}
|
2014-01-17 12:46:48 -05:00
|
|
|
" Restore 'cpoptions' {{{
|
2013-12-18 07:42:56 -05:00
|
|
|
let &cpo = s:save_cpo
|
|
|
|
unlet s:save_cpo
|
|
|
|
" }}}
|
2014-01-17 03:39:26 -05:00
|
|
|
" vim: fdm=marker:et:ts=4:sw=4:sts=4
|