emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
929 stars 90 forks source link

Support Python LSP in org-mode #369

Open 0liu opened 2 years ago

0liu commented 2 years ago

Hi,

I'm wondering if emacs-jupyter supports LSP in source code blocks? I have pyright installed and it works for plain .py files. For org files, jupyter-python code blocks run normally with a conda environment activated, and syntax highlighting and auto complete work as well. I have used emacs-jupyter with these tools for a while, and it's great experience! But the only thing turns me down: there seems no LSP functions in org mode python code blocks, like syntax checking etc. My emacs is doom emacs 27.2 with (python +lsp +pyright +conda) in the init file. If I do M-x lsp, a warning message pops out:

Warning (lsp-mode): Unable to calculate the languageId for buffer ‘test.org’. Take a look at ‘lsp-language-id-configuration’. The ‘major-mode’ is org-mode

and in *Messages* buffer:

LSP :: There are no language servers supporting current mode `org-mode' registered with `lsp-mode'.
This issue might be caused by:
1. The language you are trying to use does not have built-in support in `lsp-mode'. You must install the required support manually. Examples of this are `lsp-java' or `lsp-metals'.
2. The language server that you expect to run is not configured to run for major mode `org-mode'. You may check that by checking the `:major-modes' that are passed to `lsp-register-client'.
3. `lsp-mode' doesn't have any integration for the language behind `org-mode'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ .
4. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/.
5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients').

Does this mean in org-mode code blocks I can't use a LSP such as pyright? Is it possible to support LSPs from emacs-jupyter? Thank you.

zhenhua-wang commented 1 year ago

you can call lsp-org instead

holocronweaver commented 1 year ago

lsp-org is promising, but does not seem to support code completion / docs based on prior evaluated blocks. Each block is effectively treated as an independent Python file.