Add subcommand completion for YcmCompleter command
This commit is contained in:
parent
06b1daf1b3
commit
0edec9c95a
@ -609,7 +609,13 @@ function! youcompleteme#OpenGoToList()
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
command! -nargs=* YcmCompleter call s:CompleterCommand(<f-args>)
|
||||
command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete
|
||||
\ YcmCompleter call s:CompleterCommand(<f-args>)
|
||||
|
||||
function! youcompleteme#SubCommandsComplete( arglead, cmdline, cursorpos )
|
||||
return join( pyeval( 'ycm_state.GetFiletypeCompleter().DefinedSubcommands()' ),
|
||||
\ "\n")
|
||||
endfunction
|
||||
|
||||
function! s:ForceCompile()
|
||||
if !pyeval( 'ycm_state.NativeFiletypeCompletionUsable()' )
|
||||
|
@ -176,6 +176,18 @@ class Completer( object ):
|
||||
self.CandidatesForQueryAsyncInner( query, start_column )
|
||||
|
||||
|
||||
def DefinedSubcommands( self ):
|
||||
return []
|
||||
|
||||
|
||||
def UserCommandsHelpMessage( self ):
|
||||
if self.DefinedSubcommands():
|
||||
vimsupport.EchoText( "Supported commands are:\n" +
|
||||
'\n'.join( self.DefinedSubcommands() )+
|
||||
"\nSee the docs for information on what they do." )
|
||||
else:
|
||||
vimsupport.EchoText( "No supported subcommands" )
|
||||
|
||||
def FilterAndSortCandidates( self, candidates, query ):
|
||||
if not candidates:
|
||||
return []
|
||||
|
@ -28,12 +28,6 @@ from flags import Flags
|
||||
CLANG_FILETYPES = set( [ 'c', 'cpp', 'objc', 'objcpp' ] )
|
||||
MAX_DIAGNOSTICS_TO_DISPLAY = int( vimsupport.GetVariableValue(
|
||||
"g:ycm_max_diagnostics_to_display" ) )
|
||||
USER_COMMANDS_HELP_MESSAGE = """
|
||||
Supported commands are:
|
||||
GoToDefinition
|
||||
GoToDeclaration
|
||||
GoToDefinitionElseDeclaration
|
||||
See the docs for information on what they do."""
|
||||
|
||||
|
||||
class ClangCompleter( Completer ):
|
||||
@ -130,10 +124,15 @@ class ClangCompleter( Completer ):
|
||||
return results
|
||||
|
||||
|
||||
def DefinedSubcommands( self ):
|
||||
return [ "GoToDefinition",
|
||||
"GoToDeclaration",
|
||||
"GoToDefinitionElseDeclaration" ]
|
||||
|
||||
|
||||
def OnUserCommand( self, arguments ):
|
||||
if not arguments:
|
||||
vimsupport.EchoText( USER_COMMANDS_HELP_MESSAGE )
|
||||
return
|
||||
return self.UserCommandsHelpMessage()
|
||||
|
||||
command = arguments[ 0 ]
|
||||
if command == 'GoToDefinition':
|
||||
|
@ -38,13 +38,6 @@ except ImportError:
|
||||
'In the YouCompleteMe folder, run "git submodule update --init --recursive"')
|
||||
sys.path.pop( 0 )
|
||||
|
||||
USER_COMMANDS_HELP_MESSAGE = """
|
||||
Supported commands are:
|
||||
GoToDefinition
|
||||
GoToDeclaration
|
||||
GoToDefinitionElseDeclaration
|
||||
See the docs for information on what they do."""
|
||||
|
||||
|
||||
class JediCompleter( ThreadedCompleter ):
|
||||
"""
|
||||
@ -80,10 +73,15 @@ class JediCompleter( ThreadedCompleter ):
|
||||
for completion in script.complete() ]
|
||||
|
||||
|
||||
def DefinedSubcommands( self ):
|
||||
return [ "GoToDefinition",
|
||||
"GoToDeclaration",
|
||||
"GoToDefinitionElseDeclaration" ]
|
||||
|
||||
|
||||
def OnUserCommand( self, arguments ):
|
||||
if not arguments:
|
||||
vimsupport.EchoText( USER_COMMANDS_HELP_MESSAGE )
|
||||
return
|
||||
return self.UserCommandsHelpMessage()
|
||||
|
||||
command = arguments[ 0 ]
|
||||
if command == 'GoToDefinition':
|
||||
|
Loading…
Reference in New Issue
Block a user