def ServerBecomesReady( self ): if not self._server_is_ready_with_cache: with HandleServerException( display = False ): self._server_is_ready_with_cache = BaseRequest.GetDataFromHandler( 'ready' ) return self._server_is_ready_with_cache return False
def ShowDetailedDiagnostic( self ): detailed_diagnostic = BaseRequest().PostDataToHandler( BuildRequestData(), 'detailed_diagnostic' ) if detailed_diagnostic and 'message' in detailed_diagnostic: vimsupport.PostVimMessage( detailed_diagnostic[ 'message' ], warning = False )
def ShowDetailedDiagnostic(self): with HandleServerException(): detailed_diagnostic = BaseRequest.PostDataToHandler( BuildRequestData(), 'detailed_diagnostic') if 'message' in detailed_diagnostic: vimsupport.PostVimMessage(detailed_diagnostic['message'], warning=False)
def FilterAndSortItems(self, items, sort_property, query, max_items=0): return BaseRequest().PostDataToHandler( { 'candidates': items, 'sort_property': sort_property, 'max_num_candidates': max_items, 'query': vimsupport.ToUnicode(query) }, 'filter_and_sort_candidates')
def GetDefinedSubcommands(self): if self.IsServerAlive(): try: return BaseRequest.PostDataToHandler(BuildRequestData(), 'defined_subcommands') except ServerError: return [] else: return []
def ShowDetailedDiagnostic(self): if not self.IsServerAlive(): return try: debug_info = BaseRequest.PostDataToHandler(BuildRequestData(), 'detailed_diagnostic') if 'message' in debug_info: vimsupport.EchoText(debug_info['message']) except ServerError as e: vimsupport.PostVimMessage(str(e))
def _ThreadMain(self): while True: time.sleep(self._ping_interval_seconds) # We don't care if there's an intermittent problem in contacting the # server; it's fine to just skip this ping. try: BaseRequest.GetDataFromHandler('healthy') except: pass
def FilterAndSortCandidatesInner(self, candidates, sort_property, query): request_data = { 'candidates': candidates, 'sort_property': sort_property, 'query': query } response = BaseRequest().PostDataToHandler( request_data, 'filter_and_sort_candidates') return response if response is not None else []
def FilterAndSortCandidatesInner(self, candidates, sort_property, query): request_data = { 'candidates': candidates, 'sort_property': sort_property, 'query': query } with HandleServerException(): return BaseRequest.PostDataToHandler(request_data, 'filter_and_sort_candidates') return candidates
def DebugInfo(self): if self.IsServerAlive(): debug_info = BaseRequest.PostDataToHandler(BuildRequestData(), 'debug_info') else: debug_info = 'Server crashed, no debug info from server' debug_info += '\nServer running at: {0}'.format( BaseRequest.server_location) debug_info += '\nServer process ID: {0}'.format(self._server_popen.pid) if self._server_stderr or self._server_stdout: debug_info += '\nServer logfiles:\n {0}\n {1}'.format( self._server_stdout, self._server_stderr) return debug_info
def ShowDetailedDiagnostic( self, message_in_popup ): detailed_diagnostic = BaseRequest().PostDataToHandler( BuildRequestData(), 'detailed_diagnostic' ) if detailed_diagnostic and 'message' in detailed_diagnostic: message = detailed_diagnostic[ 'message' ] if message_in_popup and vimsupport.VimSupportsPopupWindows(): window = vim.current.window buffer_number = vimsupport.GetCurrentBufferNumber() diags_on_this_line = self._buffers[ buffer_number ].DiagnosticsForLine( window.cursor[ 0 ] ) lines = message.split( '\n' ) available_columns = vimsupport.GetIntValue( '&columns' ) col = window.cursor[ 1 ] + 1 if col > available_columns - 2: # -2 accounts for padding. col = 0 options = { 'col': col, 'padding': [ 0, 1, 0, 1 ], 'maxwidth': available_columns, 'close': 'click', 'fixed': 0, 'highlight': 'ErrorMsg', 'border': [ 1, 1, 1, 1 ], # Close when moving cursor 'moved': 'expr', } popup_func = 'popup_atcursor' for diag in diags_on_this_line: if message == diag[ 'text' ]: popup_func = 'popup_create' prop = vimsupport.GetTextPropertyForDiag( buffer_number, window.cursor[ 0 ], diag ) options.update( { 'textpropid': prop[ 'id' ], 'textprop': prop[ 'type' ], } ) options.pop( 'col' ) vim.eval( f'{ popup_func }( { lines }, { options } )' ) else: vimsupport.PostVimMessage( message, warning = False )
def CheckIfServerIsReady(self): if not self._server_is_ready_with_cache and self.IsServerAlive(): with HandleServerException(display=False): self._server_is_ready_with_cache = BaseRequest.GetDataFromHandler( 'ready') return self._server_is_ready_with_cache
def _IgnoreExtraConfFile(filepath): BaseRequest.PostDataToHandler({'filepath': filepath}, 'ignore_extra_conf_file')
def _IsReady(): return BaseRequest().GetDataFromHandler( 'ready' )
def GetDefinedSubcommands( self ): subcommands = BaseRequest().PostDataToHandler( BuildRequestData(), 'defined_subcommands' ) return subcommands if subcommands else []
def CheckIfServerIsReady( self ): if not self._server_is_ready_with_cache and self.IsServerAlive(): self._server_is_ready_with_cache = BaseRequest().GetDataFromHandler( 'ready', display_message = False ) return self._server_is_ready_with_cache
def GetDefinedSubcommands(self): if self._IsServerAlive(): return BaseRequest.PostDataToHandler(BuildRequestData(), 'defined_subcommands') else: return []
def _ThreadMain(self): while True: time.sleep(self._ping_interval_seconds) BaseRequest().GetDataFromHandler('healthy', display_message=False)
def GetDefinedSubcommands(self): with HandleServerException(): return BaseRequest.PostDataToHandler(BuildRequestData(), 'defined_subcommands') return []
def _LoadExtraConfFile(filepath): BaseRequest.PostDataToHandler({'filepath': filepath}, 'load_extra_conf_file')
def _ThreadMain(self): while True: time.sleep(self._ping_interval_seconds) with HandleServerException(display=False): BaseRequest.GetDataFromHandler('healthy')