zed icon indicating copy to clipboard operation
zed copied to clipboard

Show settings.json errors somewhere

Open nixpulvis opened this issue 2 years ago • 4 comments

Check for existing issues

  • [X] Completed

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

nixpulvis avatar Feb 18 '24 18:02 nixpulvis

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

munozr1 avatar Feb 21 '24 05:02 munozr1

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

zephaniahong avatar Feb 25 '24 02:02 zephaniahong

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

zephaniahong avatar Feb 25 '24 06:02 zephaniahong

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.

SomeoneToIgnore avatar Feb 25 '24 07:02 SomeoneToIgnore