- No configuration needed to detect schemas
- Hover: Show description of field
- Code Action: Open documentation in browser
- Diagnostics: Validate yaml syntax
- Diagnostics: Validate against schema
- Diagnostics - Kustomization: Warn when not all yaml files in the current dir are included as resources
- Kubernetes Resources.
Detected from
kind
andapiVersion
. - Custom Resource Definitions.
Detected from
kind
andapiVersion
. - JSON Schema Store. Detected from filename.
go install github.com/slarwise/yamlls@latest
This will install yamlls
into $GOPATH/bin
or ~/go/bin
. Make sure that dir
is in your $PATH
.
TODO. Do you have to write an extension? Can't you just point to a binary?
In your languages.toml
, add
[[language]]
name = "yaml"
language-servers = ["yamlls"]
[language-server.yamlls]
command = "yamlls"
In your init.lua
, or something sourced from there, add
vim.api.nvim_create_autocmd('Filetype', {
pattern = "yaml",
callback = function()
vim.lsp.start({
name = "yamlls",
cmd = { "yamlls" },
root_dir = vim.fs.dirname(vim.fs.find(".git", { upward = true, path = vim.api.nvim_buf_get_name(0) })[1]),
})
end
})
To try out changes using helix, you can do:
# Use yamlls in the current directory
export PATH=.:"$PATH"
# Update source code
go build .
hx examples/service.yaml -vvv
# Test things
# Run :log-open inside helix to see helix logs
tail -f ~/Library/Caches/yamlls/log | jq # Follow the logs from yamlls (on a mac)
- Use an offline documentation generator
- Completion
- If
kind
orapiVersion
is given, give completion suggestions for the other - Suggest
enum
s from the schema
- If
- Code actions
- Fill all required fields. Use placeholders that fit the type, or the first
enum
. - Add all files in the current directory to .resources in a Kustomization file
- Fill all required fields. Use placeholders that fit the type, or the first
- Background http server
- Show external documentation in a nice way for the currently open file. Can do this since we get notifications when the user changes file.
- Workspace: If there is an kustomization file, connect the resources somehow? And give info if there are things that don't match
- Can't get description of anyOf, such as github workflow jobs.something.runs-on
- Can't get description of any kustomization fields, I think it can't handle the ref
The first version of this repo was basically copied from a-h/examplelsp, which is an awesome starting point for understanding how to write a language server!