lsp_server icon indicating copy to clipboard operation
lsp_server copied to clipboard

Improved support for textDocument/publishDiagnostics

Open erlanger opened this issue 6 years ago • 10 comments
trafficstars

Contiunuing from #2 (LanguageClient)

The main functionality I was looking for was to show the compilation errors with textDocument/publishDiagnostics; is that supported?

If not, I have some code from someone that tried to implement the lsp server (in the new discourse forum) and it collects the compilation errors.

erlanger avatar Aug 09 '19 21:08 erlanger

It isn't yet; I will try to do that next.

jamesnvc avatar Aug 09 '19 21:08 jamesnvc

Great! Look forward to it!

erlanger avatar Aug 09 '19 21:08 erlanger

Deployed v1.3.0 with preliminary support for publishDiagnostics.

jamesnvc avatar Aug 11 '19 18:08 jamesnvc

I am not seeing any errors, most likely because didChange is not being handled (LanguageClient sends the whole document again on didChange). UPDATE: I am seeing the error when I write the file to disk (as opposed to when I type), it is not showing singleton warnings. Why not use load_files/2 and capture the error messages (that way you have the full compiler support)?

UPDATE2: Regarding capturing messages from load_files, I meant using thread_message_hook/3

erlanger avatar Aug 11 '19 20:08 erlanger

Hm, I was able to see errors with LanguageClient; it does the error stuff in didSave, so the changes shouldn’t be a problem. I’ll have a look tomorrow; I also have some improvements to the warnings for singleton variables in progress.

On Aug 11, 2019, at 16:27, erlanger [email protected] wrote:

I am not seeing any errors, most likely because didChange is not being handled (LanguageClient sends the whole document again on didChange).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jamesnvc avatar Aug 11 '19 20:08 jamesnvc

it does the error stuff in didSave, so the changes shouldn’t be a problem.

Ahh, what I meant was that if you did the error checking on didChange, it would work real time! But you probably have to do a threaded implementation to do that.

Thanks! BTW, look at the update above about using thread_message_hook/3 with load_files/2 that way you can just gather all the errors produced by the compiler.

erlanger avatar Aug 11 '19 20:08 erlanger

Ah okay. I’d like to hook in to didChange at some point, but it isn’t working yet.

Regarding “load_file”, right now the process is working via the xref library, which just uses static analysis. It does make getting a lot of the diagnostics more challenging, but I’m doing it this way because I’m not confident in how robust it will be if it tries to actually load the source files to check them (e.g. if initialization goals run, top-level queries might have side effects, code that redefine predicates could interfere with the checker itself).

jamesnvc avatar Aug 11 '19 23:08 jamesnvc

I’m not confident in how robust it will be if it tries to actually load the source files to check them

I see. I would ask Jan, I suspect there might be some way to get all the compiler errors in a safe way.

In any case, thanks for your great work!

erlanger avatar Aug 12 '19 00:08 erlanger

I see. I would ask Jan, I suspect there might be some way to get all the compiler errors in a safe way.

Indeed. I’m about to go on vacation for two weeks; when I return, I’ll look into that. I’m also looking at the source for prolog_codewalk, to see if I can leverage that directly somehow.

In the meantime, I’ve released 1.3.2, which should have better display of singleton variable warnings.

jamesnvc avatar Aug 12 '19 17:08 jamesnvc

Great! thanks!

erlanger avatar Aug 12 '19 22:08 erlanger