Per-filetype turning off of filetype completion

So things like the ClangCompleter can be turned off fully and the user can rely
on identifier completion only.
This commit is contained in:
Strahinja Val Markovic 2012-08-15 21:29:43 -07:00
parent dc2f52edbf
commit 0c17c49a66
3 changed files with 13 additions and 12 deletions

View File

@ -68,11 +68,9 @@ function! youcompleteme#Enable()
py import ycm
py ycm_state = ycm.YouCompleteMe()
if g:ycm_filetype_completion_enabled
" <c-x><c-o> trigger omni completion, <c-p> deselects the first completion
" candidate that vim selects by default
inoremap <unique> <C-Space> <C-X><C-O><C-P>
endif
" TODO: make this a nicer, customizable map
nnoremap <unique> <leader>d :call <sid>ShowDetailedDiagnostic()<cr>
@ -87,7 +85,7 @@ endfunction
function! s:AllowedToCompleteInCurrentFile()
" If the user set the current filetype as a filetype that YCM should ignore,
" then we don't do anything
return !get( g:ycm_filetypes_to_ignore, &filetype, 0 )
return !get( g:ycm_filetypes_to_completely_ignore, &filetype, 0 )
endfunction

View File

@ -34,12 +34,11 @@ let g:loaded_youcompleteme = 1
let g:ycm_min_num_of_chars_for_completion =
\ get( g:, 'ycm_min_num_of_chars_for_completion', 2 )
let g:ycm_filetypes_to_ignore =
\ get( g:, 'ycm_filetypes_to_ignore', { 'notes' : 1 } )
let g:ycm_filetypes_to_completely_ignore =
\ get( g:, 'ycm_filetypes_to_completely_ignore', { 'notes' : 1 } )
" TODO: make this more granular
let g:ycm_filetype_completion_enabled =
\ get( g:, 'ycm_filetype_completion_enabled', 1 )
let g:ycm_filetype_specific_completion_to_disable =
\ get( g:, 'ycm_filetype_specific_completion_to_disable', {} )
let g:ycm_allow_changing_updatetime =
\ get( g:, 'ycm_allow_changing_updatetime', 1 )

View File

@ -25,6 +25,9 @@ import os
import sys
from completers.all.identifier_completer import IdentifierCompleter
FILETYPE_SPECIFIC_COMPLETION_TO_DISABLE = vim.eval(
'g:ycm_filetype_specific_completion_to_disable' )
class YouCompleteMe( object ):
def __init__( self ):
@ -76,7 +79,8 @@ class YouCompleteMe( object ):
def FiletypeCompletionEnabledForCurrentFile( self ):
return ( bool( int( vim.eval( 'g:ycm_filetype_completion_enabled' ) ) ) and
return ( vimsupport.CurrentFiletype() not in
FILETYPE_SPECIFIC_COMPLETION_TO_DISABLE and
self.FiletypeCompletionAvailableForFile() )