LSP (lsp-mode or eglot) + TRAMP (to work server) + pyenv + pyenv-virtualenv + WSL2

I just want to better understand how this all works together…And also make it work…

I have tried to search all over the internet for a singularly decent tutorial or example and cannot find anything of use. The LSP-mode tutorial is basically useless

Reddit doesn’t have anything of use. One thread showed some promise.

What happened?

Open a project on remote server. I get this error:
LSP :: There are no language servers supporting current mode `python-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 `python-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 `python-mode'. Refer to and .
4. You are over `tramp'. In this case follow
5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients').
You can customize `lsp-warn-no-matched-clients' to disable this message.
mouse-minibuffer-check: Minibuffer window is not active

So, then I follow the terrible tutorial that LSP-mode creator provided and put this code in my config.el

    (make-lsp-client :new-connection (lsp-tramp-connection "pyright")
                     :major-modes '(python-mode)
                     :remote? t
                     :server-id 'pyright-remote))

And doom doesn’t load: Error caused by user's config or system: /home/user/.doom.d/config.el, (void-function lsp-register-client)

Here it is with --debug-init

Debugger entered--Lisp error: (void-function lsp-register-client)
  (lsp-register-client (make-lsp-client :new-connection (lsp-tramp-connection "pyright") :major-modes '(python-mode) :remote\? t :server-id 'pyright-remote))
  load-with-code-conversion("/home/goberlan/.doom.d/config.el" "/home/goberlan/.doom.d/config.el" nil t)
  load("~/.doom.d/config" nil nomessage)
  (condition-case e (load path noerror 'nomessage) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (setq path (locate-file path load-path (get-load-suffixes))) (signal (cond ((not (and path (featurep ...))) 'error) ((file-in-directory-p path (expand-file-name "cli" doom-core-dir)) 'doom-cli-error) ((file-in-directory-p path doom-core-dir) 'doom-core-error) ((file-in-directory-p path doom-user-dir) 'doom-user-error) ((file-in-directory-p path doom-profile-dir) 'doom-profile-error) ((file-in-directory-p path doom-modules-dir) 'doom-module-error) ('doom-error)) (list path e))))

Once it does load, it likely still won’t work, but I haven’t made it that far.

###eglot With eglot, it also failed, with:

Error in post-command-hook (#[0 "\303\304\301\242\305#\210\300\306!\205\0r\211q\210
?\205\0\307\310\311 \")\207" [#<buffer> (#0) eglot--managed-mode remove-hook post-command-hook nil buffer-live-p apply eglot--connect eglot--guess-contact] 4]): (error "None of ’pylsp, pyls, pyright-langserver, jedi-language-server’ are valid executables")
Anaconda Jump Proxy: nil

I have pyright installed globally, and in each pyenv I use. Still doesn’t work. eglot is suppose to “just work” with TRAMP, but that is not the case.

What did you expect to happen?

LSP would work…

Steps to reproduce

  1. Enable LSP-mode (+eglot or without)
  2. install pyright or pyls locally and on remote server
  3. Open a python project on remote server over TRAMP

System information

WSL2 - Arch Linux

Loading data dump...

I would prefer not to use an emacs on the remote server because it completely prevents the benefit of using one single emacs that I can navigate to everything I want/need. On windows, on WSL, on my remote work server

From looking at your modules it looks like you need to add +pyright to your python language settings in doom’s init.el

Then you’ll need to run doom sync and reload doom.

I am not versed at remote editing, but from your error, lsp-register-client isn’t autoloaded so you need to evaluate it after loading lsp-mode or requireing the lib explicitly.

It is: (python +lsp +pyright)

How do I do this in doom config? Like this:

(after! lsp-mode
    (make-lsp-client :new-connection (lsp-tramp-connection "pyright")
                     :major-modes '(python-mode)
                     :remote? t
                     :server-id 'pyright-remote))
1 Like

Interesting, in your doom info output it has (python +lsp +pyenv)

Just to make sure, is it working ok when you’re not using Tramp? If you run doom info now does it show (python +lsp +pyright)?

Edit to add:

If you want to use all of it together you probably need

(python +lsp +pyenv +pyright), and then make sure to run doom sync, and then I would close any open emacs instances and then reopen emacs to make sure.

1 Like

Ah. I probably ran it when I was using eglot and trying to use pyls, because pyright wasn’t working.

Ya I had all 3 of those and it still doesn’t work.

This is current doom/info. I stopped using pyenv because I was trying to simplify my setup just to get it to work. But nothing still works.

generated  Dec 16, 2022 08:44:54
system     Arch Linux Linux x86_64 x
emacs      28.2 ~/.emacs.d/
doom       3.0.0-pre PROFILE=_@0 HEAD -> master d5ccac5d 2022-12-02 00:36:06 +0100
shell      /bin/bash
traits     gui server-running envvar-file custom-file
custom     tramp-remote-path tramp-encoding-shell tramp-connection-properties
modules    :config use-package :completion company vertico :ui doom doom-dashboard
           hl-todo modeline ophints (popup +defaults) (vc-gutter +pretty)
           vi-tilde-fringe workspaces :editor (evil +everywhere) file-templates fold
           (format +onsave) snippets :emacs dired electric undo vc :checkers syntax
           (spell +flyspell) :tools (eval +overlay) lookup lsp magit :lang emacs-lisp
           markdown org (python +lsp +pyright) sh :config (default +bindings

@daanturo this still didn’t work.

Okay… Nevermind? It works now, lmao. I don’t know…

(after! lsp-mode
   (make-lsp-client :new-connection (lsp-tramp-connection "pyright")
                    :major-modes '(python-mode)
                    :remote? t
                    :server-id 'pyright-remote))

Maybe the formatting allowed it to work?

But, the LSP functions don’t work. Like rename, etc. Which… Makes this kind of useless lol

edit: Eglot rename seems to work. So I think I’ll stick to using that one. Sadly search the project or directory doesn’t work with vertico… Do you know if I can search with Helm, Ivy or the other? Or what’s best way to search a directory? I guess I can open a shell and use ripgrep?

FYI lsp-mode’s TRAMP support is going to be re-written so it would be easier to use update lsp-mode over TRAMP docs · Issue #3841 · emacs-lsp/lsp-mode · GitHub

1 Like

Haha, ya that’s actually my post >.<

1 Like

Ok, for my info then :))

This topic was automatically closed after 360 days. New replies are no longer allowed.