Skip to content

Commit

Permalink
More fixes for separate ycmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Valloric committed May 14, 2014
1 parent 6defe8c commit a09527b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 30 deletions.
47 changes: 28 additions & 19 deletions autoload/youcompleteme.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions third_party/ycmd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions third_party/ycmd/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion third_party/ycmd/ycmd/completers/cs/cs_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion third_party/ycmd/ycmd/server_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def SetUpPythonPath():
'..' ) )

from ycmd import utils
utils.AddThirdPartyFoldersToSysPath()
utils.AddNearestThirdPartyFoldersToSysPath( __file__ )
6 changes: 3 additions & 3 deletions third_party/ycmd/ycmd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a09527b

Please sign in to comment.