diff --git a/autoload/asyncomplete/sources/file.vim b/autoload/asyncomplete/sources/file.vim index 2c6578f..585a156 100644 --- a/autoload/asyncomplete/sources/file.vim +++ b/autoload/asyncomplete/sources/file.vim @@ -11,6 +11,22 @@ function! s:filename_map(prefix, file) abort \ } endfunction +function! s:matches_for_prefix(pre, cwd) abort + let l:pre = a:pre + let l:cwd = a:cwd + + let l:glob = fnamemodify(l:cwd, ':t') . '*' + let l:cwd = fnamemodify(l:cwd, ':p:h') + + if l:pre !~ '/$' + let l:pre = l:pre . '/' + endif + + let l:cwdlen = strlen(l:cwd) + let l:files = split(globpath(l:cwd, l:glob), '\n') + return map(l:files, {key, val -> s:filename_map(l:pre, val)}) +endfunction + function! asyncomplete#sources#file#completor(opt, ctx) let l:bufnr = a:ctx['bufnr'] let l:typed = a:ctx['typed'] @@ -18,30 +34,23 @@ function! asyncomplete#sources#file#completor(opt, ctx) let l:kw = matchstr(l:typed, '<\@ s:filename_map(l:pre, val)}) - call asyncomplete#complete(a:opt['name'], a:ctx, l:startcol, l:matches) endfunction