diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 77ce429a..3405b76a 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -49,12 +49,13 @@ function! youcompleteme#Enable() py import sys py import vim exe 'python sys.path.insert( 0, "' . s:script_folder_path . '/../python" )' - py from ycm import utils + 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 ycm import vimsupport - py from ycm import user_options_store + py from ycmd import user_options_store py user_options_store.SetAll( base.BuildServerConf() ) if !pyeval( 'base.CompatibleWithYcmCore()') diff --git a/python/ycm/base.py b/python/ycm/base.py index da0a4bc2..2161b032 100644 --- a/python/ycm/base.py +++ b/python/ycm/base.py @@ -19,8 +19,8 @@ import vim from ycm import vimsupport -from ycm import utils -from ycm import user_options_store +from ycmd import utils +from ycmd import user_options_store import ycm_client_support YCM_VAR_PREFIX = 'ycm_' diff --git a/python/ycm/client/base_request.py b/python/ycm/client/base_request.py index 36388a0a..d48090d1 100644 --- a/python/ycm/client/base_request.py +++ b/python/ycm/client/base_request.py @@ -25,9 +25,9 @@ from retries import retries from requests_futures.sessions import FuturesSession from ycm.unsafe_thread_pool_executor import UnsafeThreadPoolExecutor from ycm import vimsupport -from ycm import utils -from ycm.utils import ToUtf8Json -from ycm.server.responses import ServerError, UnknownExtraConf +from ycmd import utils +from ycmd.utils import ToUtf8Json +from ycmd.responses import ServerError, UnknownExtraConf _HEADERS = {'content-type': 'application/json'} _EXECUTOR = UnsafeThreadPoolExecutor( max_workers = 30 ) diff --git a/python/ycm/client/command_request.py b/python/ycm/client/command_request.py index 375cde10..717eb221 100644 --- a/python/ycm/client/command_request.py +++ b/python/ycm/client/command_request.py @@ -20,7 +20,7 @@ import vim from ycm.client.base_request import BaseRequest, BuildRequestData, ServerError from ycm import vimsupport -from ycm.utils import ToUtf8IfNeeded +from ycmd.utils import ToUtf8IfNeeded def _EnsureBackwardsCompatibility( arguments ): if arguments and arguments[ 0 ] == 'GoToDefinitionElseDeclaration': diff --git a/python/ycm/client/completion_request.py b/python/ycm/client/completion_request.py index 5dd6872f..c54e1b4e 100644 --- a/python/ycm/client/completion_request.py +++ b/python/ycm/client/completion_request.py @@ -19,7 +19,7 @@ from ycm import base from ycm import vimsupport -from ycm.utils import ToUtf8IfNeeded +from ycmd.utils import ToUtf8IfNeeded from ycm.client.base_request import ( BaseRequest, BuildRequestData, JsonFromFuture ) diff --git a/python/ycm/client/event_notification.py b/python/ycm/client/event_notification.py index af10ca02..a5978ad0 100644 --- a/python/ycm/client/event_notification.py +++ b/python/ycm/client/event_notification.py @@ -18,7 +18,7 @@ # along with YouCompleteMe. If not, see . from ycm import vimsupport -from ycm.server.responses import UnknownExtraConf +from ycmd.responses import UnknownExtraConf from ycm.client.base_request import ( BaseRequest, BuildRequestData, JsonFromFuture ) diff --git a/third_party/ycmd/ycmd/completers/all/omni_completer.py b/python/ycm/omni_completer.py similarity index 98% rename from third_party/ycmd/ycmd/completers/all/omni_completer.py rename to python/ycm/omni_completer.py index 944160c8..098adb56 100644 --- a/third_party/ycmd/ycmd/completers/all/omni_completer.py +++ b/python/ycm/omni_completer.py @@ -20,7 +20,7 @@ import vim from ycm import vimsupport from ycm import base -from ycm.completers.completer import Completer +from ycmd.completers.completer import Completer from ycm.client.base_request import BuildRequestData OMNIFUNC_RETURNED_BAD_VALUE = 'Omnifunc returned bad value to YCM!' diff --git a/third_party/ycmd/ycmd/completers/general/syntax_parse.py b/python/ycm/syntax_parse.py similarity index 100% rename from third_party/ycmd/ycmd/completers/general/syntax_parse.py rename to python/ycm/syntax_parse.py diff --git a/third_party/ycmd/ycmd/completers/general/tests/syntax_parse_test.py b/python/ycm/tests/syntax_parse_test.py similarity index 99% rename from third_party/ycmd/ycmd/completers/general/tests/syntax_parse_test.py rename to python/ycm/tests/syntax_parse_test.py index 318c7785..d7b34f88 100644 --- a/third_party/ycmd/ycmd/completers/general/tests/syntax_parse_test.py +++ b/python/ycm/tests/syntax_parse_test.py @@ -21,7 +21,7 @@ import os from nose.tools import eq_ from ycm.test_utils import MockVimModule vim_mock = MockVimModule() -from ycm.completers.general import syntax_parse +from ycm import syntax_parse def ContentsOfTestFile( test_file ): diff --git a/third_party/ycmd/ycmd/completers/general/tests/testdata/cpp_syntax b/python/ycm/tests/testdata/cpp_syntax similarity index 100% rename from third_party/ycmd/ycmd/completers/general/tests/testdata/cpp_syntax rename to python/ycm/tests/testdata/cpp_syntax diff --git a/third_party/ycmd/ycmd/completers/general/tests/testdata/java_syntax b/python/ycm/tests/testdata/java_syntax similarity index 100% rename from third_party/ycmd/ycmd/completers/general/tests/testdata/java_syntax rename to python/ycm/tests/testdata/java_syntax diff --git a/third_party/ycmd/ycmd/completers/general/tests/testdata/python_syntax b/python/ycm/tests/testdata/python_syntax similarity index 100% rename from third_party/ycmd/ycmd/completers/general/tests/testdata/python_syntax rename to python/ycm/tests/testdata/python_syntax diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index 6782c8f6..48ec4a3e 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -20,8 +20,8 @@ import vim import os import json -from ycm.utils import ToUtf8IfNeeded -from ycm import user_options_store +from ycmd.utils import ToUtf8IfNeeded +from ycmd import user_options_store BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit', 'horizontal-split' : 'split', diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index 83849ce1..5c274f1e 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -25,11 +25,11 @@ import signal import base64 from subprocess import PIPE from ycm import vimsupport -from ycm import utils +from ycmd import utils from ycm.diagnostic_interface import DiagnosticInterface -from ycm.completers.all.omni_completer import OmniCompleter -from ycm.completers.general import syntax_parse -from ycm.completers.completer_utils import FiletypeCompleterExistsForFiletype +from ycm.omni_completer import OmniCompleter +from ycm import syntax_parse +from ycmd.completers.completer_utils import FiletypeCompleterExistsForFiletype from ycm.client.ycmd_keepalive import YcmdKeepalive from ycm.client.base_request import BaseRequest, BuildRequestData from ycm.client.command_request import SendCommandRequest @@ -37,7 +37,7 @@ from ycm.client.completion_request import CompletionRequest from ycm.client.omni_completion_request import OmniCompletionRequest from ycm.client.event_notification import ( SendEventNotificationAsync, EventNotification ) -from ycm.server.responses import ServerError +from ycmd.responses import ServerError try: from UltiSnips import UltiSnips_Manager @@ -363,7 +363,7 @@ class YouCompleteMe( object ): def _PathToServerScript(): dir_of_current_script = os.path.dirname( os.path.abspath( __file__ ) ) - return os.path.join( dir_of_current_script, 'server/ycmd.py' ) + return os.path.join( dir_of_current_script, '../../third_party/ycmd/ycmd' ) def _AddUltiSnipsDataIfNeeded( extra_data ): diff --git a/third_party/ycmd/ycmd/ycmd.py b/third_party/ycmd/ycmd/__main__.py similarity index 95% rename from third_party/ycmd/ycmd/ycmd.py rename to third_party/ycmd/ycmd/__main__.py index b9a6c602..37049aa2 100755 --- a/third_party/ycmd/ycmd/ycmd.py +++ b/third_party/ycmd/ycmd/__main__.py @@ -28,11 +28,11 @@ import waitress import signal import os import base64 -from ycm import user_options_store -from ycm import extra_conf_store -from ycm import utils -from ycm.server.watchdog_plugin import WatchdogPlugin -from ycm.server.hmac_plugin import HmacPlugin +from ycmd import user_options_store +from ycmd import extra_conf_store +from ycmd import utils +from ycmd.watchdog_plugin import WatchdogPlugin +from ycmd.hmac_plugin import HmacPlugin def YcmCoreSanityCheck(): if 'ycm_core' in sys.modules: @@ -126,7 +126,7 @@ def Main(): # This can't be a top-level import because it transitively imports # ycm_core which we want to be imported ONLY after extra conf # preload has executed. - from ycm.server import handlers + from ycmd import handlers handlers.UpdateUserOptions( options ) SetUpSignalHandler(args.stdout, args.stderr, args.keep_logfiles) handlers.app.install( WatchdogPlugin( args.idle_suicide_seconds ) ) diff --git a/third_party/ycmd/ycmd/completers/all/identifier_completer.py b/third_party/ycmd/ycmd/completers/all/identifier_completer.py index 5baa0eed..cd0f8b8a 100644 --- a/third_party/ycmd/ycmd/completers/all/identifier_completer.py +++ b/third_party/ycmd/ycmd/completers/all/identifier_completer.py @@ -21,11 +21,10 @@ import os import logging import ycm_core from collections import defaultdict -from ycm.completers.general_completer import GeneralCompleter -# from ycm.completers.general import syntax_parse -from ycm import utils -from ycm.utils import ToUtf8IfNeeded -from ycm.server import responses +from ycmd.completers.general_completer import GeneralCompleter +from ycmd import utils +from ycmd.utils import ToUtf8IfNeeded +from ycmd import responses MAX_IDENTIFIER_COMPLETIONS_RETURNED = 10 SYNTAX_FILENAME = 'YCM_PLACEHOLDER_FOR_SYNTAX' diff --git a/third_party/ycmd/ycmd/completers/all/tests/identifier_completer_test.py b/third_party/ycmd/ycmd/completers/all/tests/identifier_completer_test.py index 6ded7173..176b5dd9 100644 --- a/third_party/ycmd/ycmd/completers/all/tests/identifier_completer_test.py +++ b/third_party/ycmd/ycmd/completers/all/tests/identifier_completer_test.py @@ -18,7 +18,7 @@ # along with YouCompleteMe. If not, see . from nose.tools import eq_ -from ycm.completers.all import identifier_completer +from ycmd.completers.all import identifier_completer def GetCursorIdentifier_StartOfLine_test(): diff --git a/third_party/ycmd/ycmd/completers/c/hook.py b/third_party/ycmd/ycmd/completers/c/hook.py index 2d8b3481..7d30c02f 100644 --- a/third_party/ycmd/ycmd/completers/c/hook.py +++ b/third_party/ycmd/ycmd/completers/c/hook.py @@ -18,7 +18,7 @@ # along with YouCompleteMe. If not, see . import ycm_core -from ycm.completers.cpp.clang_completer import ClangCompleter +from ycmd.completers.cpp.clang_completer import ClangCompleter def GetCompleter( user_options ): if ycm_core.HasClangSupport(): diff --git a/third_party/ycmd/ycmd/completers/completer.py b/third_party/ycmd/ycmd/completers/completer.py index 33f367d0..5a1e05eb 100644 --- a/third_party/ycmd/ycmd/completers/completer.py +++ b/third_party/ycmd/ycmd/completers/completer.py @@ -20,15 +20,15 @@ import abc import threading from collections import defaultdict -from ycm.utils import ToUtf8IfNeeded, ForceSemanticCompletion, RunningInsideVim +from ycmd.utils import ToUtf8IfNeeded, ForceSemanticCompletion, RunningInsideVim if RunningInsideVim(): from ycm_client_support import FilterAndSortCandidates else: from ycm_core import FilterAndSortCandidates -from ycm.completers.completer_utils import TriggersForFiletype -from ycm.server.responses import NoDiagnosticSupport +from ycmd.completers.completer_utils import TriggersForFiletype +from ycmd.responses import NoDiagnosticSupport NO_USER_COMMANDS = 'This completer does not define any commands.' @@ -70,7 +70,7 @@ class Completer( object ): "foo.bar", the user query is "bar" and completions matching this string should be shown. It should return the list of candidates. The format of the result can be a list of strings or a more complicated list of dictionaries. Use - ycm.server.responses.BuildCompletionData to build the detailed response. See + ycmd.responses.BuildCompletionData to build the detailed response. See clang_completer.py to see how its used in practice. Again, you probably want to override ComputeCandidatesInner(). diff --git a/third_party/ycmd/ycmd/completers/completer_utils_test.py b/third_party/ycmd/ycmd/completers/completer_utils_test.py index c182443c..07938943 100644 --- a/third_party/ycmd/ycmd/completers/completer_utils_test.py +++ b/third_party/ycmd/ycmd/completers/completer_utils_test.py @@ -19,9 +19,7 @@ from collections import defaultdict from nose.tools import eq_ -from ycm.test_utils import MockVimModule -vim_mock = MockVimModule() -from ycm.completers import completer_utils +from ycmd.completers import completer_utils def FiletypeTriggerDictFromSpec_Works_test(): diff --git a/third_party/ycmd/ycmd/completers/cpp/clang_completer.py b/third_party/ycmd/ycmd/completers/cpp/clang_completer.py index e358e57b..4890b7a5 100644 --- a/third_party/ycmd/ycmd/completers/cpp/clang_completer.py +++ b/third_party/ycmd/ycmd/completers/cpp/clang_completer.py @@ -19,11 +19,11 @@ from collections import defaultdict import ycm_core -from ycm.server import responses -from ycm import extra_conf_store -from ycm.utils import ToUtf8IfNeeded -from ycm.completers.completer import Completer -from ycm.completers.cpp.flags import Flags, PrepareFlagsForClang +from ycmd import responses +from ycmd import extra_conf_store +from ycmd.utils import ToUtf8IfNeeded +from ycmd.completers.completer import Completer +from ycmd.completers.cpp.flags import Flags, PrepareFlagsForClang CLANG_FILETYPES = set( [ 'c', 'cpp', 'objc', 'objcpp' ] ) MIN_LINES_IN_FILE_TO_PARSE = 5 diff --git a/third_party/ycmd/ycmd/completers/cpp/flags.py b/third_party/ycmd/ycmd/completers/cpp/flags.py index c2e4377f..3c48171c 100644 --- a/third_party/ycmd/ycmd/completers/cpp/flags.py +++ b/third_party/ycmd/ycmd/completers/cpp/flags.py @@ -20,9 +20,9 @@ import ycm_core import os import inspect -from ycm import extra_conf_store -from ycm.utils import ToUtf8IfNeeded -from ycm.server.responses import NoExtraConfDetected +from ycmd import extra_conf_store +from ycmd.utils import ToUtf8IfNeeded +from ycmd.responses import NoExtraConfDetected INCLUDE_FLAGS = [ '-isystem', '-I', '-iquote', '--sysroot=', '-isysroot', '-include' ] diff --git a/third_party/ycmd/ycmd/completers/cpp/hook.py b/third_party/ycmd/ycmd/completers/cpp/hook.py index 2d8b3481..7d30c02f 100644 --- a/third_party/ycmd/ycmd/completers/cpp/hook.py +++ b/third_party/ycmd/ycmd/completers/cpp/hook.py @@ -18,7 +18,7 @@ # along with YouCompleteMe. If not, see . import ycm_core -from ycm.completers.cpp.clang_completer import ClangCompleter +from ycmd.completers.cpp.clang_completer import ClangCompleter def GetCompleter( user_options ): if ycm_core.HasClangSupport(): diff --git a/third_party/ycmd/ycmd/completers/cs/cs_completer.py b/third_party/ycmd/ycmd/completers/cs/cs_completer.py index 574e95ad..a8dff336 100755 --- a/third_party/ycmd/ycmd/completers/cs/cs_completer.py +++ b/third_party/ycmd/ycmd/completers/cs/cs_completer.py @@ -21,9 +21,9 @@ from collections import defaultdict import os import glob -from ycm.completers.completer import Completer -from ycm.server import responses -from ycm import utils +from ycmd.completers.completer import Completer +from ycmd import responses +from ycmd import utils import urllib2 import urllib import urlparse @@ -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__ ) ), - '../../../../third_party/OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) + '../../../../OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) #TODO: Handle this better than dummy classes diff --git a/third_party/ycmd/ycmd/completers/cs/hook.py b/third_party/ycmd/ycmd/completers/cs/hook.py index d266191c..489c7ce2 100644 --- a/third_party/ycmd/ycmd/completers/cs/hook.py +++ b/third_party/ycmd/ycmd/completers/cs/hook.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see . -from ycm.completers.cs.cs_completer import CsharpCompleter +from ycmd.completers.cs.cs_completer import CsharpCompleter def GetCompleter( user_options ): return CsharpCompleter( user_options ) diff --git a/third_party/ycmd/ycmd/completers/general/filename_completer.py b/third_party/ycmd/ycmd/completers/general/filename_completer.py index 77195909..81923ccf 100644 --- a/third_party/ycmd/ycmd/completers/general/filename_completer.py +++ b/third_party/ycmd/ycmd/completers/general/filename_completer.py @@ -20,11 +20,11 @@ import os import re from collections import defaultdict -from ycm.completers.completer import Completer -from ycm.completers.cpp.clang_completer import InCFamilyFile -from ycm.completers.cpp.flags import Flags -from ycm.utils import ToUtf8IfNeeded -from ycm.server import responses +from ycmd.completers.completer import Completer +from ycmd.completers.cpp.clang_completer import InCFamilyFile +from ycmd.completers.cpp.flags import Flags +from ycmd.utils import ToUtf8IfNeeded +from ycmd import responses EXTRA_INFO_MAP = { 1 : '[File]', 2 : '[Dir]', 3 : '[File&Dir]' } diff --git a/third_party/ycmd/ycmd/completers/general/general_completer_store.py b/third_party/ycmd/ycmd/completers/general/general_completer_store.py index 2e46ef37..eea83578 100644 --- a/third_party/ycmd/ycmd/completers/general/general_completer_store.py +++ b/third_party/ycmd/ycmd/completers/general/general_completer_store.py @@ -18,10 +18,10 @@ # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see . -from ycm.completers.completer import Completer -from ycm.completers.all.identifier_completer import IdentifierCompleter -from ycm.completers.general.filename_completer import FilenameCompleter -from ycm.completers.general.ultisnips_completer import UltiSnipsCompleter +from ycmd.completers.completer import Completer +from ycmd.completers.all.identifier_completer import IdentifierCompleter +from ycmd.completers.general.filename_completer import FilenameCompleter +from ycmd.completers.general.ultisnips_completer import UltiSnipsCompleter class GeneralCompleterStore( Completer ): diff --git a/third_party/ycmd/ycmd/completers/general/tests/filename_completer_test.py b/third_party/ycmd/ycmd/completers/general/tests/filename_completer_test.py index 28f236c8..9111dfe8 100644 --- a/third_party/ycmd/ycmd/completers/general/tests/filename_completer_test.py +++ b/third_party/ycmd/ycmd/completers/general/tests/filename_completer_test.py @@ -19,8 +19,8 @@ import os from nose.tools import eq_ -from ycm.completers.general.filename_completer import FilenameCompleter -from ycm import user_options_store +from ycmd.completers.general.filename_completer import FilenameCompleter +from ycmd import user_options_store test_dir = os.path.dirname( os.path.abspath( __file__ ) ) data_dir = os.path.join( test_dir, "testdata", "filename_completer" ) diff --git a/third_party/ycmd/ycmd/completers/general/ultisnips_completer.py b/third_party/ycmd/ycmd/completers/general/ultisnips_completer.py index d1e8a2d4..5d562431 100644 --- a/third_party/ycmd/ycmd/completers/general/ultisnips_completer.py +++ b/third_party/ycmd/ycmd/completers/general/ultisnips_completer.py @@ -18,8 +18,8 @@ # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see . -from ycm.completers.general_completer import GeneralCompleter -from ycm.server import responses +from ycmd.completers.general_completer import GeneralCompleter +from ycmd import responses class UltiSnipsCompleter( GeneralCompleter ): diff --git a/third_party/ycmd/ycmd/completers/general_completer.py b/third_party/ycmd/ycmd/completers/general_completer.py index 717d97e1..72b3d265 100644 --- a/third_party/ycmd/ycmd/completers/general_completer.py +++ b/third_party/ycmd/ycmd/completers/general_completer.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see . -from ycm.completers.completer import Completer +from ycmd.completers.completer import Completer class GeneralCompleter( Completer ): """ diff --git a/third_party/ycmd/ycmd/completers/objc/hook.py b/third_party/ycmd/ycmd/completers/objc/hook.py index 48e66ec3..d0ca40b0 100644 --- a/third_party/ycmd/ycmd/completers/objc/hook.py +++ b/third_party/ycmd/ycmd/completers/objc/hook.py @@ -18,7 +18,7 @@ # along with YouCompleteMe. If not, see . import ycm_core -from ycm.completers.cpp.clang_completer import ClangCompleter +from ycmd.completers.cpp.clang_completer import ClangCompleter def GetCompleter( user_options ): if ycm_core.HasClangSupport(): diff --git a/third_party/ycmd/ycmd/completers/objcpp/hook.py b/third_party/ycmd/ycmd/completers/objcpp/hook.py index 2d8b3481..7d30c02f 100644 --- a/third_party/ycmd/ycmd/completers/objcpp/hook.py +++ b/third_party/ycmd/ycmd/completers/objcpp/hook.py @@ -18,7 +18,7 @@ # along with YouCompleteMe. If not, see . import ycm_core -from ycm.completers.cpp.clang_completer import ClangCompleter +from ycmd.completers.cpp.clang_completer import ClangCompleter def GetCompleter( user_options ): if ycm_core.HasClangSupport(): diff --git a/third_party/ycmd/ycmd/completers/python/hook.py b/third_party/ycmd/ycmd/completers/python/hook.py index 690b7923..9421a84d 100644 --- a/third_party/ycmd/ycmd/completers/python/hook.py +++ b/third_party/ycmd/ycmd/completers/python/hook.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see . -from ycm.completers.python.jedi_completer import JediCompleter +from ycmd.completers.python.jedi_completer import JediCompleter def GetCompleter( user_options ): return JediCompleter( user_options ) diff --git a/third_party/ycmd/ycmd/completers/python/jedi_completer.py b/third_party/ycmd/ycmd/completers/python/jedi_completer.py index 283106b9..6e49c42c 100644 --- a/third_party/ycmd/ycmd/completers/python/jedi_completer.py +++ b/third_party/ycmd/ycmd/completers/python/jedi_completer.py @@ -19,8 +19,8 @@ # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see . -from ycm.completers.completer import Completer -from ycm.server import responses +from ycmd.completers.completer import Completer +from ycmd import responses try: import jedi diff --git a/third_party/ycmd/ycmd/extra_conf_store.py b/third_party/ycmd/ycmd/extra_conf_store.py index 9262ba2d..1e471218 100644 --- a/third_party/ycmd/ycmd/extra_conf_store.py +++ b/third_party/ycmd/ycmd/extra_conf_store.py @@ -26,8 +26,8 @@ import string import sys import logging from threading import Lock -from ycm import user_options_store -from ycm.server.responses import UnknownExtraConf, YCM_EXTRA_CONF_FILENAME +from ycmd import user_options_store +from ycmd.responses import UnknownExtraConf, YCM_EXTRA_CONF_FILENAME from fnmatch import fnmatch diff --git a/third_party/ycmd/ycmd/handlers.py b/third_party/ycmd/ycmd/handlers.py index ceab2c06..a2758348 100644 --- a/third_party/ycmd/ycmd/handlers.py +++ b/third_party/ycmd/ycmd/handlers.py @@ -26,7 +26,7 @@ except ImportError as e: 'Error importing ycm_core. Are you sure you have placed a ' 'version 3.2+ libclang.[so|dll|dylib] in folder "{0}"? ' 'See the Installation Guide in the docs. Full error: {1}'.format( - path.realpath( path.join( path.abspath( __file__ ), '../../..' ) ), + path.realpath( path.join( path.abspath( __file__ ), '../..' ) ), str( e ) ) ) import atexit @@ -36,10 +36,10 @@ import bottle import httplib from bottle import request, response import server_state -from ycm import user_options_store -from ycm.server.responses import BuildExceptionResponse -from ycm.server import hmac_plugin -from ycm import extra_conf_store +from ycmd import user_options_store +from ycmd.responses import BuildExceptionResponse +from ycmd import hmac_plugin +from ycmd import extra_conf_store # num bytes for the request body buffer; request.json only works if the request diff --git a/third_party/ycmd/ycmd/hmac_plugin.py b/third_party/ycmd/ycmd/hmac_plugin.py index fec899bd..a4436752 100644 --- a/third_party/ycmd/ycmd/hmac_plugin.py +++ b/third_party/ycmd/ycmd/hmac_plugin.py @@ -21,7 +21,7 @@ import logging import httplib from base64 import b64decode, b64encode from bottle import request, response, abort -from ycm import utils +from ycmd import utils _HMAC_HEADER = 'x-ycm-hmac' diff --git a/third_party/ycmd/ycmd/server_state.py b/third_party/ycmd/ycmd/server_state.py index 8bc16b20..a0d60e8b 100644 --- a/third_party/ycmd/ycmd/server_state.py +++ b/third_party/ycmd/ycmd/server_state.py @@ -19,9 +19,9 @@ import imp import os -from ycm.utils import ForceSemanticCompletion -from ycm.completers.general.general_completer_store import GeneralCompleterStore -from ycm.completers.completer_utils import PathToFiletypeCompleterPluginLoader +from ycmd.utils import ForceSemanticCompletion +from ycmd.completers.general.general_completer_store import GeneralCompleterStore +from ycmd.completers.completer_utils import PathToFiletypeCompleterPluginLoader class ServerState( object ): diff --git a/third_party/ycmd/ycmd/server_utils.py b/third_party/ycmd/ycmd/server_utils.py index 20a90501..ef3a476b 100644 --- a/third_party/ycmd/ycmd/server_utils.py +++ b/third_party/ycmd/ycmd/server_utils.py @@ -21,14 +21,9 @@ import sys import os def SetUpPythonPath(): - # We want to have the YouCompleteMe/python directory on the Python PATH - # because all the code already assumes that it's there. This is a relic from - # before the client/server architecture. - # TODO: Fix things so that this is not needed anymore when we split ycmd into - # a separate repository. sys.path.insert( 0, os.path.join( os.path.dirname( os.path.abspath( __file__ ) ), - '../..' ) ) + '..' ) ) - from ycm import utils + from ycmd import utils utils.AddThirdPartyFoldersToSysPath() diff --git a/third_party/ycmd/ycmd/tests/extra_conf_store_test.py b/third_party/ycmd/ycmd/tests/extra_conf_store_test.py index f06005ee..e5771005 100644 --- a/third_party/ycmd/ycmd/tests/extra_conf_store_test.py +++ b/third_party/ycmd/ycmd/tests/extra_conf_store_test.py @@ -18,9 +18,7 @@ # along with YouCompleteMe. If not, see . from nose.tools import eq_ -from ycm.test_utils import MockVimModule -vim_mock = MockVimModule() -from ycm.extra_conf_store import _PathsToAllParentFolders +from ycmd.extra_conf_store import _PathsToAllParentFolders def PathsToAllParentFolders_Basic_test(): diff --git a/third_party/ycmd/ycmd/tests/test_utils.py b/third_party/ycmd/ycmd/tests/test_utils.py index 0d09ddcb..8f823bee 100644 --- a/third_party/ycmd/ycmd/tests/test_utils.py +++ b/third_party/ycmd/ycmd/tests/test_utils.py @@ -20,7 +20,7 @@ import os import time from .. import handlers -from ycm import user_options_store +from ycmd import user_options_store def BuildRequest( **kwargs ): filepath = kwargs[ 'filepath' ] if 'filepath' in kwargs else '/foo' diff --git a/third_party/ycmd/ycmd/user_options_store.py b/third_party/ycmd/ycmd/user_options_store.py index 31efa87c..3b4881ba 100644 --- a/third_party/ycmd/ycmd/user_options_store.py +++ b/third_party/ycmd/ycmd/user_options_store.py @@ -42,8 +42,7 @@ def LoadDefaults(): def DefaultOptions(): settings_path = os.path.join( - os.path.dirname( os.path.abspath( __file__ ) ), - 'server/default_settings.json' ) + os.path.dirname( os.path.abspath( __file__ ) ), 'default_settings.json' ) with open( settings_path ) as f: return json.loads( f.read() ) diff --git a/third_party/ycmd/ycmd/utils.py b/third_party/ycmd/ycmd/utils.py index b557dc04..d689a602 100644 --- a/third_party/ycmd/ycmd/utils.py +++ b/third_party/ycmd/ycmd/utils.py @@ -191,15 +191,35 @@ def TerminateProcess( pid ): os.kill( pid, signal.SIGTERM ) +def AncestorFolders( path ): + folder = os.path.abspath( path ) + while True: + parent = os.path.dirname( folder ) + if parent == folder: + break + folder = parent + yield folder + + +def PathToNearestThirdPartyFolder( path ): + for folder in AncestorFolders( path ): + path_to_third_party = os.path.join( folder, 'third_party' ) + if os.path.isdir( path_to_third_party ): + return path_to_third_party + return None + + def AddThirdPartyFoldersToSysPath(): - path_to_third_party = os.path.join( - os.path.dirname( os.path.abspath( __file__ ) ), - '../../third_party' ) + path_to_third_party = PathToNearestThirdPartyFolder( __file__ ) + if not path_to_third_party: + raise RuntimeError( + 'No third_party folder found for: {0}'.format( __file__) ) for folder in os.listdir( path_to_third_party ): sys.path.insert( 0, os.path.realpath( os.path.join( path_to_third_party, folder ) ) ) + def ForceSemanticCompletion( request_data ): return ( 'force_semantic' in request_data and bool( request_data[ 'force_semantic' ] ) ) diff --git a/third_party/ycmd/ycmd/watchdog_plugin.py b/third_party/ycmd/ycmd/watchdog_plugin.py index cdf17b40..3e95a23a 100644 --- a/third_party/ycmd/ycmd/watchdog_plugin.py +++ b/third_party/ycmd/ycmd/watchdog_plugin.py @@ -20,7 +20,7 @@ import time import os import copy -from ycm import utils +from ycmd import utils from threading import Thread, Lock # This class implements the Bottle plugin API: