emacs-lsp / lsp-docker

Scripts and configurations to leverage lsp-mode in docker environment
GNU General Public License v3.0
248 stars 34 forks source link

Questions: Find definition from libraries installed in container #21

Open ztlevi opened 4 years ago

ztlevi commented 4 years ago

It seems like we are not able to jump to definitions where the source codes are installed as libraries in the docker container. For example, jump to native python libraries.

I'm not sure how to make this happen. So I tried to open emacs in the docker container with emacslsp/lsp-docker-full, then of course, we could jump to that definition.

But I got another question. How to start emacs as gui from docker? There must some command line args that I don't know and I need to pass to enable gui...

So sum up the two question:

  1. Can I open emacs on desktop and use lsp-docker to find definitions from the libraries installed in the docker container?
  2. Can we open emacs from docker in gui?

I have a minimal test repo over here which contains the minimal reproduce steps https://github.com/ztlevi/lsp-docker-test

yyoncho commented 4 years ago
  1. I don't have the time to test it now but this should work. Can you describe what exactly happens and add the logs?

  2. I run

 xhost +

and then it works.

ztlevi commented 4 years ago
  1. I use the repo I attach above and try lsp-jump-to-definition to Deque from from typing import Deque. Then it gives me:
  signal(cl-no-applicable-method (xref-item-location nil))
  cl-no-applicable-method(#s(cl--generic :name xref-item-location :dispatches ((0 #s(cl--generic-generalizer :name eieio--gen$
  apply(cl-no-applicable-method #s(cl--generic :name xref-item-location :dispatches ((0 #s(cl--generic-generalizer :name eiei$
  #f(compiled-function (&rest args) #<bytecode 0x1638e45>)(nil)
  apply(#f(compiled-function (&rest args) #<bytecode 0x1638e45>) nil nil)
  xref-item-location(nil)
  xref--pop-to-location(nil nil)
  xref--show-xrefs(nil nil)
  lsp-show-xrefs(nil nil nil)
  lsp-find-locations("textDocument/definition" nil :display-action nil)
  lsp-find-definition()
  funcall-interactively(lsp-find-definition)
  call-interactively(lsp-find-definition record nil)
  command-execute(lsp-find-definition record)
  execute-extended-command(nil "lsp-find-definition" "lsp-find-def")
  funcall-interactively(execute-extended-command nil "lsp-find-definition" "lsp-find-def")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)
  1. How did you run xhost +? I run it on my local shell and run start-emacs.sh, but emacs is still start in terminal.
zflat commented 3 years ago

I have the same question. I try lsp-find-reference and get this error

Warning (lsp-mode): Failed to process xref entry for filename ’/docker:my-docker-langservers:/opt/ros/melodic/include/rosconsole/macros_generated.h’: Method ‘docker’ is not known.

The file path is known and correct within the container. Is there any way to open that file in an emacs buffer? Ideally it would still work with lsp-mode to facilitate further navigation.

If that is not possible, could there be a way to open the buffer using Tramp? In my case, changing the file path from /docker:my-docker-langserver:/opt/... to /ssh:user@host#port:/opt/... would work when the container is running sshd.

yyoncho commented 3 years ago

@zflat can you try installing docker-tramp package?

zflat commented 3 years ago

Yes, that is the fix for handling the xref uri. However, I now have this issue: https://github.com/emacs-lsp/lsp-docker/issues/29

I have a branch that I am using to test a fix.