zbelial / lspce

LSP Client for Emacs implemented as a module using rust.
GNU General Public License v3.0
154 stars 11 forks source link

Error reporting in Rust project sometimes missing #4

Closed casouri closed 1 year ago

casouri commented 1 year ago

I'm using lspce on a Rust project and I noticed that sometimes lspce doesn't display errors like eglot does. I'm not exactly sure what could be the problem, so any guidance on debugging this is appreciated!

If I enable eglot in the buffer, it shows some errors like this:

Screenshot 2023-02-23 at 10 55 19 PM

Notice the squiggly lines at two new's and the info tooltip at the first line. On the other hand, lspce doesn't seem to show anything. flymake-mode is enabled, and I do see error reporting other times, just not in this case.

I tried to look at the log but despite enabling logging, I don't see a log file. (This might be due to me using lspce on Mac.)

Here is my relevant config:

(setq lspce-send-changes-idle-time 1)
(lspce-set-log-file "/tmp/lspce.log")
(lspce-enable-logging)

If you have time, you can try reproducing this by cloning https://git.sr.ht/~casouri/ccbc, branch lspce-test, and the file shown in the screenshot is src/bonjour.rs.

zbelial commented 1 year ago

I'm using lspce on Linux and it shows errors about these two new here.
image

Unfortunately I don't have a Mac so I can't do any test.

Did other functions (such as completing and jumping to definition work on your Mac?

zbelial commented 1 year ago

FYI. After opening src/bonjour.rs and enabling lspce-mode in that buffer, I waited about 2 minutes before lspce could display errors, during that time, cargo was working ( to fetch dependencies ? ).

casouri commented 1 year ago

Waiting doesn't seem to change anything. But this time I see the log file! Looking at it, it seems rust-analyzer isn't sending any error reports:

2023-02-24 15:46:40.058 - stdio read {
  "method": "textDocument/publishDiagnostics",
  "params": {
    "diagnostics": [],
    "uri": "file:///Users/yuan/p/ccbc/src/bonjour.rs",
    "version": 0
  }
}

Could this be due to the initialize options lspce pre-configured for rust-analyzer? Because I don't have any configuration for rust-analyzer on Eglot.

Full log: lspce.log

zbelial commented 1 year ago

Could this be due to the initialize options lspce pre-configured for rust-analyzer?

You used the default initializationOptions (I mean lspce-ra-initializationOptions) right? If so, I'm not sure that's the reason, because I use it too.

what's your flymake configuration? Also you can edit that file and see whether diagnostics appear.

Below is mine:

            (setq flymake-no-changes-timeout 2)
            (setq flymake-start-on-flymake-mode nil) 

            (add-hook 'flymake-mode-hook
                      (lambda () (run-with-idle-timer 2 t #'flymake-start)))
zbelial commented 1 year ago

Maybe you can redifine lspce-ra-initializationOptions to an empty function and try again.

(defun lspce-ra-initializationOptions ()
  (let ((options (make-hash-table :test #'equal)))
    options))
casouri commented 1 year ago

Thank you for your patience. I redefined lspce-ra-initializationOptions but the initialize request doesn't seem to change. And there is still no diagnostic. Evaluating (lspce-ra-initializationOptions) does return an empty hash table.

lspce.log

zbelial commented 1 year ago

Maybe lspce has some wired buy on Mac, but I cannot do anything ATM. Sorry. I guess eglot is a better option for you now.

casouri commented 1 year ago

Probably something going on with Mac. Anyway, thanks for your time!