predragnikolic / OLSP

Opinionated LSP. Mostly for experimentation. Nothing serious... Ignore this repo.
MIT License
3 stars 0 forks source link

Request for help with understanding the log function #1

Open LakshyAAAgrawal opened 1 year ago

LakshyAAAgrawal commented 1 year ago

Dear @predragnikolic,

I was reading through the code implementation, and wanted to understand why does the client-side log function defined in file https://github.com/predragnikolic/OLSP/blob/6f9b6370b61b08d750b032d50af95cf0190e86e6/libs/lsp/server.py#L130-L133 send the log message as a notification to the server? Does a language server typically have a special way to handle the the message?

predragnikolic commented 1 year ago

Hello,

That code looks wrong to me. The "window/logMessage" notification should be sent from the server to the client to log a message.

That code in OLSP is sending a notification to the server... which is not according to the LSP spec.

To give more details, The LanguageServer._log is the same code as https://github.com/sublimelsp/LSP/blob/2e06833ca86cb88b4ae3acf663541551de675458/tests/server.py#L182
and the LanguageServer class is the almost the same class as sublimelsp/LSP/tests/server.py Session.

A simple print statement would be enough instead of self._log.

LakshyAAAgrawal commented 1 year ago

Thanks a lot for the reply. I think this is in line with my understanding, and self._log shouldn't be sending the notification to the server, instead logging it on the client side (either using a logger, or print statement, etc.). I think the following code location also has the same issue: https://github.com/predragnikolic/OLSP/blob/6f9b6370b61b08d750b032d50af95cf0190e86e6/libs/lsp/server.py#L259-L261

If you agree, I will create a PR to fix both of these.

predragnikolic commented 1 year ago

I don't know why it was done that way. Feel free to submit a PR.