Skip to content

Commit

Permalink
Merge branch 'improve-file-completion'
Browse files Browse the repository at this point in the history
Manually merge in mhinz#256.
  • Loading branch information
tylerw committed Sep 7, 2022
2 parents 2b93535 + e78901e commit c4f0da7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
doc/tags
test/vader.vim
13 changes: 2 additions & 11 deletions plugin/grepper.vim
Original file line number Diff line number Diff line change
Expand Up @@ -228,23 +228,14 @@ function! grepper#complete(lead, line, _pos) abort
return filter(map(sort(copy(g:grepper.tools)), 'v:val." "'),
\ 'empty(a:lead) || v:val[:strlen(a:lead)-1] ==# a:lead')
else
return grepper#complete_files(a:lead, 0, 0)
return []
endif
endfunction

" grepper#complete_files() {{{2
function! grepper#complete_files(lead, _line, _pos)
let [head, path] = s:extract_path(a:lead)
" handle relative paths
if empty(path) || (path =~ '\s$')
return map(split(globpath('.'.s:slash, path.'*'), '\n'), 'head . "." . v:val[1:] . (isdirectory(v:val) ? s:slash : "")')
" handle sub paths
elseif path =~ '^.\/'
return map(split(globpath('.'.s:slash, path[2:].'*'), '\n'), 'head . "." . v:val[1:] . (isdirectory(v:val) ? s:slash : "")')
" handle absolute paths
elseif path[0] == '/'
return map(split(globpath(s:slash, path.'*'), '\n'), 'head . v:val[1:] . (isdirectory(v:val) ? s:slash : "")')
endif
return map(getcompletion(path, 'file'), 'head . v:val')
endfunction

" s:extract_path() {{{2
Expand Down

0 comments on commit c4f0da7

Please sign in to comment.