Merge branch 'feature/multi-migemo' into master
This commit is contained in:
commit
3c7d39488c
@ -144,9 +144,10 @@ function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
|
||||
return
|
||||
endif
|
||||
|
||||
let s:line_flag = 1
|
||||
|
||||
let re = s:findMotion(input)
|
||||
|
||||
let s:line_flag = 1
|
||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
||||
endfunction " }}}
|
||||
function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
|
||||
@ -165,6 +166,8 @@ function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
|
||||
return
|
||||
endif
|
||||
|
||||
let s:line_flag = 1
|
||||
|
||||
let re = s:findMotion(input)
|
||||
|
||||
if a:direction == 1
|
||||
@ -175,8 +178,6 @@ function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
|
||||
let re = '.\ze' . re
|
||||
endif
|
||||
|
||||
let s:line_flag = 1
|
||||
|
||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
||||
endfunction " }}}
|
||||
function! EasyMotion#WBL(visualmode, direction) " {{{
|
||||
@ -488,11 +489,18 @@ function! s:findMotion(char) "{{{
|
||||
endfunction "}}}
|
||||
function! s:convertMigemo(re) "{{{
|
||||
let re = a:re
|
||||
|
||||
if len(re) > 1
|
||||
" System cmigemo
|
||||
return EasyMotion#cmigemo#getMigemoPattern(re)
|
||||
endif
|
||||
|
||||
" EasyMoton migemo one key dict
|
||||
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 = s:migemo_dicts[&l:encoding][re]
|
||||
let re = get(s:migemo_dicts[&l:encoding], re, a:re)
|
||||
endif
|
||||
return re
|
||||
endfunction "}}}
|
||||
@ -580,13 +588,19 @@ function! s:GetVisualStartPosition(c_pos, v_start, v_end, search_direction) "{{{
|
||||
endfunction "}}}
|
||||
" -- Others ------------------------------
|
||||
function! s:should_use_migemo(char) "{{{
|
||||
if ! g:EasyMotion_use_migemo || a:char !~# '^\a$'
|
||||
if ! g:EasyMotion_use_migemo || match(a:char, '\A') != -1
|
||||
return 0
|
||||
endif
|
||||
|
||||
" TODO: use direction and support within line
|
||||
let first_line = line('w0')
|
||||
let end_line = line('w$')
|
||||
" TODO: use direction
|
||||
if s:line_flag == 1
|
||||
let first_line = line('.')
|
||||
let end_line = line('.')
|
||||
else
|
||||
let first_line = line('w0')
|
||||
let end_line = line('w$')
|
||||
endif
|
||||
|
||||
|
||||
for line in range(first_line, end_line)
|
||||
if s:is_folded(line)
|
||||
|
110
autoload/EasyMotion/cmigemo.vim
Normal file
110
autoload/EasyMotion/cmigemo.vim
Normal file
@ -0,0 +1,110 @@
|
||||
"=============================================================================
|
||||
" FILE: autoload/EasyMotion/cmigemo.vim
|
||||
" AUTHOR: haya14busa
|
||||
" Last Change: 14 Jan 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
|
||||
" "Software"), to deal in the Software without restriction, including
|
||||
" without limitation the rights to use, copy, modify, merge, publish,
|
||||
" distribute, sublicense, and/or sell copies of the Software, and to
|
||||
" permit persons to whom the Software is furnished to do so, subject to
|
||||
" the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included
|
||||
" in all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
" }}}
|
||||
"=============================================================================
|
||||
scriptencoding utf-8
|
||||
" Saving 'cpoptions' {{{
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
" }}}
|
||||
|
||||
function! s:has_vimproc() "{{{
|
||||
if !exists('s:exists_vimproc')
|
||||
try
|
||||
silent call vimproc#version()
|
||||
let s:exists_vimproc = 1
|
||||
catch
|
||||
let s:exists_vimproc = 0
|
||||
endtry
|
||||
endif
|
||||
|
||||
return s:exists_vimproc
|
||||
endfunction "}}}
|
||||
|
||||
function! EasyMotion#cmigemo#system(...) "{{{
|
||||
return call(s:has_vimproc() ? 'vimproc#system' : 'system', a:000)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:SearchDict2(name) "{{{
|
||||
let path = $VIM . ',' . &runtimepath
|
||||
let dict = globpath(path, "dict/".a:name)
|
||||
if dict == ''
|
||||
let dict = globpath(path, a:name)
|
||||
endif
|
||||
if dict == ''
|
||||
for path in [
|
||||
\ '/usr/local/share/migemo/',
|
||||
\ '/usr/local/share/cmigemo/',
|
||||
\ '/usr/local/share/',
|
||||
\ '/usr/share/cmigemo/',
|
||||
\ '/usr/share/',
|
||||
\ ]
|
||||
let path = path . a:name
|
||||
if filereadable(path)
|
||||
let dict = path
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let dict = matchstr(dict, "^[^\<NL>]*")
|
||||
return dict
|
||||
endfunction "}}}
|
||||
|
||||
function! s:SearchDict() "{{{
|
||||
for path in [
|
||||
\ 'migemo/'.&encoding.'/migemo-dict',
|
||||
\ &encoding.'/migemo-dict',
|
||||
\ 'migemo-dict',
|
||||
\ ]
|
||||
let dict = s:SearchDict2(path)
|
||||
if dict != ''
|
||||
return dict
|
||||
endif
|
||||
endfor
|
||||
echoerr 'a dictionary for migemo is not found'
|
||||
echoerr 'your encoding is '.&encoding
|
||||
endfunction "}}}
|
||||
|
||||
function! EasyMotion#cmigemo#getMigemoPattern(input) "{{{
|
||||
if !exists('s:migemodict')
|
||||
let s:migemodict = s:SearchDict()
|
||||
endif
|
||||
|
||||
if has('migemo')
|
||||
" Use migemo().
|
||||
return migemo(a:input)
|
||||
elseif executable('cmigemo')
|
||||
" Use cmigemo.
|
||||
return EasyMotion#cmigemo#system('cmigemo -v -w "'.a:input.'" -d "'.s:migemodict.'"')
|
||||
else
|
||||
" Not supported
|
||||
return input
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" Restore 'cpoptions' {{{
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" }}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user