Created
June 11, 2015 05:44
-
-
Save presuku/605b352daf26feb6625c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! MigemoMatch(items, str, limit, mmode, ispath, crfile, regex) | |
if has('migmeo') | |
let tmp = tempname() | |
try | |
if a:str =~ '^\s*$' | |
return a:items | |
endif | |
call writefile(split(iconv(join(a:items, "\n"), &encoding, 'utf-8'), "\n"), tmp) | |
return split(iconv(system( | |
\ printf('migemogrep %s %s', | |
\ shellescape(a:str), | |
\ shellescape(tmp))), 'utf-8', &encoding), "\n") | |
catch | |
return [] | |
finally | |
call delete(tmp) | |
endtry | |
else | |
try | |
if a:str =~ '^\s*$' | |
return copy(a:items) | |
endif | |
let migemoed_str = migemo(a:str) | |
let new_items = filter(copy(a:items), 'match(v:val, migemoed_str) >= 0') | |
if ! empty(new_items) | |
return new_items | |
else | |
return [] | |
endif | |
catch | |
return copy(a:items) | |
endtry | |
endif | |
endfunction | |
function! SetMigemoMatcher() | |
let g:ctrlp_match_func = {'match' : 'MigemoMatch' } | |
endfunction | |
function! SetMigemoMatcher() | |
let g:ctrlp_match_func = {} | |
endfunction | |
command! CtrlPSetMigemoMatcher call SetMigemoMatcher() | |
command! CtrlPSetDefaultMatcher call SetDefaultMatcher() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment