this post was submitted on 22 Nov 2023
1 points (100.0% liked)

Emacs

313 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

Have been using emacs for a while now with doom and have a question to the community:

When you have a project inside of docker with packages instead by pip, how to you have your eMacs and LSP resolve the import statements?

I have heard of TRAMP but this seems like a solution for jacking into a docker container that is running to just modify files.

Thanks, Aaron

you are viewing a single comment's thread
view the rest of the comments
[–] yurikhan@alien.top 1 points 1 year ago

My solution is to run the language server in a container created from the (almost) same image.

Step 1: From your “production” docker image, derive a “development” image that installs the language server.

Step 2: Write a docker-compose.yaml that defines a service that is based on the development image and mounts the project directory.

Step 3: In your .dir-locals.el for the project, configure Eglot to use docker-compose run --rm -w {mounted project root} {service name} {language server command line}.

What I get is navigation through my project code, and documentation/completion over libraries. What I don’t get is navigation into libraries (because they exist only in the container and in this setup Emacs only deals with files on the host.)

I have also worked with a guy who mounted his PyCharm installation and config directories and the X11 socket and the /dev/dri device inside the container, and ran an instance of the IDE inside the development container. This gave him all the advantages of working directly with the project and libraries, but the disadvantage that the IDE is separated from the host.