zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.36k stars 3k forks source link

Show settings.json errors somewhere #7986

Open nixpulvis opened 8 months ago

nixpulvis commented 8 months ago

Check for existing issues

Describe the feature

Unless I'm missing something, there's no way to see any errors in the settings.json configuration. For some settings this would be trivial. Others, like anything under "lsp" might be harder to check until the underlying system is used?

At any rate, it seems like things are failing silently. Would it make sense to use a "Notification"? Or some red error in the bottom status bar where the LSP status is already?

If applicable, add mockups / screenshots to help present your vision of the feature

No response

munozr1 commented 8 months ago

For Zed config files, there should be a validation step before allowing you to save

I 2nd this, I saved and exited the settings.json file very quickly and restarted zed like 5 times before rechecking and catching the error, I get a squigly error but it lets you save the file regardless. When it fails it seems to revert to the default settings.

zed logs

2024-02-20T23:01:02-06:00 [ERROR] Prettier instance from None failed to format a buffer: prettier format request: error during message '{"jsonrpc":"2.0","id":35,"method":"prettier/format","params":{"text":"..snip..","options":{"plugins":[],"parser":"json","filepath":"/Users/rmunoz/.config/zed/settings.json","prettierOptions":{"tabWidth":2,"printWidth":80}}}}' handling: SyntaxError: Unexpected token, expected "," (20:31)
  18 |   "ui_font_size": 18,
  19 |   "buffer_font_size": 18,
> 20 |   "buffer_font_family": Comic Mono",
     |                               ^
  21 |   "ui_font_family": "Comic Mono",
  22 |   "project_panel": {
  23 |     "dock": "right"
2024-02-20T23:01:02-06:00 [ERROR] crates/settings/src/settings_file.rs:83: expected value at line 20 column 25
zephaniahong commented 8 months ago

This seems similar to #7574. I'll take a look at this

zephaniahong commented 8 months ago

Hi @SomeoneToIgnore, I've taken a deeper look into this and I'm facing an issue. Do I create a LanguageServerPromptRequest in project.rs or in prettier_support.rs?

if I do it in prettier_support.rs, how do I get a hold of the language_server (i need it for the lsp_name in the LanguageServerPromptRequest struct)? Alternatively, if I do it in project.rs, how do I propagate the error from prettier_support?

Thank you! https://github.com/zed-industries/zed/blob/dbe1f48f95558aa5764c5ed0c87022291fb5800b/crates/project/src/prettier_support.rs#L51-L112

https://github.com/zed-industries/zed/blob/dbe1f48f95558aa5764c5ed0c87022291fb5800b/crates/project/src/project.rs#L4409-L4440

SomeoneToIgnore commented 8 months ago

prettier_support.rs seems just wrong, I do not understand the question fully, since both entities belong to the same crate, so at the worst case it could be a shared module (lib.rs)? Generally, the question looks like a Rust problem which I encourage you to solve yourself somehow.