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