diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 3405b76a..d50ea4d0 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -46,28 +46,10 @@ function! youcompleteme#Enable() call s:SetUpBackwardsCompatibility() - py import sys - py import vim - exe 'python sys.path.insert( 0, "' . s:script_folder_path . '/../python" )' - exe 'python sys.path.insert( 0, "' . s:script_folder_path . - \ '/../third_party/ycmd" )' - py from ycmd import utils - py utils.AddThirdPartyFoldersToSysPath() - py from ycm import base - py base.LoadJsonDefaultsIntoVim() - py from ycmd import user_options_store - py user_options_store.SetAll( base.BuildServerConf() ) - - if !pyeval( 'base.CompatibleWithYcmCore()') - echohl WarningMsg | - \ echomsg "YouCompleteMe unavailable: YCM support libs too old, PLEASE RECOMPILE" | - \ echohl None + if !s:SetUpPython() return endif - py from ycm.youcompleteme import YouCompleteMe - py ycm_state = YouCompleteMe( user_options_store.GetAll() ) - call s:SetUpCpoptions() call s:SetUpCompleteopt() call s:SetUpKeyMappings() @@ -110,6 +92,33 @@ function! youcompleteme#Enable() endfunction +function! s:SetUpPython() + py import sys + py import vim + exe 'python sys.path.insert( 0, "' . s:script_folder_path . '/../python" )' + exe 'python sys.path.insert( 0, "' . s:script_folder_path . + \ '/../third_party/ycmd" )' + py from ycmd import utils + exe 'py utils.AddNearestThirdPartyFoldersToSysPath("' + \ . s:script_folder_path . '")' + py from ycm import base + py base.LoadJsonDefaultsIntoVim() + py from ycmd import user_options_store + py user_options_store.SetAll( base.BuildServerConf() ) + + if !pyeval( 'base.CompatibleWithYcmCore()') + echohl WarningMsg | + \ echomsg "YouCompleteMe unavailable: YCM support libs too old, PLEASE RECOMPILE" | + \ echohl None + return 0 + endif + + py from ycm.youcompleteme import YouCompleteMe + py ycm_state = YouCompleteMe( user_options_store.GetAll() ) + return 1 +endfunction + + function! s:SetUpKeyMappings() " The g:ycm_key_select_completion and g:ycm_key_previous_completion used to " exist and are now here purely for the sake of backwards compatibility; we diff --git a/third_party/ycmd/build.sh b/third_party/ycmd/build.sh index 055c81dc..4ee8c9f3 100755 --- a/third_party/ycmd/build.sh +++ b/third_party/ycmd/build.sh @@ -175,9 +175,7 @@ if $omnisharp_completer; then fi fi - # TODO: change to the following when omnisharp in own third_party: - # $SCRIPT_DIR"/third_party/OmniSharpServer" - build_dir=$SCRIPT_DIR"/../OmniSharpServer" + build_dir=$SCRIPT_DIR"/third_party/OmniSharpServer" cd $build_dir $buildcommand diff --git a/third_party/ycmd/run_tests.sh b/third_party/ycmd/run_tests.sh index 9b877079..f14d33c5 100755 --- a/third_party/ycmd/run_tests.sh +++ b/third_party/ycmd/run_tests.sh @@ -36,9 +36,7 @@ fi EXTRA_CMAKE_ARGS=$extra_cmake_args YCM_TESTRUN=1 \ $SCRIPT_DIR/build.sh --omnisharp-completer -# TODO: change to the following when we have own third_party: -# $SCRIPT_DIR/third_party/* -for directory in $SCRIPT_DIR/../*; do +for directory in $SCRIPT_DIR/third_party/*; do if [ -d "${directory}" ]; then export PYTHONPATH=${directory}:$PYTHONPATH fi diff --git a/third_party/ycmd/ycmd/completers/cs/cs_completer.py b/third_party/ycmd/ycmd/completers/cs/cs_completer.py index a8dff336..9343cc90 100755 --- a/third_party/ycmd/ycmd/completers/cs/cs_completer.py +++ b/third_party/ycmd/ycmd/completers/cs/cs_completer.py @@ -41,7 +41,7 @@ FILE_TOO_SHORT_MESSAGE = ( NO_DIAGNOSTIC_MESSAGE = 'No diagnostic for current line!' PATH_TO_OMNISHARP_BINARY = os.path.join( os.path.abspath( os.path.dirname( __file__ ) ), - '../../../../OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) + '../../../third_party/OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) #TODO: Handle this better than dummy classes diff --git a/third_party/ycmd/ycmd/server_utils.py b/third_party/ycmd/ycmd/server_utils.py index ef3a476b..a3ce56ed 100644 --- a/third_party/ycmd/ycmd/server_utils.py +++ b/third_party/ycmd/ycmd/server_utils.py @@ -26,4 +26,4 @@ def SetUpPythonPath(): '..' ) ) from ycmd import utils - utils.AddThirdPartyFoldersToSysPath() + utils.AddNearestThirdPartyFoldersToSysPath( __file__ ) diff --git a/third_party/ycmd/ycmd/utils.py b/third_party/ycmd/ycmd/utils.py index d689a602..db5a24f4 100644 --- a/third_party/ycmd/ycmd/utils.py +++ b/third_party/ycmd/ycmd/utils.py @@ -209,11 +209,11 @@ def PathToNearestThirdPartyFolder( path ): return None -def AddThirdPartyFoldersToSysPath(): - path_to_third_party = PathToNearestThirdPartyFolder( __file__ ) +def AddNearestThirdPartyFoldersToSysPath( filepath ): + path_to_third_party = PathToNearestThirdPartyFolder( filepath ) if not path_to_third_party: raise RuntimeError( - 'No third_party folder found for: {0}'.format( __file__) ) + 'No third_party folder found for: {0}'.format( filepath ) ) for folder in os.listdir( path_to_third_party ): sys.path.insert( 0, os.path.realpath( os.path.join( path_to_third_party,