ShouldUseNow for IdentifierCompleter done and used
This commit is contained in:
parent
df260ed2a8
commit
ea30cb046e
@ -205,12 +205,6 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! s:CompletionsForQuery( query, use_filetype_completer )
|
function! s:CompletionsForQuery( query, use_filetype_completer )
|
||||||
" TODO: needed?
|
|
||||||
if !a:use_filetype_completer &&
|
|
||||||
\ strlen( a:query ) < g:ycm_min_num_of_chars_for_completion
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:use_filetype_completer
|
if a:use_filetype_completer
|
||||||
py completer = ycm_state.GetFiletypeCompleterForCurrentFile()
|
py completer = ycm_state.GetFiletypeCompleterForCurrentFile()
|
||||||
else
|
else
|
||||||
@ -250,16 +244,12 @@ function! youcompleteme#Complete( findstart, base )
|
|||||||
\ pyeval( 'ycm_state.ShouldUseFiletypeCompleter(' .
|
\ pyeval( 'ycm_state.ShouldUseFiletypeCompleter(' .
|
||||||
\ s:completion_start_column . ')' )
|
\ s:completion_start_column . ')' )
|
||||||
|
|
||||||
" TODO: use ShouldUseIdentifierCompleter() which checks query length
|
if !s:should_use_filetype_completion &&
|
||||||
if ( !s:should_use_filetype_completion )
|
\ !pyeval( 'ycm_state.ShouldUseIdentifierCompleter(' .
|
||||||
let l:current_column = col('.') - 1
|
\ s:completion_start_column . ')' )
|
||||||
let l:query_length = current_column - s:completion_start_column
|
" for vim, -2 means not found but don't trigger an error message
|
||||||
|
" see :h complete-functions
|
||||||
if ( query_length < g:ycm_min_num_of_chars_for_completion )
|
return -2
|
||||||
" for vim, -2 means not found but don't trigger an error message
|
|
||||||
" see :h complete-functions
|
|
||||||
return -2
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
return s:completion_start_column
|
return s:completion_start_column
|
||||||
else
|
else
|
||||||
|
@ -24,7 +24,8 @@ import ycm_core
|
|||||||
import utils
|
import utils
|
||||||
|
|
||||||
MAX_IDENTIFIER_COMPLETIONS_RETURNED = 10
|
MAX_IDENTIFIER_COMPLETIONS_RETURNED = 10
|
||||||
MIN_NUM_CHARS = int( vim.eval( "g:ycm_min_num_of_chars_for_completion" ) )
|
MIN_NUM_CHARS = int( vimsupport.GetVariableValue(
|
||||||
|
"g:ycm_min_num_of_chars_for_completion" ) )
|
||||||
|
|
||||||
|
|
||||||
def GetCompleter():
|
def GetCompleter():
|
||||||
@ -42,9 +43,9 @@ class IdentifierCompleter( Completer ):
|
|||||||
return set( [ 'ycm_all' ] )
|
return set( [ 'ycm_all' ] )
|
||||||
|
|
||||||
|
|
||||||
# TODO: implement this
|
|
||||||
def ShouldUseNow( self, start_column ):
|
def ShouldUseNow( self, start_column ):
|
||||||
return True
|
query_length = vimsupport.CurrentColumn() - start_column
|
||||||
|
return query_length >= MIN_NUM_CHARS
|
||||||
|
|
||||||
|
|
||||||
def CandidatesForQueryAsync( self, query ):
|
def CandidatesForQueryAsync( self, query ):
|
||||||
|
@ -64,3 +64,7 @@ def EscapeForVim( text ):
|
|||||||
|
|
||||||
def CurrentFiletype():
|
def CurrentFiletype():
|
||||||
return vim.eval( "&filetype" )
|
return vim.eval( "&filetype" )
|
||||||
|
|
||||||
|
|
||||||
|
def GetVariableValue( variable ):
|
||||||
|
return vim.eval( variable )
|
||||||
|
Loading…
Reference in New Issue
Block a user