From 6ec038870b986bb29910da5f597efeb56b9934a5 Mon Sep 17 00:00:00 2001 From: Chiel92 Date: Mon, 8 Jul 2013 11:22:17 +0200 Subject: [PATCH] ServerIsRunning fixed and variable defaults set --- .gitmodules | 2 +- plugin/youcompleteme.vim | 3 +++ python/ycm/completers/cs/cs_completer.py | 12 ++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index 7d13a22b..bb21127b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/davidhalter/jedi.git [submodule "python/ycm/completers/cs/OmniSharpServer"] path = python/ycm/completers/cs/OmniSharpServer - url = https://github.com/nosami/OmniSharpServer.git + url = https://github.com/Chiel92/OmniSharpServer.git diff --git a/plugin/youcompleteme.vim b/plugin/youcompleteme.vim index 940ca304..fef34b22 100644 --- a/plugin/youcompleteme.vim +++ b/plugin/youcompleteme.vim @@ -151,6 +151,9 @@ let g:ycm_semantic_triggers = let g:ycm_cache_omnifunc = \ get( g:, 'ycm_cache_omnifunc', 1 ) +let g:ycm_auto_start_csharp_server = + \ get( g:, 'ycm_auto_start_csharp_server', 0 ) + " On-demand loading. Let's use the autoload folder and not slow down vim's " startup procedure. augroup youcompletemeStart diff --git a/python/ycm/completers/cs/cs_completer.py b/python/ycm/completers/cs/cs_completer.py index 1e983967..7e50ffa5 100755 --- a/python/ycm/completers/cs/cs_completer.py +++ b/python/ycm/completers/cs/cs_completer.py @@ -42,8 +42,8 @@ class CsharpCompleter( ThreadedCompleter ): if vimsupport.GetBoolValue( "g:ycm_auto_start_csharp_server" ): self._StartServer() - def OnVimLeave( self ): - self._StopServer() + #def OnVimLeave( self ): + #self._StopServer() def SupportedFiletypes( self ): """ Just csharp """ @@ -115,8 +115,7 @@ class CsharpCompleter( ThreadedCompleter ): def _ServerIsRunning( self ): """ Check if the OmniSharp server is running """ - self._StopServer() # temporal fix - return False + return self._GetResponse( '/poke', silent=True ) != None def _GetCompletions( self ): """ Ask server for completions """ @@ -130,7 +129,7 @@ class CsharpCompleter( ThreadedCompleter ): completions = self._GetResponse( '/autocomplete', parameters ) return completions if completions != None else [] - def _GetResponse( self, endPoint, parameters={} ): + def _GetResponse( self, endPoint, parameters={}, silent = False ): """ Handle communication with server """ target = urlparse.urljoin( self.OmniSharpHost, endPoint ) parameters = urllib.urlencode( parameters ) @@ -138,5 +137,6 @@ class CsharpCompleter( ThreadedCompleter ): response = urllib2.urlopen( target, parameters ) return json.loads( response.read() ) except Exception as e: - vimsupport.PostVimMessage('OmniSharp : Could not connect to ' + target + ': ' + str(e)) + if not silent: + vimsupport.PostVimMessage('OmniSharp : Could not connect to ' + target + ': ' + str(e)) return None