yaml-language-server
yaml-language-server copied to clipboard
intellisense completion breaks with multiple documents in a single file
Describe the bug
It seems like intellisense completion breaks with multiple docs in single file. For example if I'm working with k8s manifests it's very common to have multiple related k8s resources per .yaml file.
Expected Behavior
If I have only one doc per file the completion works perfectly:
& I'd expect it to work just fine with multiple docs as well
Current Behavior
...but actually with multiple docs it offers nothing:
Environment
- [ ] Windows
- [X] Mac
- [ ] Linux
- [ ] other (please specify)
I get an error on multiple documents in a single file:
Source contains multiple documents; please use YAML.parseAllDocuments()
I can not replicate this issue. Can you provide a more complete example?
So I'm not sure if my issue is related to the original issue, but will add some details.
Basic details
OS: macOS 13.4.1 Environment: Neovim 0.9.1 Installed with: Mason yaml-language-server version: 1.13.0
Settings as reported by Mason:
◍ yaml-language-server yamlls
Language Server for YAML Files.
installed version 1.13.0
homepage https://github.com/redhat-developer/yaml-language-server
languages YAML
categories LSP
executables yaml-language-server
↓ LSP server configuration schema (press enter to collapse)
This is a read-only overview of the settings this server accepts. Note that some settings might not apply to neovim.
→ redhat.telemetry.enabled
→ yaml.completion default: true
→ yaml.customTags default: []
→ yaml.disableAdditionalProperties default: false
→ yaml.format.bracketSpacing default: true
→ yaml.format.enable default: true
→ yaml.format.printWidth default: 80
→ yaml.format.proseWrap default: "preserve"
→ yaml.format.singleQuote default: false
→ yaml.hover default: true
→ yaml.maxItemsComputed default: 5000
→ yaml.schemaStore.enable default: true
→ yaml.schemaStore.url default: "https:\/\/www.schemastore.org\/api\/json\/catalog.json"
→ yaml.schemas default: {}
→ yaml.trace.server default: "off"
→ yaml.validate default: true
Example
---
key: "value"
--- # ---> Here I get the Error
key: "value"
The Error
Diagnostics:
Source contains multiple documents; please use YAML.parseAllDocuments() at line 3, column 1:
key: "value"
---
^
[MULTIPLE_DOCS]
So I'm not sure if my issue is related to the original issue, but will add some details.
Basic details
OS: macOS 13.4.1 Environment: Neovim 0.9.1 Installed with: Mason yaml-language-server version: 1.13.0
Settings as reported by Mason:
◍ yaml-language-server yamlls Language Server for YAML Files. installed version 1.13.0 homepage https://github.com/redhat-developer/yaml-language-server languages YAML categories LSP executables yaml-language-server ↓ LSP server configuration schema (press enter to collapse) This is a read-only overview of the settings this server accepts. Note that some settings might not apply to neovim. → redhat.telemetry.enabled → yaml.completion default: true → yaml.customTags default: [] → yaml.disableAdditionalProperties default: false → yaml.format.bracketSpacing default: true → yaml.format.enable default: true → yaml.format.printWidth default: 80 → yaml.format.proseWrap default: "preserve" → yaml.format.singleQuote default: false → yaml.hover default: true → yaml.maxItemsComputed default: 5000 → yaml.schemaStore.enable default: true → yaml.schemaStore.url default: "https:\/\/www.schemastore.org\/api\/json\/catalog.json" → yaml.schemas default: {} → yaml.trace.server default: "off" → yaml.validate default: true
Example
--- key: "value" --- # ---> Here I get the Error key: "value"
The Error
Diagnostics: Source contains multiple documents; please use YAML.parseAllDocuments() at line 3, column 1: key: "value" --- ^ [MULTIPLE_DOCS]
I got the same error
We got the same in zed-editor with yaml language server too
ParseAllDocuments()
specifically appears on Kubernetes manifests.
The error changes when yaml-language-server is configured with a kubernetes glob pattern.
https://github.com/redhat-developer/yaml-language-server/blob/main/README.md?plain=1#L115
It will instead show:
Matches multiple schemas when only one must validate. (0)
Despite the workaround: https://github.com/redhat-developer/yaml-language-server/blob/main/src/languageservice/services/yamlValidation.ts#L122-L124