purescript-language-server icon indicating copy to clipboard operation
purescript-language-server copied to clipboard

No instantaneous diagnostics feedback?

Open oblitum opened this issue 6 years ago • 10 comments

First thanks for this project.

I noticed this server behaves differently than all others I use, it only provide errors on file save. Any plans to provide instantaneous diagnostics like others? Some servers provide a flag for this, bingo for example provide the --diagnostics-style option.

oblitum avatar Mar 08 '19 08:03 oblitum

Definitely considered having this (opt-in) - on larger projects some files can take a noticeable time for purs ide to compile, but with the right timing/debouncing it could be fine for some.

I do think you'll find that because we just do an actual compilation with no shallow syntactic linting or whatever and there's no kind of incremental parsing/analysis (whatever this is properly called) most of the time you will be in a non-compiling state and the file will just be in a big error status, unparseable.

nwolverson avatar Mar 11 '19 12:03 nwolverson

I agree on that, but for example, with coc.nvim, the plugin I use with NeoVim, it doesn't try compile on every character I type, in fact that's kind horrid/annoying, I've seen that happening with some alternative plugins, I think it's an issue of the client not acting sane. coc.nvim just compiles and shows diagnostics at specific times, like when leaving insert mode.

oblitum avatar Mar 11 '19 12:03 oblitum

FWIW, I've added server configuration for coc.nvim here:

  • https://github.com/neoclide/coc.nvim/wiki/Language-servers#purescript

(coc.nvim can be configured both from .vimrc as from coc-settings.json)

oblitum avatar Mar 11 '19 12:03 oblitum

In what way is coc.nvim responsible for somehow deciding when to evaluate diagnostics but also it is the language server responsibility? I think more information is required here to understand the behvaiour being discussed.

Diagnostics are a "push" from language server to client, currently we use purs ide rebuild on saving a file and push diagnostics at this time. The client also notifies the server on file contents changing, what we could do is perform a rebuild on the current file/buffer contents at this point (debounced appropriately).

It could be that the vim plugin sends file update notifications only on leaving insert mode?

nwolverson avatar Mar 11 '19 14:03 nwolverson

I think coc doesn't decide when to evaluate anything, just decides when to send text changes to server.

oblitum avatar Mar 11 '19 14:03 oblitum

I don't know the internals, but I guess that's it. Instead of sending requests on every input, it sends on sensible spots. I think coc.nvim allows for configuring that too, iirc, it just takes a sensible default, but it can be changed to more requests on every character change.

oblitum avatar Mar 11 '19 14:03 oblitum

diagnostic.refreshOnInsertMode is the coc.nvim setting to have updates for every input:

https://github.com/neoclide/coc.nvim/blob/ba4679cb69e1e81bc55d02eb86ba955e3b490af1/data/schema.json#L331-L335

oblitum avatar Mar 11 '19 14:03 oblitum

This is an interesting thing to have. I don't think the performance will be a pain when we execute it on the NeoVim's CursorHold event.

@nwolverson Can you make a command for this, so I can choose to call that command whenever I need to see the diagnostics? I had some really huge projects using PureScript, some with thousands of modules too.

I think trigger update after a CursorHold event that comes after a TextChange should be better.

sriharshachilakapati avatar Mar 15 '19 03:03 sriharshachilakapati

@sriharshachilakapati coc.nvim does it on InsertLeave, it provides a good balance IMO, since I'm generally not interested in diagnostics until finished micro editing, which couples to entering Normal mode. Update rate control is more on the hands of the client than the server.

oblitum avatar Mar 15 '19 04:03 oblitum

I ran a test run on a project I had at work which had 858 purescript modules. I've set autowrite. It was working ok, file was being written and I had webpack constantly watching for files and loading it. Not sure about pulp though, we are using purs-loader in our organization.

This shouldn't in theory cause any issue with instantaneous diagnostics. I'll take some time to experiment with the server this weekend.

sriharshachilakapati avatar Mar 21 '19 10:03 sriharshachilakapati