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
48.52k stars 2.9k forks source link

Comments in JSON files #10921

Closed luckydye closed 3 months ago

luckydye commented 5 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

It seems all files in zed are interpreted to be jsonc (?) and does not have a "JSONC" language.

There are some files in the zed codebase (assets/keymaps/vim.json) for example, that use comments in .json files, but langauge-servers don't know about that. So the biome extension for example, shows diagnostics as if they are json files, which doesn't allow comments.

image

https://github.com/biomejs/biome-zed/issues/11

Environment

Zed: v0.132.2 (Zed Preview) OS: macOS 14.2.1 Memory: 16 GiB Architecture: aarch64

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

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

maxdeviant commented 5 months ago

Would it work to map the JSON language to jsonc on the Biome extension side?

[language_servers.biome]
name = "Biome Language Server"
language = "JavaScript"
languages = ["JavaScript", "JSX", "TypeScript", "TSX", "Vue.js", "Astro", "Svelte", "JSON", "JSONC"]
# Map the "JSON" language in Zed to "jsonc" (or whatever ID Biome uses for JSONC files).
language_ids = { JSON = "jsonc" }
code_actions_kind = ["", "quickfix"]
luckydye commented 5 months ago

Would it work to map the JSON language to jsonc on the Biome extension side?

[language_servers.biome]
name = "Biome Language Server"
language = "JavaScript"
languages = ["JavaScript", "JSX", "TypeScript", "TSX", "Vue.js", "Astro", "Svelte", "JSON", "JSONC"]
# Map the "JSON" language in Zed to "jsonc" (or whatever ID Biome uses for JSONC files).
language_ids = { JSON = "jsonc" }
code_actions_kind = ["", "quickfix"]

That was my first thought too, but I think being able to differentiate between linting for json or jsonc is useful too. And the output in the editor would become out of sync with what the cli outputs.