zed
zed copied to clipboard
Multiple documents in one yaml file
Check for existing issues
- [X] Completed
Describe the bug / provide steps to reproduce it
Having multiple yaml documents in one file, Zed marks the second document all in red with the information:
Source contains multiple documents; please use YAML.parseAllDocuments() at line 169, column 1: (MULTIPLE_DOCS)
Example of yaml file:
metadata:
name: doc1
---
metadata:
name: doc2
---
metadata:
name: doc3
aur/zed-editor 0.135.2-1 on Arch Linux
Environment
Zed: v1.0.0 (Zed) OS: Linux 1.0.0 Memory: 13.7 GiB Architecture: x86_64
If applicable, add mockups / screenshots to help explain present your vision of the feature
If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.
No response
This makes working with Kubernetes yaml files pretty difficult ...
Failing Syntax Highlighting for multiple Yaml documents in one file is also occurring in the mac version, 0.145.1 in my case.
I have this issue too with flux2 yaml file
Maybe its upstream ? https://github.com/redhat-developer/yaml-language-server/issues/869 https://github.com/redhat-developer/yaml-language-server/issues/946 and from https://github.com/eemeli/yaml
Not sure to understand but it seem to detect if file is yml or yaml and kubernetes and parse it differently https://github.com/redhat-developer/yaml-language-server/blob/f039273ee5b6974db5ad34b03bb24cfe09b64447/src/languageservice/parser/isKubernetes.ts
The multi document yaml test https://github.com/redhat-developer/yaml-language-server/blob/f039273ee5b6974db5ad34b03bb24cfe09b64447/test/multipleDocuments.test.ts
Bump. Would be nice this fix this issue, since this makes working on kubernetes ressources diffcult.
This bug seems fixed.
I'm still observing this problem on mac Zed 0.149.5
I'm still observing this problem on mac Zed 0.149.5
me too.
I'm still observing this problem on mac Zed Preview 0.153.1
same here, still observing this problem, is there a fix for this?
我仍然在 Mac Zed Preview 0.157.4 上观察到这个问题,有解决办法吗?
Also observed here.
Zed: v0.160.2 (Zed Preview) OS: Linux Wayland fedora 41 Memory: 62.4 GiB Architecture: x86_64 GPU: NVIDIA GeForce RTX 3080 Ti Laptop GPU || NVIDIA || 560.35.03
Still seeing this issue in today's update, not sure if the bug went away and came back or if h3adex got lucky ^^
Zed: v0.163.2 (Zed Preview) OS: macOS 15.2.0 Memory: 36 GiB Architecture: aarch64
Issue still present. Zed: v0.166.1
this is very annoying any ideas what is the underlying problem?
this is very annoying any ideas what is the underlying problem?
zed-industries/tree-sitter-yaml properly supports syntax highlighting of multiple documents:
I believe the original reported issue may have been solved (all multi-doc yaml files trigger errors) and now it's a kubernetes yaml file specific issue (kubernetes multi-doc yaml files trigger errors) upstream with redhat-developer/yaml-language-server, perhaps:
- https://github.com/redhat-developer/yaml-language-server/issues/869
- https://github.com/redhat-developer/yaml-language-server/issues/946
If you are still experiencing this issue, could you please comment with a minimal yaml file which triggers the issue? Given that I believe this is a yaml-language-server issue I would expect that vscode with the redhat.vscode-yaml extension would show identical behavior.
As a (sad) workaround you can disable yaml-language-server altogether with the following in your settings:
"languages": {
"YAML": {
"enable_language_server": false
}
}
using Zed 0.166.2 on Arch 6.12.7-arch1-1
Here is a sample file
test.yaml
---
person:
name: John Doe
age: 30
occupation: Software Engineer
skills:
- Python
- JavaScript
- YAML
---
server:
host: example.com
port: 8080
maintenance_mode: false
features:
- API
- WebSockets
- Static Content
@1hachem When I create this as test.yaml I don't see the schema errors. I assume because your pathing is triggering one of the built-in schema associations -- can you share your pathing and the associated schema url so we can add a inline schema directive an create a fully self-contained reproduction example?
# yaml-language-server: $schema=https://my.url.to/the/schema
Thanks
Okay I can't explain it but I am running into this bug and it does not impact every file and I haven't been able to figure out a commonality. I am running into it when writing Kubernetes manifests and it is only showing the error on the second document in some files. It doesn't seem to be related to the detected schema, it does it with or without it defined.
Here is an example:
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.31.5/namespace-v1.json
apiVersion: v1
kind: Namespace
metadata:
name: config
labels:
kustomize.toolkit.fluxcd.io/prune: disabled
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.31.5/namespace-v1.json
apiVersion: v1
kind: Namespace
metadata:
name: system
labels:
kustomize.toolkit.fluxcd.io/prune: disabled
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.31.5/namespace-v1.json
apiVersion: v1
kind: Namespace
metadata:
name: network
labels:
kustomize.toolkit.fluxcd.io/prune: disabled
It seems to do this no matter what the file is named (or if it uses yaml or yml) or how it was created. I can work around it by leaving an empty document in the second position but it still causes the file tree to show an error on the file.
Zed 0.169.2
MacOS 15.2 (24C101)
Apple M2
16GB Memory
Let me know if there is any other information that would be helpful!
-
@wazoo Can you provide the filename you are using for this?I believe the pathing you are using are causing these documents to be captured by the "Kubernetes" glob was causes yaml-language-server to handles these documents differently than by default. When I create your example as
a.ymlI do not see errors and validation/autocomplete works as expected. -
I wonder if as a workaround we can defeat this by altering the
Kubernetesglob and explicitly including per-document schemas as you have above. Can you try this and see if it helps (untested).
"lsp": {
"yaml-language-server": {
"settings": {
"yaml": {
"schemas": {
"Kubernetes": []
}
}
}
}
}
Oh interesting! The file is called bootstrap.yaml but I also have one called cluster-base.yaml that has the same behavior (different manifests, same folder).
Currently I have this same issues on the following files/paths (metal is the name of the cluster):
- clusters/metal/base/namespaces.yaml
- clusters/metal/base/config.yaml
- clusters/metal/bootstrap.yaml (the file from the previous comment)
- clusters/metal/cluster-system.yaml
I also created a copy of the bootstrap file and tried the following paths:
- test/metal/bootstrap.yaml
- totallynotclusters/metal/bootstrap.yaml
- totallynotclusters/bootstrap.yaml
- totallynotclusters/zerp.yaml
- bootstrap.yaml
- zerp.yaml
None of those paths worked either, I wasn't able to get the error to disappear no matter what the name of the file is or what the path is. I also tried opening it in a new workspace (zed -n zerp.yaml), same result.
I tried adding that snipped above and it didn't seem to change anything, here is my whole zed config in case I missed something, I am fairly new to Zed.
@wazoo I was able to reproduce by installing the Docker Compose Zed Extension. Uninstall that extension and you issue should go away.
- See: https://github.com/eth0net/zed-docker-compose/issues/2
I forgot to come back and comment that disabling that zed extension did fix it for me.