Closed fvdnabee closed 2 years ago
Hi. We've had this discussion with another user in gitter.
Mostly, you have identified the big problems. There's one more thing.
bstaletic@Gallifrey YouCompleteMe (git)-[remotes/origin/HEAD]-% rg '(from|import) ycmd' python/ycm --vimgrep
python/ycm/omni_completer.py:20:1:from ycmd import utils
python/ycm/omni_completer.py:21:1:from ycmd.completers.completer import Completer
python/ycm/base.py:19:1:from ycmd import identifier_utils
python/ycm/paths.py:38:3: from ycmd import utils
python/ycm/paths.py:73:3: from ycmd import utils
python/ycm/youcompleteme.py:28:1:from ycmd import utils
python/ycm/youcompleteme.py:29:1:from ycmd.request_wrap import RequestWrap
python/ycm/signature_help.py:21:1:from ycmd import utils
python/ycm/vimsupport.py:23:1:from ycmd.utils import ( ByteOffsetToCodepointOffset,
python/ycm/client/completion_request.py:20:1:from ycmd.utils import ToUnicode
python/ycm/client/command_request.py:20:1:from ycmd.utils import ToUnicode
python/ycm/client/base_request.py:25:1:from ycmd.utils import ToBytes, GetCurrentDirectory
python/ycm/client/base_request.py:26:1:from ycmd.hmac_utils import CreateRequestHmac, CreateHmac
python/ycm/client/base_request.py:27:1:from ycmd.responses import ServerError, UnknownExtraConf
python/ycm/tests/conftest.py:30:1:from ycmd.utils import CloseStandardStreams, WaitUntilProcessIsTerminated
python/ycm/tests/youcompleteme_test.py:45:1:from ycmd.responses import ServerError
python/ycm/tests/postcomplete_test.py:29:1:from ycmd.utils import ToBytes
python/ycm/tests/completion_test.py:27:1:from ycmd.responses import ServerError
python/ycm/tests/vimsupport_test.py:27:1:from ycmd.utils import ToBytes
python/ycm/tests/syntax_parse_test.py:25:1:from ycmd.utils import ReadFile
python/ycm/tests/event_notification_test.py:29:1:from ycmd.responses import ( BuildDiagnosticData, Diagnostic, Location, Range,
python/ycm/tests/test_utils.py:31:1:from ycmd.utils import GetCurrentDirectory, OnMac, OnWindows, ToUnicode
bstaletic@Gallifrey YouCompleteMe (git)-[remotes/origin/HEAD]-% rg default_settings plugin --vimgrep
plugin/youcompleteme.vim:89:38: \ '/../third_party/ycmd/ycmd/default_settings.json'
plugin/youcompleteme.vim:301:3:" default_settings.json. This ensures that any part of ycm that uses ycmd code
YCM directly imports utilities from ycmd. This is done by having ycmd
in PYTHONPATH. I see two ways of solving this:
protoycmd
that both projects depend on.PYTHONPATH
.Solving this problem would also help packaging ycmd. It would be nice to be able to do python -m pip install ycmd
, but it's a pain in the ass and only slightly related to making a containerized ycmd.
Thanks for your input @bstaletic, here and on gitter.
After some hacking, I got ycmd to respond to completion requests from ycm in vim on the host machine.
Some findings:
BaseRequest.server_location
). With container port publishing via docker-run -p, traffic stems from the private network shared between the container and the host. YouCompleteMe:_SetUpServer
. The SafePopen should be able to call docker-run directly. Also monitoring the docker run process should provide similar semantics as is currently the case for monitoring the ycmd process directly (via .poll()). A nice side effect is that when vim exits, the container stops as ycmd receives a shutdown request (ycmd is the entrypoint of the container).PathToPythonInterpreter
and DIR_OF_YCMD
in ycm/paths.py
, but specifying the interpreter in the projects .ycm_extra_conf.py
seems like a more satisfactory solution.GoToDefinition
for project dependencies. I also made sure to start vim from the bind mounted location on the host, so that the file paths for ycm and ycmd were identical. I'm unaware the downsides of sshfs, but I'm guessing it isn't a filesystem known for its performant IO; even over a private network on the same machine.I'd love to run ycmd on a remote server perhaps over an ssh tunnel to make it look like localhost traffic. Any progress or advice on this?
I just found this, which is very pretty interesting https://github.com/AlexandreCarlton/ycmd-docker
It's not quite the same use case (just running ycmd in a container to minimise dependency hell), but it's an interesting take.
Running ycmd In a container or on a remote host is not considered in scope at the moment.
Issue Prelude
Please complete these steps and check these boxes (by putting an
x
inside the brackets) before filing your issue:vim --version
.:YcmDebugInfo
.:YcmToggleLogs
command.vim -Nu /path/to/YCM/vimrc_ycm_minimal
, including what I expected to happen and what actually happened.install.py
(orcmake
/make
/ninja
) including its invocationThank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.
Feature Details
Use case
This issue contains a feature request for using YCM with containers. The use case are python projects where the development environment assumes containerization of the project for e.g. dependency management. IDEs like vscode and pycharm support remote development inside containers.
Setup
After some discussions on gibber, a setup where ycmd runs in the development container and ycm on the host machine was identified as a feasible approach. The project folder would be bind mounted in the container, so that changes made in VIM on the host system are visible to ycmd in the container.
Changes to ycm(d)
The following changes were identified:
ycm_core.so
to be compatible with the container's environment. There would be a dedicated ycmd install within the container, apart from the host ycmd install..ycm_extra_conf.py
would be a good candidate to signal to ycm that it should run ycmd inside the dev docker for that project.Feedback welcomed
I've opened this issue to solicit feedback on the feature request. I'm hoping to find some time this month to work on a PR. Any blatant problems or anticipated problems with the approach outlined above are welcomed.