{"id":15975827,"url":"https://github.com/alexandrecarlton/ycmd-docker","last_synced_at":"2025-10-20T05:54:41.076Z","repository":{"id":147202812,"uuid":"106103253","full_name":"AlexandreCarlton/ycmd-docker","owner":"AlexandreCarlton","description":"A dockerised ycmd for YouCompleteMe","archived":false,"fork":false,"pushed_at":"2018-12-31T10:59:32.000Z","size":51,"stargazers_count":23,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-28T05:57:34.438Z","etag":null,"topics":["docker","vim","ycm","ycmd","ycmd-docker","youcompleteme"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexandreCarlton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-07T14:15:03.000Z","updated_at":"2024-07-01T06:10:42.000Z","dependencies_parsed_at":"2023-07-02T10:15:45.707Z","dependency_job_id":null,"html_url":"https://github.com/AlexandreCarlton/ycmd-docker","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":"0.24390243902439024","last_synced_commit":"81c3c50ec43a918070935756db09e71a9e2f0042"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreCarlton%2Fycmd-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreCarlton%2Fycmd-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreCarlton%2Fycmd-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexandreCarlton%2Fycmd-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexandreCarlton","download_url":"https://codeload.github.com/AlexandreCarlton/ycmd-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243893848,"owners_count":20364918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","vim","ycm","ycmd","ycmd-docker","youcompleteme"],"created_at":"2024-10-07T22:05:18.376Z","updated_at":"2025-10-08T03:51:41.031Z","avatar_url":"https://github.com/AlexandreCarlton.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ycmd-docker\n\n[![Build Status](https://travis-ci.org/AlexandreCarlton/ycmd-docker.svg?branch=master)](https://travis-ci.org/AlexandreCarlton/ycmd-docker)\n\nAn example of running a containerised [`ycmd`](https://github.com/Valloric/ycmd) to:\n - obviate the need to build `ycm_core.so`.\n - capture completion suggestions for libraries that may not be present on the\n   user's system when using [`YouCompleteMe`](https://github.com/Valloric/YouCompleteMe).\n\n## Motivation\n\n[`YouCompleteMe`](https://github.com/Valloric/YouCompleteMe) is a popular Vim\nplugin that provides the user with semantic completion. It has a client-server\narchitecture, with the server component [`ycmd`](https://github.com/Valloric/ycmd)\nproviding code-completion and comprehension.\nHowever, there is a pain point in that [`ycmd`](https://github.com/Valloric/ycmd)\nrequires the user compile `ycm_core.so` with a modern enough [CMake](https://cmake.org/)\nand [LibClang](https://clang.llvm.org/docs/Tooling.html) for it to function properly.\n\nFurthermore, more and more projects are using Docker containers to provide a\nuniform build environment containing all dependencies needed to build them.\nThese dependencies (usually libraries and headers) may not be present on the\nuser's system, and thus [`YouCompleteMe`](https://github.com/Valloric/YouCompleteMe)\nwill not be able to pick them up for completion.\n\n## Implementation\n\nNormally, [`YouCompleteMe`](https://github.com/Valloric/YouCompleteMe) fires up\n[`ycmd`](https://github.com/Valloric/ycmd) by invoking `python` on its nested\n[`ycmd` folder](https://github.com/Valloric/ycmd/tree/master/ycmd) (which\nessentially invokes the contained [`__main__.py`](https://github.com/Valloric/ycmd/blob/master/ycmd/__main__.py)).\nWe will configure [`YouCompleteMe`](https://github.com/Valloric/YouCompleteMe) to instead fire up our own Docker container\nby fooling it into thinking our script [`ycmd-python`](ycmd-python) is the Python\nserver interpreter (when it really just launches our own dockerized [`ycmd`](https://github.com/Valloric/ycmd)\ninstead).\n\n### Docker\n\nThe [`Dockerfile`](Dockerfile) provided is only intended as an example (though\nit can be used for basic completion).\nThe parent image [`ubuntu`](https://hub.docker.com/_/ubuntu/) should instead be\nreplaced with the build image, and subsequently [`apt-get`](https://linux.die.net/man/8/apt-get)\nwith the corresponding package manager for that image.\n\n### Vim\n\nWe copy the [`ycmd-python`](ycmd-python) script somewhere into our `$PATH`,\ntweaking the image name as necessary.\n\nWe then override `g:ycm_server_python_interpreter` to launch our own container,\nusing an image which has both our dependencies (headers, libraries, etc) and\n[`ycmd`](https://github.com/Valloric/ycmd):\n\n```vim\nPlug 'Valloric/YouCompleteMe'\nlet g:ycm_server_python_interpreter = 'ycmd-python'\n```\n\nIt is imperative that the name of [`ycmd-python`](ycmd-python) ends with\n`python` (should it need to be changed), else [`YouCompleteMe`](https://github.com/Valloric/YouCompleteMe)\nwill refuse to launch it.\n\n### Emacs / Spacemacs\n\n**NB:** I have little success with this; while in theory this should work [`emacs-ycmd`](https://github.com/abingham/emacs-ycmd)\nfails to contact the launched Docker container.\n\nEmacs integration with [`ycmd`](https://github.com/Valloric/ycmd) is provided through [`emacs-ycmd`](https://github.com/abingham/emacs-ycmd).\n[Spacemacs](http://spacemacs.org) provides this package through its [`ycmd` layer](https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Btools/ycmd).\n\nTo use our container here, we override `ycmd-server-command` to use our binary:\n\n```elisp\n(setq ycmd-server-command '(\"ycmd-python\")')\n```\n\nThere does not appear to be any restriction on the name of [`ycmd-python`](ycmd-python),\nthough filename expansion is not supported for characters like `~`, so it may\nbe necessary to use `file-truename` to expand it.\n\n## Diagnostics\n\n### Locating the container instance\nA typical YouCompleteMe instance will display the following diagnostics with\n`:YcmDebugInfo`:\n\n```\nPrinting YouCompleteMe debug information...\n...\n-- Server running at: http://127.0.0.1:8888\n-- Server process ID: 12345\n...\n```\n\nNormally we would use the process ID to locate the running instance and monitor\nit.\nHowever, as we are using docker to run this, we cannot use this method.\nTo make this easier for the user, the containers launched using [`ycmd-python`](ycmd-python)\nwill have the format `ycmd-\u003cpid\u003e`, so that this will match what we see in the\ndiagnostic information.\nIn this instance, we would look for the container `ycmd-12345` using\n`docker ps -a`.\n\n### Retrieving logs\nA regular installation of YouCompleteMe will start a server that logs to\nseveral files, which can be inspected using `:YcmDebugInfo`:\n\n```\nPrinting YouCompleteMe debug information...\n...\n-- Server running at: http://127.0.0.1:8888\n...\n-- Server logfiles:\n--   /tmp/ycmd_8888_stdout_abcdefgh.log\n--   /tmp/ycmd_8888_stderr_ijklmnop.log\n...\n```\n\nHowever, on a long running server this will result in log files that may never\nbe cleaned up.\n\nTo resolve this, we do not copy across the arguments provided to the `stdout`\nand `stderr` options so that `ycmd` will log to `/dev/stdout` and `/dev/stderr`\nrespectively, and clean this up when we are done with them.\nTo retrieve them, we can use `docker logs` on the particular instance that we\nwant (using the process ID as described above).\n\nNote that [`YouCompleteMe` will still create these files regardless of whether\nthey end up being used](https://github.com/Valloric/YouCompleteMe/blob/28292f0f62e6352111b694ce8753bf739b50fb40/python/ycm/youcompleteme.py#L175),\nthough they will remain empty.\n\n## Caveats\n\n### Python completion\n\n[`YouCompleteMe`](https://github.com/Valloric/YouCompleteMe) uses\n[`jedi`](https://github.com/davidhalter/jedi) for Python\nsemantic completion. By default, it uses the same python interpreter used to\nrun [`ycmd`](https://github.com/Valloric/ycmd) (which in the example image is `/usr/bin/python3`).\n\nIn order to capture completions for third-party libraries found in a\nvirtual environment, one can tweak their `.vimrc` to point to the currently\nactive python:\n\n```vim\nlet g:ycm_python_binary_path = 'python'\n```\n\n[`ycmd-python`](ycmd-python) will automatically pick this up if the activated virtual\nenvironment lies in `$HOME`.\n\n### `:YcmCompleter GoTo`\n\nYou will not be able to jump to a file that is located only inside the\ncontainer, as your editor will not be able to find it in the host filesystem.\n\n## Updating\n\nEach version of [`YouCompleteMe`](https://github.com/Valloric/YouCompleteMe) is\ndesigned for a particular [`ycmd`](https://github.com/Valloric/ycmd) revision.\nAs such, every time we update our `YouCompleteMe` instance this image should\nalso be updated accordingly.\n\nThis is done by tweaking the `YCMD_REVISION` variable in the [Makefile](Makefile)\nto match the [corresponding version used in `YouCompleteMe`](https://github.com/Valloric/YouCompleteMe/tree/master/third_party).\n\nFurthermore, we should transfer any differences in the original [`examples/example_client.py`](https://github.com/Valloric/ycmd/blob/master/examples/example_client.py)\nand the samples found in [`examples/samples`](https://github.com/Valloric/ycmd/tree/master/examples/samples)\nacross into our repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrecarlton%2Fycmd-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexandrecarlton%2Fycmd-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrecarlton%2Fycmd-docker/lists"}