1

I'm getting all kinds of strange behavior trying to run Eglot with Pyright on Windows with Emacs 29.0.60 ((build 1, x86_64-w64-mingw32) of 2023-03-10). The *Messages* buffer shows lots of attempts to connect, quickly followed by timeouts and server shutdowns. For example,

[eglot] Connected! Server `EGLOT (kalman/(python-mode python-ts-mode))' now managing `(python-mode python-ts-mode)' buffers in project `kalman'.
[eglot] Connected! Server `EGLOT (core/(python-mode python-ts-mode))' now managing `(python-mode python-ts-mode)' buffers in project `core'.
[jsonrpc] Server exited with status 1
[eglot] (warning) Not auto-reconnecting, last one didn't last long.

Doing M-x eglot-events-buffer shows JSON messages with apparently bad URIs for files such as :uri "file:///c%3A/Users/....

[client-request] (id:4) Tue May  9 15:55:35 2023:
(:jsonrpc "2.0" :id 4 :method "textDocument/documentHighlight" :params
          (:textDocument
           (:uri "file:///c%3A/Users/rdprice/Apps/msys64/home/rdprice/working/kalman/src/kepler/rotators.py")
           :position
           (:line 27 :character 51)))
[internal] (id:4) Tue May  9 15:55:45 2023:
(:timed-out :textDocument/documentHighlight :id 4 :params
            (:textDocument
             (:uri "file:///c%3A/Users/rdprice/Apps/msys64/home/rdprice/working/kalman/src/kepler/rotators.py")
             :position
             (:line 27 :character 51)))

Is this known behavior? Some mis-configuration on my part?

Here's my Eglot setup:

  (use-package eglot
    :ensure t
    :after conda
    :defer t
    :preface
    (defun mp-eglot-eldoc ()
      (setq eldoc-documentation-strategy
            'eldoc-documentation-compose-eagerly))
    :custom
    (eglot-connect-timeout 120)   ; my work computer is slow, slow, slow
    (eglot-stay-out-of 'company)
    (eglot-report-progress t)
    :hook ((eglot-managed-mode . mp-eglot-eldoc)
           (python-mode . eglot-ensure)))

Edit:

Evaluated in the scratch buffer, the following gives a malformed path,

(eglot--path-to-uri ".")
"file:///c%3A/Users/rdprice/Apps/msys64/home/rdprice"

Still in the scratch buffer, just to get a valid path, I evaluate

(file-truename ".")
"c:/Users/rdprice/Apps/msys64/home/rdprice"

Calling this function is basically the first thing that eglot--path-to-uri does. Evaluating the following gives me a malformed path,

(url-hexify-string
 (file-truename ".")
 eglot--uri-path-allowed-chars)
"c%3A/Users/rdprice/Apps/msys64/home/rdprice"

The variable eglot--uri-path-allowed-chars is an array of 256 elements, each with value nil. The function url-hexify-string is called within eglot--path-to-uri before tacking on file:/// to the front.

Another edit

It seems that Firefox understands the URI,

file:///c%3A/Users/rdprice/Apps/msys64/home/rdprice

Perhaps I'm just running down a rabbit hole.

Rodney Price
  • 496
  • 3
  • 10

0 Answers0