Closed darth-cheney closed 1 year ago
I simply run emacs from the command line.
Please try with running emacs -Q
from the command line. Your configuration is very large, I cannot load it on. In other words, your recipe may be complete, but it's not minimal.
The LSP server (solargraph) resides within an rvm environment. These are different on a per-project basis, but rvm is setup to install solagraph automatically in all ruby environments that it creates (and I can confirm the presence of the gem).
The point of this item is for you to teach us how to install the solargraph server in environments that are not yours. So come up with the simplest way to install solargraph, ideally not requiring rvm at all.
There is no backtrace, but the following displays in the Message buffer:
Can you try again with M-x toggle-debug-on-error
?
@joaotavora Here is the trace I'm getting when I toggle debugging:
Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
eglot--format-markup((:kind "markdown" :value nil))
eglot--hover-info((:kind "markdown" :value nil) nil)
#f(compiled-function (jsonrpc-lambda-elem12) #<bytecode -0x1284ee1b119edb04>)((:contents (:kind "markdown" :value nil)))
jsonrpc-connection-receive(#<eglot-lsp-server eglot-lsp-server-59a8e908> (:jsonrpc "2.0" :id 102 :result (:contents (:kind "markdown" :value nil))))
jsonrpc--process-filter(#<process autoconnect-EGLOT (identity-idp/enh-ruby-mode)> "Content-Length: 81\15\n\15\n{\"jsonrpc\":\"2.0\",\"id\":102,\"r...")
The point of this item is for you to teach us how to install the solargraph server in environments that are not yours. So come up with the simplest way to install solargraph, ideally not requiring rvm at all.
No problem. Assuming you have Ruby installed, you can run gem install solargraph
Please try with running emacs -Q from the command line. Your configuration is very large, I cannot load it on. In other words, your recipe may be complete, but it's not minimal.
I am able to replicate this error by running the following steps when using quiet emacs emacs -Q
(assuming solargraph already installed per above):
M-x package-refresh-contents
M-x package-list-packages
eglot
and installruby.rb
and enter the buffermy_string = "12345"
new_string = "#{my_string}6789"
M-x eglot
The server should automatically detect and connect, and you should start seeing the warnings if you move the cursor around and hover on identifiers
Edit: Looks like solargraph was updated recently to return a nil value for empty hover contents - https://github.com/castwide/solargraph/commit/81bd810e7578040cbdb7650b71abb5c8a10962ab
@darth-cheney I'm also running into this issue - My hacky fix in the meantime is to just add a conditional checking if (plist-get markup :value)
is nil and if so just returning a newline character.
(defun eglot--format-markup (markup)
"Format MARKUP according to LSP's spec."
(if (plist-get markup :value)
(pcase-let ((`(,string ,mode)
(if (stringp markup) (list markup 'gfm-view-mode)
(list (plist-get markup :value)
(pcase (plist-get markup :kind)
("markdown" 'gfm-view-mode)
("plaintext" 'text-mode)
(_ major-mode))))))
(with-temp-buffer
(setq-local markdown-fontify-code-blocks-natively t)
(insert string)
(let ((inhibit-message t)
(message-log-max nil))
(ignore-errors (delay-mode-hooks (funcall mode))))
(font-lock-ensure)
(string-trim (filter-buffer-substring (point-min) (point-max)))))
"\n"))
This seems to keep the issue at bay for me.
I'm considering adding this patch to eglot.el
:
diff --git a/eglot.el b/eglot.el
index 2e332c470f..e6db4e80af 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1459,7 +1459,7 @@ Doubles as an indicator of snippet support."
'yas-expand-snippet))
(defun eglot--format-markup (markup)
- "Format MARKUP according to LSP's spec."
+ "Return string of formatted MARKUP according to LSP's spec."
(pcase-let ((`(,string ,mode)
(if (stringp markup) (list markup 'gfm-view-mode)
(list (plist-get markup :value)
@@ -1467,14 +1467,16 @@ Doubles as an indicator of snippet support."
("markdown" 'gfm-view-mode)
("plaintext" 'text-mode)
(_ major-mode))))))
- (with-temp-buffer
- (setq-local markdown-fontify-code-blocks-natively t)
- (insert string)
- (let ((inhibit-message t)
- (message-log-max nil))
- (ignore-errors (delay-mode-hooks (funcall mode))))
- (font-lock-ensure)
- (string-trim (buffer-string)))))
+ (if string
+ (with-temp-buffer
+ (setq-local markdown-fontify-code-blocks-natively t)
+ (insert string)
+ (let ((inhibit-message t)
+ (message-log-max nil))
+ (ignore-errors (delay-mode-hooks (funcall mode))))
+ (font-lock-ensure)
+ (string-trim (buffer-string)))
+ "")))
(define-obsolete-variable-alias 'eglot-ignored-server-capabilites
'eglot-ignored-server-capabilities "1.8")
You can try it yourself, and it's similar to the previous suggestion.
However, according to my research that landed me here, it seems that solargraph is not complying with the spec. value
in a MarkupContent
interface must be a string, and it's definitely sending a JSON null (which is a nil in Elisp):
See in your transcript:
[server-reply] (id:6) Fri Aug 26 11:19:16 2022:
(:jsonrpc "2.0" :id 6 :result
(:contents
(:kind "markdown" :value nil)))
So I'm going to tag this "workaround" and "wontfix", though I may be convinced to change it if the solargraph people don't respond to a bug report on their side.
Was just checking that this this was fixed on Solargraph's side, seems like it is: https://github.com/castwide/solargraph/issues/583
LSP transcript - M-x eglot-events-buffer (mandatory unless Emacs inoperable)
Backtrace (mandatory, unless no error message seen or heard):
There is no backtrace, but the following displays in the Message buffer:
Minimum Reproducible Example (mandatory)
Here's how I suggest you structure your recipe:
I simply run
emacs
from the command line.The LSP server (solargraph) resides within an rvm environment. These are different on a per-project basis, but rvm is setup to install solagraph automatically in all ruby environments that it creates (and I can confirm the presence of the gem).
The issue appears to happen on textDocument LSP requests. As it stands, I cannot even create any new
.rb
file and type without persistent errors/warnings.If you would like to test yourself, create a new ruby file with any syntax and hover the point on an identifier. Example:
Here are the relevant config lines for ruby
Here is the relevant Eglot section of the config
Hover over any identifier in an open ruby buffer with Eglot enabled and (successfully) connected to a solagraph server
I would expect some documentation about the given identifier to appear in the minibuffer or other display, rather than a message about a type error
What is the observed behaviour?
VERY IMPORTANT: follow your own recipe (steps 1-9) by yourself and verify that it leads to the error.
You don't HAVE to follow this guide if you are confident you can describe your own COMPLETE, MINIMAL and REPRODUCIBLE recipe. See https://github.com/joaotavora/eglot/issues/696 for a good example of an issue following this template.