eglot icon indicating copy to clipboard operation
eglot copied to clipboard

MS python language server: wrong-type-argument error in `eglot--format-markup`

Open galeo opened this issue 5 years ago • 3 comments

(plist-get markup :value) is nil in eglot--format-markup function when the language server returns '(:kind "plaintext"), (insert string) would lead to error Wrong type argument: char-or-string-p, nil.

galeo avatar May 09 '19 04:05 galeo

Isn't the :value field required? If yes, then that's a server-side issue.

mkcms avatar May 09 '19 09:05 mkcms

Yes. An issue has been submitted.

galeo avatar May 09 '19 12:05 galeo

I modified the function to get it working with omnisharp-roslyn (C#) like this:

(defun eglot--format-markup (markup)
  "Format MARKUP according to LSP's spec."
  (unless markup
    (setq markup ""))
  (pcase-let ((`(,string ,mode)
               (if (stringp markup) (list (string-trim markup)
                                          (intern "gfm-view-mode"))
                 (list (plist-get markup :value)
                       major-mode))))
    (with-temp-buffer
      (insert string)
      (ignore-errors (funcall mode)) (font-lock-ensure) (buffer-string))))

Maybe this helps you with this server too. Also, since it seems to be a common issue, maybe this could be part of eglot-strict-mode?

(when (and (not markup) (not eglot-strict-mode) ;; set response to "" to avoid errors

sebasmonia avatar Jul 01 '19 16:07 sebasmonia