Closed na0x2c6 closed 3 years ago
You should use copy
function! Hoge(items, str, limit, mmode, ispath, crfile, regex)
return copy(a:items)
endfunction
@mattn Thank you for your fast response.
Actually, What I really want to do is to use migemogrep
according to this article:
https://vim-jp.org/blog/2014/08/08/dropped-migemo-from-ctrlp-vim.html
Now, my code is:
function! MigemoMatch(items, str, limit, mmode, ispath, crfile, regex)
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 copy(split(iconv(system(
\ printf('migemogrep %s %s',
\ shellescape(a:str),
\ shellescape(tmp))), 'utf-8', &encoding), "\n"))
catch
return []
finally
call delete(tmp)
endtry
endfunction
let g:ctrlp_match_func = {'match' : 'MigemoMatch' }
But, ONE prefix still is concatenated to file names:
Please try this.
function! MigemoMatch(items, str, limit, mmode, ispath, crfile, regex)
let tmp = tempname()
try
if a:str =~ '^\s*$'
return copy(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
endfunction
let g:ctrlp_match_func = {'match' : 'MigemoMatch' }
Ohhhh, completely worked. Thank you!!!
👍
Thank you for the great plugin.
If
g:ctrlp_match_func
is set, the prefix will concatenate to the file names in the list repeatedly.Example:
The above script means that any pattern matches any file.
Result:![using-ctrlp_match_func](https://user-images.githubusercontent.com/15692034/93567138-27d16b00-f9c9-11ea-93ea-0efdf785254b.gif)
So, I cannot open the correct file but new file which has unnecessary prefix.
I use Vim v8.2.1704 on MacOS. Thanks.