Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Valloric committed Aug 16, 2012
1 parent dc2f52e commit 0c17c49
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
10 changes: 4 additions & 6 deletions autoload/youcompleteme.vim
Expand Up @@ -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
" <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>
" TODO: make this a nicer, customizable map
nnoremap <unique> <leader>d :call <sid>ShowDetailedDiagnostic()<cr>
Expand All @@ -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


Expand Down
9 changes: 4 additions & 5 deletions plugin/youcompleteme.vim
Expand Up @@ -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 )
Expand Down
6 changes: 5 additions & 1 deletion python/ycm.py
Expand Up @@ -25,6 +25,9 @@
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 ):
Expand Down Expand Up @@ -76,7 +79,8 @@ def FiletypeCompletionAvailableForFile( self ):


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() )


Expand Down

0 comments on commit 0c17c49

Please sign in to comment.