reddit / emacs

[LSP] what does this mean? what should I answer?

wdicc · 2022-08-14 10:22
I use doom-emacs, it comes with LSP. When I press \`gd\` on \`fmt.Sprintf\`, it will pop up this window, what should I answer? it looks like even I hit esc, I still can jump throught the codes in the new buffer. https://preview.redd.it/vg87n0hennh91.png?width=1902&format=png&auto=webp&s=46c92bb15661a8015c94b828df82ca9770d4dc9c
northWe5t · 2022-08-14 13:13
I tend to import projects from root if I work on them myself. This makes them available to select among when hitting `SPC` + `p` + `p` (evil) For third party libraries I hit “d”.
SafeSemifinalist · 2022-08-14 19:42
Could you explain a little more, please? I am having a similar problem with lsp and Python. I press . but when I execute python, it gives me an error because it can not found other files which are in the same directory.
Old-Oven-9641 · 2022-08-14 21:25
[Lsp](https://en.m.wikipedia.org/wiki/Language_Server_Protocol) (Language Server Protocol) is a protocol that is used to build interchangeable Language-Servers that enable IDE-like features in Emacs and other programs. For example, though [lsp-mode](https://emacs-lsp.github.io/lsp-mode/), [elgot](https://github.com/joaotavora/eglot) or [lsp-bridge](https://github.com/manateelazycat/lsp-bridge). To provide you with all the features, the lsp-client asks you for the project root to scan the hole project. For example to discover and help you find the implementation of classes, methods … On the one hand, that’s pretty helpful for code navigation but, on the other hand, it can be (for example in big projects and external libraries) very resource intensive to scan/import the projects. Most of the lsp-clients are not multithreaded (as Emacs) and therefore in large code bases you could get into a long lack when you import the project.
db48x · 2022-08-15 08:41
The directory you import into your LSP server has nothing to do with the Python search path when you actually run the code.
SafeSemifinalist · 2022-08-19 14:14
So, why is that when you run the code in terminal it works but when you do \`C-c C-c\` does run the code in the root project? What is the best way to get the same behavior in LSP as when it is run in terminal?
db48x · 2022-08-19 17:16
The python search path is partly or wholly determined by environment variables. Environment variables are not global, they are inherited from the parent process. When you run the Emacs GUI, then the parent process is some part of your operating system, such as X11 on Linux. The environment variables that get passed on to Python will be whatever was passed on to Emacs. When you run a terminal, it runs a shell such as `bash` or `zsh` inside the terminal. The shell reads a configuration file that usually sets environment variables. Then when you type `emacs` in the shell, it passes along those configured variables. Check your shell’s config file to see if there are any variables that look like they might be related to Python, and bring those variables over to your Emacs init file. See the function `setenv` for more details about that.
SafeSemifinalist · 2022-08-19 19:23
I use `zsh` as shell, and when I write `set` there are no variables related to python. I don't know if it is related but when I run LSP server in emacs, it seems that the shell is running inside my home directory, which is a level above my project directory. If I put files there, I don't have any problem importing them. Does this give you any clue? ​ Edit: I wanted to thank you for your help, you are very kind.