onivim / oni

Oni: Modern Modal Editing - powered by Neovim
https://www.onivim.io
MIT License
11.34k stars 299 forks source link

Show prettier plugin error as a notification #2259

Open akinsho opened 6 years ago

akinsho commented 6 years ago

Prettier when it fails to parse and format a file usually throws a very informative error message which essentially shows a snapshot of where the parsing error is occurring in your file.

screen shot 2018-05-29 at 16 58 31

I've actually taken to checking the console whenever prettier fails to access this message to find out where it failed, it would be very helpful to users I think to log an info notification via the plugin to pass the error throught

Options re implementation currently are leaving the error unhandled which means our global unhandled error notifications will pick this up - Far from ideal as this is off in production currently, and not really a good mechanism to rely on nor is it ideal to leave errors completely unhandled.

Second best option (as far as I know) would require adding sending notifications to the plugin api like other bits of oni functionality so in the plugin we could do

    oni.notifications.createItem(...)

and dispatch a notification with the contents of the error message

badosu commented 6 years ago

What about adding the errors to the quickfix list, that's how it would happend for other error providers.

akinsho commented 6 years ago

I think tbh adding it to the quickfix would require more leg work and given it isn't externalised the current ux of a quickfix notice will mean users have to be familiar with the qf which new ppl may not be. Also given how the messages print out e.g. the example above they often include a code block which I think can be rendered much more legibly in a notification rather than the way qf list items render.

If in notification as these are transient it can be set to be a little stickier than normal so the user has time to respond to the error and fix it.

I imagine at some point neovim will externalise the qf at which point i'd very much like to get a nice gui there and setup an interface for rendering all kinds of pertinent errors there.