Using OmniSharp from new directory

This commit is contained in:
Strahinja Val Markovic 2014-05-12 16:30:54 -07:00
parent ea8ef9c34a
commit 7eaafd7ff8
2 changed files with 15 additions and 12 deletions

View File

@ -176,7 +176,7 @@ if $omnisharp_completer; then
fi fi
ycm_dir=`pwd` ycm_dir=`pwd`
build_dir=$ycm_dir"/python/ycm/completers/cs/OmniSharpServer" build_dir=$ycm_dir"/third_party/OmniSharpServer"
cd $build_dir cd $build_dir
$buildcommand $buildcommand

View File

@ -31,14 +31,17 @@ import json
import logging import logging
SERVER_NOT_FOUND_MSG = ( 'OmniSharp server binary not found at {0}. ' + SERVER_NOT_FOUND_MSG = ( 'OmniSharp server binary not found at {0}. ' +
'Did you compile it? You can do so by running ' + 'Did you compile it? You can do so by running ' +
'"./install.sh --omnisharp-completer".' ) '"./install.sh --omnisharp-completer".' )
MIN_LINES_IN_FILE_TO_PARSE = 5 MIN_LINES_IN_FILE_TO_PARSE = 5
INVALID_FILE_MESSAGE = 'File is invalid.' INVALID_FILE_MESSAGE = 'File is invalid.'
FILE_TOO_SHORT_MESSAGE = ( FILE_TOO_SHORT_MESSAGE = (
'File is less than {0} lines long; not parsing.'.format( 'File is less than {0} lines long; not parsing.'.format(
MIN_LINES_IN_FILE_TO_PARSE ) ) MIN_LINES_IN_FILE_TO_PARSE ) )
NO_DIAGNOSTIC_MESSAGE = 'No diagnostic for current line!' NO_DIAGNOSTIC_MESSAGE = 'No diagnostic for current line!'
PATH_TO_OMNISHARP_BINARY = os.path.join(
os.path.abspath( os.path.dirname( __file__ ) ),
'../../../../third_party/OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' )
#TODO: Handle this better than dummy classes #TODO: Handle this better than dummy classes
@ -93,6 +96,10 @@ class CsharpCompleter( Completer ):
self._max_diagnostics_to_display = user_options[ self._max_diagnostics_to_display = user_options[
'max_diagnostics_to_display' ] 'max_diagnostics_to_display' ]
if not os.path.isfile( PATH_TO_OMNISHARP_BINARY ):
raise RuntimeError(
SERVER_NOT_FOUND_MSG.format( PATH_TO_OMNISHARP_BINARY ) )
def Shutdown( self ): def Shutdown( self ):
if ( self.user_options[ 'auto_stop_csharp_server' ] and if ( self.user_options[ 'auto_stop_csharp_server' ] and
@ -232,18 +239,14 @@ class CsharpCompleter( Completer ):
'Found multiple solution files instead of one!\n{0}'.format( 'Found multiple solution files instead of one!\n{0}'.format(
solution_files ) ) solution_files ) )
omnisharp = os.path.join(
os.path.abspath( os.path.dirname( __file__ ) ),
'OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' )
if not os.path.isfile( omnisharp ):
raise RuntimeError( SERVER_NOT_FOUND_MSG.format( omnisharp ) )
path_to_solutionfile = os.path.join( folder, solutionfile ) path_to_solutionfile = os.path.join( folder, solutionfile )
# we need to pass the command to Popen as a string since we're passing # we need to pass the command to Popen as a string since we're passing
# shell=True (as recommended by Python's doc) # shell=True (as recommended by Python's doc)
command = ( omnisharp + ' -p ' + str( self._omnisharp_port ) + ' -s ' + command = ' '.join( [ PATH_TO_OMNISHARP_BINARY,
path_to_solutionfile ) '-p',
str( self._omnisharp_port ),
'-s',
path_to_solutionfile ] )
if not utils.OnWindows() and not utils.OnCygwin(): if not utils.OnWindows() and not utils.OnCygwin():
command = 'mono ' + command command = 'mono ' + command