fixing smart tab completion

This commit is contained in:
Nick Nisi
2012-11-15 10:09:04 -06:00
parent d3d161011d
commit f2fb73da33

View File

@@ -290,26 +290,26 @@ autocmd! BufEnter * call ApplyLocalSettings(expand("<afile>:p:h"))
" smart tab completion " smart tab completion
function! Smart_TabComplete() function! Smart_TabComplete()
let line = getline('.') let line = getline('.') " current line
let substr = strpart(line, -1, col('.')+1)
let substr = matchstr(substr, "[^ \t]*$") let substr = strpart(line, -1, col('.')+1) " from the start of the current
if (strlen(substr) == 0) " line to one character right
return "<\tab>" " of the cursor
let substr = matchstr(substr, "[^ \t]*$") " word till cursor
if (strlen(substr)==0) " nothing to match on empty string
return "\<tab>"
endif endif
let has_period = match(substr, '\.') != -1 let has_period = match(substr, '\.') != -1 " position of period, if any
let has_slash = match(substr, '\/') != -1 let has_slash = match(substr, '\/') != -1 " position of slash, if any
if (!has_period && !has_slash) if (!has_period && !has_slash)
return "\<C-X>\<C-P>" return "\<C-X>\<C-P>" " existing text matching
elseif (has_slash) elseif ( has_slash )
return "\<C-X>\<C-F>" return "\<C-X>\<C-F>" " file matching
else else
return "\<C-X>\<C-O>" return "\<C-X>\<C-O>" " plugin matching
endif endif
endfunction endfunction
inoremap <tab> <c-r>=Smart_TabComplete()<CR> inoremap <tab> <c-r>=Smart_TabComplete()<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins " => Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -331,9 +331,9 @@ nmap <silent> <leader>r :CtrlPBuffer<cr>
" CtrlP ignore patterns " CtrlP ignore patterns
let g:ctrlp_custom_ignore = { let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|node_modules$\|\.hg$\|\.svn$', \ 'dir': '\.git$\|node_modules$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$' \ 'file': '\.exe$\|\.so$'
\ } \ }
" search the nearest ancestor that contains .git, .hg, .svn " search the nearest ancestor that contains .git, .hg, .svn
let g:ctrlp_working_path_mode = 2 let g:ctrlp_working_path_mode = 2