ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.44k stars 2.81k forks source link

YCM and Containers #3716

Closed fvdnabee closed 2 years ago

fvdnabee commented 4 years ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Thank 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:

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.

bstaletic commented 4 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:

  1. Duplicate the code, so that YCM gets its own copy of the utilities it needs.
  2. Make something like protoycmd that both projects depend on.
  3. Make ycmd's path configurable, but keep it in 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.

fvdnabee commented 4 years ago

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:

wffurr commented 4 years ago

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?

puremourning commented 3 years ago

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.

puremourning commented 2 years ago

Running ycmd In a container or on a remote host is not considered in scope at the moment.