Reputation: 59202
In vim, does the SuperTab plugin support autocompleting local filenames? For example, In a C++ program, I want to tbe able to type:
#include "file
tab
And if there's a file called "fileparser.h" in the local directory, have SuperTab autocomplete to:
#include "fileparser.h
With my current config, the only elements in the autocomplete menu are C++ entities like classnames, no filenames.
Upvotes: 0
Views: 1590
Reputation: 172540
From the plugin's help:
let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
Note: a special value of 'context' is supported which will result in
super tab attempting to use the text preceding the cursor to decide which
type of completion to attempt. Currently super tab can recognize method
calls or attribute references via '.', '::' or '->', and file path
references containing '/'.
let g:SuperTabDefaultCompletionType = "context"
/usr/l<tab> # will use filename completion
So yes, there is filetype completion, but only if the completion base already includes a slash (which is not the case in your example). You can easily modify the plugin to also accept a preceding #include
, like this (the third-last line is new):
function! s:ContextText() " {{{
let exclusions = exists('g:SuperTabContextTextFileTypeExclusions') ?
\ g:SuperTabContextTextFileTypeExclusions : []
if index(exclusions, &ft) == -1
let curline = getline('.')
let cnum = col('.')
let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name')
if curline =~ '.*/\w*\%' . cnum . 'c' ||
\ curline =~ '#include\s.*\%' . cnum . 'c' ||
\ ((has('win32') || has('win64')) && curline =~ '.*\\\w*\%' . cnum . 'c')
return "\<c-x>\<c-f>"
Alternatively, you can trigger the built-in filetype completion via <C-x><C-f>
.
Upvotes: 2