Skip to content

Instantly share code, notes, and snippets.

@szw
Created June 3, 2013 20:30
Show Gist options
  • Select an option

  • Save szw/5701125 to your computer and use it in GitHub Desktop.

Select an option

Save szw/5701125 to your computer and use it in GitHub Desktop.
let g:ycm_semantic_triggers = {} " turn off autostart of semantic completion
let g:ycm_delayed_semantic_triggers = {
\ 'c' : ['->', '.'],
\ 'objc' : ['->', '.'],
\ 'ocaml' : ['.', '#'],
\ 'cpp,objcpp' : ['->', '.', '::'],
\ 'perl' : ['->'],
\ 'php' : ['->', '::'],
\ 'cs,java,javascript,d,vim,ruby,python,perl6,scala,vb,elixir,go' : ['.'],
\ 'lua' : ['.', ':'],
\ 'erlang' : [':'],
\ }
let g:ycm_allow_changing_updatetime = 0
set updatetime=1000
au CursorHoldI * call g:try_complete()
function! g:try_complete()
let start_column = getpos(".")[2] - 1
let line = getline(".")
let line_length = len(line)
if (line_length == 0) || ((start_column - 1) >= line_length)
return 0
endif
for [filetypes, triggers] in items(g:ycm_delayed_semantic_triggers)
if index(split(filetypes, ","), &ft) >= 0
for trigger in triggers
let index = -1
let trigger_length = len(trigger)
while 1
let line_index = start_column + index
if (line_index < 0) || (line[line_index] != trigger[trigger_length + index])
break
endif
if abs(index) == trigger_length
call feedkeys("\<C-x>\<C-o>\<C-p>")
return 1
endif
let index -= 1
endwhile
endfor
endif
endfor
return 0
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment