Find a free port for OmniSharp if another OmniSharp is using the default port
This commit is contained in:
parent
e15ec6ee93
commit
1a7da1650c
@ -163,6 +163,8 @@ let g:ycm_csharp_server_stderr_logfile_format =
|
|||||||
let g:ycm_csharp_server_stdout_logfile_format =
|
let g:ycm_csharp_server_stdout_logfile_format =
|
||||||
\ get( g:, 'ycm_csharp_server_stdout_logfile_format', '' )
|
\ get( g:, 'ycm_csharp_server_stdout_logfile_format', '' )
|
||||||
|
|
||||||
|
let g:ycm_find_free_port_for_csharp_server =
|
||||||
|
\ get( g:, 'ycm_find_free_port_for_csharp_server', 0 )
|
||||||
|
|
||||||
" On-demand loading. Let's use the autoload folder and not slow down vim's
|
" On-demand loading. Let's use the autoload folder and not slow down vim's
|
||||||
" startup procedure.
|
" startup procedure.
|
||||||
|
@ -38,7 +38,13 @@ class CsharpCompleter( ThreadedCompleter ):
|
|||||||
def __init__( self ):
|
def __init__( self ):
|
||||||
super( CsharpCompleter, self ).__init__()
|
super( CsharpCompleter, self ).__init__()
|
||||||
self.OmniSharpPort = int( vimsupport.GetVariableValue( "g:ycm_csharp_server_port" ) )
|
self.OmniSharpPort = int( vimsupport.GetVariableValue( "g:ycm_csharp_server_port" ) )
|
||||||
self.OmniSharpHost = 'http://localhost:' + str( self.OmniSharpPort )
|
self.OmniSharpHost = ''
|
||||||
|
|
||||||
|
if vimsupport.GetBoolValue( "g:ycm_find_free_port_for_csharp_server" ):
|
||||||
|
self._FindFreePort();
|
||||||
|
|
||||||
|
self._RefreshOmniSharpHost()
|
||||||
|
|
||||||
if vimsupport.GetBoolValue( "g:ycm_auto_start_csharp_server" ):
|
if vimsupport.GetBoolValue( "g:ycm_auto_start_csharp_server" ):
|
||||||
self._StartServer()
|
self._StartServer()
|
||||||
|
|
||||||
@ -132,6 +138,14 @@ class CsharpCompleter( ThreadedCompleter ):
|
|||||||
""" Check if the OmniSharp server is running """
|
""" Check if the OmniSharp server is running """
|
||||||
return self._GetResponse( '/checkalivestatus', silent=True ) != None
|
return self._GetResponse( '/checkalivestatus', silent=True ) != None
|
||||||
|
|
||||||
|
def _FindFreePort( self ):
|
||||||
|
while self._ServerIsRunning():
|
||||||
|
self.OmniSharpPort = self.OmniSharpPort + 1
|
||||||
|
self._RefreshOmniSharpHost()
|
||||||
|
|
||||||
|
def _RefreshOmniSharpHost ( self ):
|
||||||
|
self.OmniSharpHost = 'http://localhost:' + str( self.OmniSharpPort )
|
||||||
|
|
||||||
def _GetCompletions( self ):
|
def _GetCompletions( self ):
|
||||||
""" Ask server for completions """
|
""" Ask server for completions """
|
||||||
line, column = vimsupport.CurrentLineAndColumn()
|
line, column = vimsupport.CurrentLineAndColumn()
|
||||||
|
Loading…
Reference in New Issue
Block a user