Docker image + scripts for running lsp-mode
in docker
environment.
- Preconfigured language servers
- Usage
- docker Language Server running over local sources (only Linux/MacOS)
- docker over TRAMP (TBD)
- See also
The docker has the following content:
Emacs27
compiled with native JSON support for better performance.- Spacemacs configuration(.spacemacs) with enabled language servers.
- Minimal vanilla configuration (init.el) installing and configuring all the language servers from the table above.
- Language servers:
Language Language Server Bash bash-language-server C++ ccls C++ clangd CSS/LessCSS/SASS/SCSS css Dockerfile dockerfile-language-server-nodejs F# fsautocomplete Go gopls HTML html Java Eclipse JDT LS JavaScript/TypeScript typescript-language-server (recommended) JavaScript/TypeScript javascript-typescript-stdio JavaScript Flow flow (add-on if working on a Flow file) Kotlin kotlin-language-server PHP(recommended) intelephense Python pyls Python(Microsoft) Microsoft Python Language Server Ruby solargraph Rust rls Scala Metals Vue vue-language-server XML lsp4xml
There are 3 supported modes:
Run emacs and language servers in the docker container.
- Clone spacemacs repo
# Clone spacemacs develop
git clone -b develop https://github.com/syl20bnr/spacemacs ~/.emacs.d-docker
- Clone
lsp-docker
.
git clone https://github.com/emacs-lsp/lsp-docker
- Run
docker run -ti --rm -v $('pwd'):/mnt/workspace \ -v /etc/localtime:/etc/localtime:ro \ -v ~/.gnupg:${UHOME}/.gnupg \ -v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v /etc/machine-id:/etc/machine-id:ro \ -v ~/.emacs.d-docker/:/root/.emacs.d \ -v $(pwd)/dotspacemacs.el:/root/.spacemacs \ -v $(pwd)/demo-projects/:/Projects \ -e DISPLAY=$DISPLAY \ -e TZ=UA \ yyoncho/lsp-emacs-docker emacs
docker run -ti --rm -v $('pwd'):/mnt/workspace \
-v /etc/localtime:/etc/localtime:ro \
-v ~/.gnupg:${UHOME}/.gnupg \
-v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /etc/machine-id:/etc/machine-id:ro \
-v $(pwd)/demo-projects/:/Projects \
-v $(pwd)/emacs.d/:/root/.emacs.d \
-e DISPLAY=$DISPLAY \
-e TZ=UA \
yyoncho/lsp-emacs-docker emacs
In this mode, lsp-mode
runs the Language Server
in docker
container over local sources.
- Clone repo.
git clone https://github.com/emacs-lsp/lsp-docker
- add it to load path and register the docker clients(currently
pyls
andrls
are supported, but adding other clients is trivial).
(with-eval-after-load 'lsp-clients
(add-to-list 'load-path "<path-to-lsp-docker-dir>")
(require 'lsp-docker)
;; register the clients
(lsp-docker-init-default-clients
:path-mappings '(("path-to-projects-you-want-to-use" . "/projects"))
:docker-image-id "yyoncho/lsp-emacs-docker"
:docker-container-name "lsp-container"
:priority 2))
lsp-mode
starts the image passed as :docker-image-id
and mounts :path-mappings
in the container. Then when the process is started lsp-mode
translates the local paths to docker
path and vice versa using the :path-mappings
specified when calling lsp-docker-init-default-clients
. You may use lsp-enabled-clients
and lsp-disabled-clients
to control what language server will be used to run for a particular project(refer to lsp-mode
FAQ on how to configure .dir-locals).
Docker running the language servers and hosting the sources, Emacs running on the desktop machine and connecting to docker instance over TRAMP.
- docker - package for managing
docker
images/containers.