2012-04-15 19:57:10 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2012-04-15 23:28:46 -04:00
|
|
|
# Copyright (C) 2011, 2012 Strahinja Val Markovic <val@markovic.io>
|
2012-04-15 19:57:10 -04:00
|
|
|
#
|
|
|
|
# This file is part of YouCompleteMe.
|
|
|
|
#
|
|
|
|
# YouCompleteMe is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# YouCompleteMe is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-08-01 01:01:41 -04:00
|
|
|
import imp
|
|
|
|
import os
|
2013-09-06 02:43:14 -04:00
|
|
|
import time
|
2013-02-05 01:07:06 -05:00
|
|
|
import vim
|
2013-05-19 23:06:14 -04:00
|
|
|
import ycm_core
|
2013-09-06 02:43:14 -04:00
|
|
|
import logging
|
|
|
|
import tempfile
|
2013-05-19 22:44:42 -04:00
|
|
|
from ycm import vimsupport
|
2013-09-02 22:46:30 -04:00
|
|
|
from ycm import base
|
2013-09-17 19:34:02 -04:00
|
|
|
from ycm import extra_conf_store
|
2013-05-19 22:44:42 -04:00
|
|
|
from ycm.completers.all.omni_completer import OmniCompleter
|
|
|
|
from ycm.completers.general.general_completer_store import GeneralCompleterStore
|
2012-05-12 18:20:03 -04:00
|
|
|
|
2013-05-19 23:06:14 -04:00
|
|
|
|
2013-09-06 02:43:14 -04:00
|
|
|
# TODO: Put the Request classes in separate files
|
2013-09-07 20:39:52 -04:00
|
|
|
class BaseRequest( object ):
|
|
|
|
def __init__( self ):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def Start( self ):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def Done( self ):
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def Response( self ):
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class CompletionRequest( BaseRequest ):
|
2013-09-02 22:46:30 -04:00
|
|
|
def __init__( self, ycm_state ):
|
2013-09-07 20:39:52 -04:00
|
|
|
super( CompletionRequest, self ).__init__()
|
|
|
|
|
2013-09-02 22:46:30 -04:00
|
|
|
self._completion_start_column = base.CompletionStartColumn()
|
|
|
|
self._ycm_state = ycm_state
|
2013-09-06 02:43:14 -04:00
|
|
|
self._request_data = _BuildRequestData( self._completion_start_column )
|
2013-09-02 22:46:30 -04:00
|
|
|
self._do_filetype_completion = self._ycm_state.ShouldUseFiletypeCompleter(
|
2013-09-06 02:43:14 -04:00
|
|
|
self._request_data )
|
2013-09-02 22:46:30 -04:00
|
|
|
self._completer = ( self._ycm_state.GetFiletypeCompleter() if
|
|
|
|
self._do_filetype_completion else
|
|
|
|
self._ycm_state.GetGeneralCompleter() )
|
|
|
|
|
|
|
|
|
|
|
|
def ShouldComplete( self ):
|
|
|
|
return ( self._do_filetype_completion or
|
2013-09-06 02:43:14 -04:00
|
|
|
self._ycm_state.ShouldUseGeneralCompleter( self._request_data ) )
|
2013-09-02 22:46:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
def CompletionStartColumn( self ):
|
|
|
|
return self._completion_start_column
|
|
|
|
|
|
|
|
|
|
|
|
def Start( self, query ):
|
2013-09-06 02:43:14 -04:00
|
|
|
self._request_data[ 'query' ] = query
|
|
|
|
self._completer.CandidatesForQueryAsync( self._request_data )
|
2013-09-02 22:46:30 -04:00
|
|
|
|
|
|
|
def Done( self ):
|
|
|
|
return self._completer.AsyncCandidateRequestReady()
|
|
|
|
|
|
|
|
|
|
|
|
def Results( self ):
|
2013-09-06 02:43:14 -04:00
|
|
|
try:
|
|
|
|
return [ _ConvertCompletionDataToVimData( x )
|
|
|
|
for x in self._completer.CandidatesFromStoredRequest() ]
|
|
|
|
except Exception as e:
|
|
|
|
vimsupport.PostVimMessage( str( e ) )
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-07 20:39:52 -04:00
|
|
|
class CommandRequest( BaseRequest ):
|
2013-09-06 02:43:14 -04:00
|
|
|
class ServerResponse( object ):
|
|
|
|
def __init__( self ):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def Valid( self ):
|
|
|
|
return True
|
|
|
|
|
|
|
|
def __init__( self, ycm_state, arguments, completer_target = None ):
|
2013-09-07 20:39:52 -04:00
|
|
|
super( CommandRequest, self ).__init__()
|
|
|
|
|
2013-09-06 02:43:14 -04:00
|
|
|
if not completer_target:
|
|
|
|
completer_target = 'filetpe_default'
|
|
|
|
|
|
|
|
if completer_target == 'omni':
|
|
|
|
self._completer = ycm_state.GetOmniCompleter()
|
|
|
|
elif completer_target == 'identifier':
|
|
|
|
self._completer = ycm_state.GetGeneralCompleter()
|
|
|
|
else:
|
|
|
|
self._completer = ycm_state.GetFiletypeCompleter()
|
|
|
|
self._arguments = arguments
|
|
|
|
|
|
|
|
|
|
|
|
def Start( self ):
|
|
|
|
self._completer.OnUserCommand( self._arguments,
|
|
|
|
_BuildRequestData() )
|
|
|
|
|
|
|
|
|
|
|
|
def Response( self ):
|
|
|
|
# TODO: Call vimsupport.JumpToLocation if the user called a GoTo command...
|
|
|
|
# we may want to have specific subclasses of CommandRequest so that a
|
|
|
|
# GoToRequest knows it needs to jump after the data comes back.
|
|
|
|
#
|
|
|
|
# Also need to run the following on GoTo data:
|
|
|
|
# CAREFUL about line/column number 0-based/1-based confusion!
|
|
|
|
#
|
|
|
|
# defs = []
|
|
|
|
# defs.append( {'filename': definition.module_path.encode( 'utf-8' ),
|
|
|
|
# 'lnum': definition.line,
|
|
|
|
# 'col': definition.column + 1,
|
|
|
|
# 'text': definition.description.encode( 'utf-8' ) } )
|
|
|
|
# vim.eval( 'setqflist( %s )' % repr( defs ) )
|
|
|
|
# vim.eval( 'youcompleteme#OpenGoToList()' )
|
|
|
|
return self.ServerResponse()
|
2013-09-02 22:46:30 -04:00
|
|
|
|
|
|
|
|
2013-09-07 20:39:52 -04:00
|
|
|
class EventNotification( BaseRequest ):
|
|
|
|
def __init__( self, event_name, ycm_state, extra_data = None ):
|
|
|
|
super( EventNotification, self ).__init__()
|
|
|
|
|
|
|
|
self._ycm_state = ycm_state
|
|
|
|
self._event_name = event_name
|
|
|
|
self._request_data = _BuildRequestData()
|
|
|
|
if extra_data:
|
|
|
|
self._request_data.update( extra_data )
|
|
|
|
|
|
|
|
|
|
|
|
def Start( self ):
|
2013-09-17 19:34:02 -04:00
|
|
|
event_handler = 'On' + self._event_name
|
2013-09-07 20:39:52 -04:00
|
|
|
getattr( self._ycm_state.GetGeneralCompleter(),
|
2013-09-17 19:34:02 -04:00
|
|
|
event_handler )( self._request_data )
|
2013-09-07 20:39:52 -04:00
|
|
|
|
|
|
|
if self._ycm_state.FiletypeCompletionUsable():
|
|
|
|
getattr( self._ycm_state.GetFiletypeCompleter(),
|
2013-09-17 19:34:02 -04:00
|
|
|
event_handler )( self._request_data )
|
|
|
|
|
|
|
|
if hasattr( extra_conf_store, event_handler ):
|
|
|
|
getattr( extra_conf_store, event_handler )( self._request_data )
|
2013-09-07 20:39:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def SendEventNotificationAsync( event_name, ycm_state, extra_data = None ):
|
|
|
|
event = EventNotification( event_name, ycm_state, extra_data )
|
|
|
|
event.Start()
|
|
|
|
|
2013-09-02 22:46:30 -04:00
|
|
|
|
2012-08-04 20:46:54 -04:00
|
|
|
class YouCompleteMe( object ):
|
2013-09-02 17:45:53 -04:00
|
|
|
def __init__( self, user_options ):
|
2013-09-06 02:43:14 -04:00
|
|
|
# TODO: This should go into the server
|
|
|
|
# TODO: Use more logging like we do in cs_completer
|
|
|
|
self._logfile = tempfile.NamedTemporaryFile()
|
|
|
|
logging.basicConfig( format='%(asctime)s - %(levelname)s - %(message)s',
|
|
|
|
filename=self._logfile.name,
|
|
|
|
level=logging.DEBUG )
|
|
|
|
|
2013-09-02 17:45:53 -04:00
|
|
|
self._user_options = user_options
|
|
|
|
self._gencomp = GeneralCompleterStore( user_options )
|
|
|
|
self._omnicomp = OmniCompleter( user_options )
|
2013-09-01 23:19:46 -04:00
|
|
|
self._filetype_completers = {}
|
2013-09-02 22:46:30 -04:00
|
|
|
self._current_completion_request = None
|
|
|
|
|
|
|
|
|
|
|
|
def CreateCompletionRequest( self ):
|
|
|
|
# We have to store a reference to the newly created CompletionRequest
|
|
|
|
# because VimScript can't store a reference to a Python object across
|
|
|
|
# function calls... Thus we need to keep this request somewhere.
|
|
|
|
self._current_completion_request = CompletionRequest( self )
|
|
|
|
return self._current_completion_request
|
|
|
|
|
|
|
|
|
2013-09-06 02:43:14 -04:00
|
|
|
def SendCommandRequest( self, arguments, completer ):
|
|
|
|
# TODO: This should be inside a method in a command_request module
|
|
|
|
request = CommandRequest( self, arguments, completer )
|
|
|
|
request.Start()
|
|
|
|
while not request.Done():
|
|
|
|
time.sleep( 0.1 )
|
|
|
|
|
|
|
|
return request.Response()
|
|
|
|
|
|
|
|
|
2013-09-02 22:46:30 -04:00
|
|
|
def GetCurrentCompletionRequest( self ):
|
|
|
|
return self._current_completion_request
|
2012-08-01 01:01:41 -04:00
|
|
|
|
2012-07-22 18:19:28 -04:00
|
|
|
|
2013-04-01 07:44:41 -04:00
|
|
|
def GetGeneralCompleter( self ):
|
2013-09-01 23:19:46 -04:00
|
|
|
return self._gencomp
|
2012-07-28 18:27:30 -04:00
|
|
|
|
|
|
|
|
2013-02-25 09:14:01 -05:00
|
|
|
def GetOmniCompleter( self ):
|
2013-09-01 23:19:46 -04:00
|
|
|
return self._omnicomp
|
2013-02-25 09:14:01 -05:00
|
|
|
|
|
|
|
|
2013-02-09 19:22:23 -05:00
|
|
|
def GetFiletypeCompleter( self ):
|
2013-01-31 19:19:56 -05:00
|
|
|
filetypes = vimsupport.CurrentFiletypes()
|
|
|
|
|
2013-04-24 22:59:14 -04:00
|
|
|
completers = [ self.GetFiletypeCompleterForFiletype( filetype )
|
|
|
|
for filetype in filetypes ]
|
2013-03-02 21:14:22 -05:00
|
|
|
|
|
|
|
if not completers:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# Try to find a native completer first
|
|
|
|
for completer in completers:
|
2013-09-01 23:19:46 -04:00
|
|
|
if completer and completer is not self._omnicomp:
|
2013-01-31 19:19:56 -05:00
|
|
|
return completer
|
2013-03-02 21:14:22 -05:00
|
|
|
|
|
|
|
# Return the omni completer for the first filetype
|
2013-09-02 17:45:53 -04:00
|
|
|
return completers[ 0 ]
|
2013-01-31 19:19:56 -05:00
|
|
|
|
|
|
|
|
|
|
|
def GetFiletypeCompleterForFiletype( self, filetype ):
|
2012-08-01 01:01:41 -04:00
|
|
|
try:
|
2013-09-01 23:19:46 -04:00
|
|
|
return self._filetype_completers[ filetype ]
|
2012-08-01 01:01:41 -04:00
|
|
|
except KeyError:
|
2012-08-04 20:46:54 -04:00
|
|
|
pass
|
2012-08-01 01:01:41 -04:00
|
|
|
|
2012-08-05 17:14:31 -04:00
|
|
|
module_path = _PathToFiletypeCompleterPluginLoader( filetype )
|
2012-08-01 01:01:41 -04:00
|
|
|
|
2012-08-04 20:46:54 -04:00
|
|
|
completer = None
|
2013-01-13 23:56:10 -05:00
|
|
|
supported_filetypes = [ filetype ]
|
2012-08-04 20:46:54 -04:00
|
|
|
if os.path.exists( module_path ):
|
|
|
|
module = imp.load_source( filetype, module_path )
|
2013-09-02 17:45:53 -04:00
|
|
|
completer = module.GetCompleter( self._user_options )
|
2013-01-13 23:56:10 -05:00
|
|
|
if completer:
|
|
|
|
supported_filetypes.extend( completer.SupportedFiletypes() )
|
2013-02-10 22:55:05 -05:00
|
|
|
else:
|
2013-09-01 23:19:46 -04:00
|
|
|
completer = self._omnicomp
|
2013-01-13 23:56:10 -05:00
|
|
|
|
|
|
|
for supported_filetype in supported_filetypes:
|
2013-09-01 23:19:46 -04:00
|
|
|
self._filetype_completers[ supported_filetype ] = completer
|
2012-08-04 20:46:54 -04:00
|
|
|
return completer
|
2012-07-28 18:27:30 -04:00
|
|
|
|
2012-07-26 23:50:56 -04:00
|
|
|
|
2013-09-06 02:43:14 -04:00
|
|
|
def ShouldUseGeneralCompleter( self, request_data ):
|
|
|
|
return self._gencomp.ShouldUseNow( request_data )
|
2012-07-22 18:19:28 -04:00
|
|
|
|
2012-07-10 23:27:46 -04:00
|
|
|
|
2013-09-06 02:43:14 -04:00
|
|
|
def ShouldUseFiletypeCompleter( self, request_data ):
|
2013-02-10 22:55:05 -05:00
|
|
|
if self.FiletypeCompletionUsable():
|
2013-09-06 02:43:14 -04:00
|
|
|
return self.GetFiletypeCompleter().ShouldUseNow( request_data )
|
2012-08-04 20:46:54 -04:00
|
|
|
return False
|
2012-07-10 23:27:46 -04:00
|
|
|
|
|
|
|
|
2013-02-10 22:55:05 -05:00
|
|
|
def NativeFiletypeCompletionAvailable( self ):
|
|
|
|
completer = self.GetFiletypeCompleter()
|
2013-09-01 23:19:46 -04:00
|
|
|
return bool( completer ) and completer is not self._omnicomp
|
2013-02-10 22:55:05 -05:00
|
|
|
|
|
|
|
|
2013-02-09 19:22:23 -05:00
|
|
|
def FiletypeCompletionAvailable( self ):
|
|
|
|
return bool( self.GetFiletypeCompleter() )
|
2012-07-20 00:17:39 -04:00
|
|
|
|
|
|
|
|
2013-02-10 22:55:05 -05:00
|
|
|
def NativeFiletypeCompletionUsable( self ):
|
2013-09-02 17:45:53 -04:00
|
|
|
return ( self.CurrentFiletypeCompletionEnabled() and
|
2013-02-10 22:55:05 -05:00
|
|
|
self.NativeFiletypeCompletionAvailable() )
|
|
|
|
|
2013-01-31 19:19:56 -05:00
|
|
|
|
2013-02-10 22:55:05 -05:00
|
|
|
def FiletypeCompletionUsable( self ):
|
2013-09-02 17:45:53 -04:00
|
|
|
return ( self.CurrentFiletypeCompletionEnabled() and
|
2013-02-09 19:22:23 -05:00
|
|
|
self.FiletypeCompletionAvailable() )
|
2012-07-28 18:27:30 -04:00
|
|
|
|
|
|
|
|
2012-08-04 20:46:54 -04:00
|
|
|
def OnFileReadyToParse( self ):
|
2013-09-07 20:39:52 -04:00
|
|
|
extra_data = {}
|
|
|
|
if self._user_options[ 'collect_identifiers_from_tags_files' ]:
|
|
|
|
extra_data[ 'tag_files' ] = _GetTagFiles()
|
2012-05-12 18:20:03 -04:00
|
|
|
|
2013-09-07 20:39:52 -04:00
|
|
|
# TODO: make this work again
|
|
|
|
# if self._user_options[ 'seed_identifiers_with_syntax' ]:
|
2012-04-15 19:57:10 -04:00
|
|
|
|
2013-09-07 20:39:52 -04:00
|
|
|
SendEventNotificationAsync( 'FileReadyToParse', self, extra_data )
|
2012-05-08 00:23:38 -04:00
|
|
|
|
2013-03-14 23:39:44 -04:00
|
|
|
|
2013-09-07 20:39:52 -04:00
|
|
|
def OnBufferUnload( self, deleted_buffer_file ):
|
|
|
|
SendEventNotificationAsync( 'BufferUnload',
|
|
|
|
self,
|
|
|
|
{ 'unloaded_buffer': deleted_buffer_file } )
|
2013-03-14 23:39:44 -04:00
|
|
|
|
|
|
|
|
2013-04-24 16:31:28 -04:00
|
|
|
def OnBufferVisit( self ):
|
2013-09-07 20:39:52 -04:00
|
|
|
SendEventNotificationAsync( 'BufferVisit', self )
|
2013-04-24 16:31:28 -04:00
|
|
|
|
|
|
|
|
2012-08-04 20:46:54 -04:00
|
|
|
def OnInsertLeave( self ):
|
2013-09-07 20:39:52 -04:00
|
|
|
SendEventNotificationAsync( 'InsertLeave', self )
|
2012-05-12 18:20:03 -04:00
|
|
|
|
2012-07-31 18:30:50 -04:00
|
|
|
|
2013-07-07 13:59:48 -04:00
|
|
|
def OnVimLeave( self ):
|
2013-09-07 20:39:52 -04:00
|
|
|
SendEventNotificationAsync( 'VimLeave', self )
|
2013-07-07 13:59:48 -04:00
|
|
|
|
2013-09-07 20:39:52 -04:00
|
|
|
|
|
|
|
def OnCurrentIdentifierFinished( self ):
|
|
|
|
SendEventNotificationAsync( 'CurrentIdentifierFinished', self )
|
2013-07-07 13:59:48 -04:00
|
|
|
|
|
|
|
|
2012-08-04 20:46:54 -04:00
|
|
|
def DiagnosticsForCurrentFileReady( self ):
|
2013-02-10 22:55:05 -05:00
|
|
|
if self.FiletypeCompletionUsable():
|
2013-02-09 19:22:23 -05:00
|
|
|
return self.GetFiletypeCompleter().DiagnosticsForCurrentFileReady()
|
2012-08-04 20:46:54 -04:00
|
|
|
return False
|
2012-07-31 18:30:50 -04:00
|
|
|
|
2012-07-23 21:35:48 -04:00
|
|
|
|
2012-08-06 23:14:21 -04:00
|
|
|
def GetDiagnosticsForCurrentFile( self ):
|
2013-02-10 22:55:05 -05:00
|
|
|
if self.FiletypeCompletionUsable():
|
2013-02-09 19:22:23 -05:00
|
|
|
return self.GetFiletypeCompleter().GetDiagnosticsForCurrentFile()
|
2012-08-06 23:14:21 -04:00
|
|
|
return []
|
|
|
|
|
|
|
|
|
2013-09-06 02:43:14 -04:00
|
|
|
def GetDetailedDiagnostic( self ):
|
2013-02-10 22:55:05 -05:00
|
|
|
if self.FiletypeCompletionUsable():
|
2013-09-06 02:43:14 -04:00
|
|
|
return self.GetFiletypeCompleter().GetDetailedDiagnostic()
|
2012-08-15 22:39:03 -04:00
|
|
|
|
|
|
|
|
2013-02-06 00:22:50 -05:00
|
|
|
def GettingCompletions( self ):
|
2013-02-10 22:55:05 -05:00
|
|
|
if self.FiletypeCompletionUsable():
|
2013-02-09 19:22:23 -05:00
|
|
|
return self.GetFiletypeCompleter().GettingCompletions()
|
2013-02-06 00:22:50 -05:00
|
|
|
return False
|
|
|
|
|
|
|
|
|
2013-01-26 14:44:42 -05:00
|
|
|
def DebugInfo( self ):
|
2013-09-01 23:19:46 -04:00
|
|
|
completers = set( self._filetype_completers.values() )
|
|
|
|
completers.add( self._gencomp )
|
2013-01-26 14:44:42 -05:00
|
|
|
output = []
|
|
|
|
for completer in completers:
|
|
|
|
if not completer:
|
|
|
|
continue
|
|
|
|
debug = completer.DebugInfo()
|
|
|
|
if debug:
|
|
|
|
output.append( debug )
|
|
|
|
|
|
|
|
has_clang_support = ycm_core.HasClangSupport()
|
|
|
|
output.append( 'Has Clang support compiled in: {0}'.format(
|
|
|
|
has_clang_support ) )
|
|
|
|
|
|
|
|
if has_clang_support:
|
|
|
|
output.append( ycm_core.ClangVersion() )
|
|
|
|
|
|
|
|
return '\n'.join( output )
|
|
|
|
|
|
|
|
|
2013-09-02 17:45:53 -04:00
|
|
|
def CurrentFiletypeCompletionEnabled( self ):
|
|
|
|
filetypes = vimsupport.CurrentFiletypes()
|
|
|
|
filetype_to_disable = self._user_options[
|
|
|
|
'filetype_specific_completion_to_disable' ]
|
|
|
|
return not all([ x in filetype_to_disable for x in filetypes ])
|
2013-02-10 22:55:05 -05:00
|
|
|
|
2013-01-26 14:44:42 -05:00
|
|
|
|
2012-08-04 20:46:54 -04:00
|
|
|
def _PathToCompletersFolder():
|
|
|
|
dir_of_current_script = os.path.dirname( os.path.abspath( __file__ ) )
|
|
|
|
return os.path.join( dir_of_current_script, 'completers' )
|
2012-07-10 18:26:07 -04:00
|
|
|
|
|
|
|
|
2012-08-05 17:14:31 -04:00
|
|
|
def _PathToFiletypeCompleterPluginLoader( filetype ):
|
|
|
|
return os.path.join( _PathToCompletersFolder(), filetype, 'hook.py' )
|
2012-07-10 18:26:07 -04:00
|
|
|
|
2012-05-12 18:20:03 -04:00
|
|
|
|
2013-09-06 02:43:14 -04:00
|
|
|
def _BuildRequestData( start_column = None, query = None ):
|
|
|
|
line, column = vimsupport.CurrentLineAndColumn()
|
|
|
|
request_data = {
|
|
|
|
'filetypes': vimsupport.CurrentFiletypes(),
|
|
|
|
'line_num': line,
|
|
|
|
'column_num': column,
|
|
|
|
'start_column': start_column,
|
|
|
|
'line_value': vim.current.line,
|
|
|
|
'filepath': vim.current.buffer.name,
|
|
|
|
'file_data': vimsupport.GetUnsavedAndCurrentBufferData()
|
|
|
|
}
|
|
|
|
|
|
|
|
if query:
|
|
|
|
request_data[ 'query' ] = query
|
|
|
|
|
|
|
|
return request_data
|
|
|
|
|
|
|
|
def _ConvertCompletionDataToVimData( completion_data ):
|
|
|
|
# see :h complete-items for a description of the dictionary fields
|
|
|
|
vim_data = {
|
|
|
|
'word' : completion_data[ 'insertion_text' ],
|
|
|
|
'dup' : 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
if 'menu_text' in completion_data:
|
|
|
|
vim_data[ 'abbr' ] = completion_data[ 'menu_text' ]
|
|
|
|
if 'extra_menu_info' in completion_data:
|
|
|
|
vim_data[ 'menu' ] = completion_data[ 'extra_menu_info' ]
|
|
|
|
if 'kind' in completion_data:
|
|
|
|
vim_data[ 'kind' ] = completion_data[ 'kind' ]
|
|
|
|
if 'detailed_info' in completion_data:
|
|
|
|
vim_data[ 'info' ] = completion_data[ 'detailed_info' ]
|
|
|
|
|
|
|
|
return vim_data
|
2013-09-07 20:39:52 -04:00
|
|
|
|
|
|
|
def _GetTagFiles():
|
|
|
|
tag_files = vim.eval( 'tagfiles()' )
|
|
|
|
current_working_directory = os.getcwd()
|
|
|
|
return [ os.path.join( current_working_directory, x ) for x in tag_files ]
|