From a69d827934e6b01cc508bd2223027fa393ea53e8 Mon Sep 17 00:00:00 2001 From: Chiel92 Date: Fri, 21 Jun 2013 22:26:11 +0200 Subject: [PATCH] solution file detection ported --- python/ycm/completers/cs/cs_completer.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/python/ycm/completers/cs/cs_completer.py b/python/ycm/completers/cs/cs_completer.py index f1e60fae..4090d76e 100755 --- a/python/ycm/completers/cs/cs_completer.py +++ b/python/ycm/completers/cs/cs_completer.py @@ -19,10 +19,10 @@ # along with YouCompleteMe. If not, see . import vim +import os +import glob from ycm.completers.threaded_completer import ThreadedCompleter from ycm import vimsupport - -# Import stuff for Omnisharp import urllib2 import urllib import urlparse @@ -68,8 +68,20 @@ class CsharpCompleter( ThreadedCompleter ): """ Start the OmniSharp server """ if ( not self._ServerIsRunning() ): # Find the solution file - folder = vim.eval( "expand(%:p:h)" ) - pass + folder = os.path.dirname( vim.current.buffer.name ) + solutionfiles = glob.glob1( folder, "*.sln" ) + while not solutionfiles: + lastfolder = folder + # Traverse up a level + folder = os.path.dirname( folder ) + if folder == lastfolder: + break + solutionfiles = glob.glob1( folder, "*.sln" ) + + if len( solutionfiles ) == 1: + pass # start server here + else: + pass # some other stuff, like notifying def _StopServer( self ): """ Stop the OmniSharp server """ @@ -78,7 +90,7 @@ class CsharpCompleter( ThreadedCompleter ): def _ServerIsRunning( self ): """ Check if the OmniSharp server is running """ - return True + return False def _GetCompletions( self ): """ Ask server for completions """