yaml-language-server
yaml-language-server copied to clipboard
Issue with YAML Language Server integration in Neovim and VSCode
Hello,
I've been facing an issue when trying to use the YAML Language Server (yamlls) with Neovim's built-in LSP client on MacOS 13. While the language server appears to attach correctly to the buffer and my configuration seems to be set up correctly, I'm not getting any syntax highlighting, autocomplete, or suggestions. Additionally, the YAML Language Server is not working in Visual Studio Code either, even when using the official YAML extension.
Here are the relevant details:
- Neovim version:
v0.9.1
- Node.js version:
v20.2.0
- Visual Studio Code version:
1.78
- YAML Language Server path:
/Users/<username>/.local/share/nvim/mason/bin/yaml-language-server --stdio
- I'm using the built-in LSP client with Mason in Neovim, and the official YAML extension in VSCode.
- The YAML Language Server is configured and attached to the buffer correctly according to
:LspInfo
in Neovim. -
which node
returns the expected path to the Node.js binary (/opt/homebrew/bin/node
), so Node.js is installed correctly and available in the PATH. - No errors are appearing in the LSP log (
/Users/philipp/.local/state/nvim/lsp.log
). - I've tried restarting my machine, reinstalling Node.js and the YAML Language Server, and manually specifying the path to Node.js in the YAML Language Server configuration in Neovim.
Despite these steps, I'm still not seeing syntax highlighting, autocomplete, or suggestions in YAML files in both Neovim and VSCode. Any guidance on how to debug or fix this issue would be greatly appreciated.
Thank you
I'm just a Vim user. With Vim I use vim-lsp and vim-lsp-settings, which provide ways to configure the yaml-language-server settings. I don't know how you'd do those settings using Mason.
I had the same issue, but after setting the file pattern to enable the schema, it worked. For Kubernetes, you can do it like this: "*.yaml"
require("lspconfig").yamlls.setup {
on_attach = on_attach,
capabilities = capabilities,
settings = {
yaml = {
schemas = {
kubernetes = "*.yaml",
},
},
},
}
I'm facing the same issue, in my case with the overridden schema via
client.config.settings = vim.tbl_deep_extend("force", client.config.settings, {
yaml = {
schemas = {
[schema] = uri,
},
},
})
client.notify("workspace/didChangeConfiguration")
see https://github.com/cwrau/yaml-schema-detect.nvim
I'm facing the same issue, in my case with the overridden schema via
client.config.settings = vim.tbl_deep_extend("force", client.config.settings, { yaml = { schemas = { [schema] = uri, }, }, }) client.notify("workspace/didChangeConfiguration")
The only thing that is working, are the # yaml-language-server: $schema=
overrides, but the config.settings.yaml.schemas.$schema=$file
aren't working
Lua code for reproduction;
local client = require("lspconfig.util").get_active_client_by_name(vim.api.nvim_get_current_buf(), "yamlls")
client.config.settings = vim.tbl_deep_extend("force", client.config.settings, {
yaml = {
schemas = {
[https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/deployment-apps-v1.json] = vim.uri_from_bufnr(vim.api.nvim_get_current_buf()),
},
},
})
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
In other words,
{
redhat = {
telemetry = {
enabled = false
}
},
yaml = {
schemas = {
["file:///tmp/lua_5MZoE1"] = "file:///home/cwr/work/clusters/1111-test-cwr-ffm3-2207/cluster.yaml"
}
}
}
is not working