Skip to content

Instantly share code, notes, and snippets.

@Shougo
Created June 11, 2012 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shougo/2908040 to your computer and use it in GitHub Desktop.
Save Shougo/2908040 to your computer and use it in GitHub Desktop.
function! CompleteFiles(findstart, base)
if a:findstart
" Get cursor word.
let cur_text = strpart(getline('.'), 0, col('.') - 1)
return match(cur_text, '\f*$')
endif
echomsg printf('getline(".") = %s, a:base = %s',
\ getline('.'), a:base)
let words = split(expand(a:base . '*'), '\n')
let list = []
let cnt = 0
for word in words
call add(list, { 'word' : word, 'abbr' : printf('%3d: %s', cnt, word), 'menu' : 'file_complete' })
let cnt += 1
endfor
return list
endfunction
setlocal omnifunc=CompleteFiles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment