Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/someone-stole-my-name/yaml-companion.nvim
Get, set and autodetect YAML schemas in your buffers.
https://github.com/someone-stole-my-name/yaml-companion.nvim
nvim nvim-lsp nvim-plugin schema yaml
Last synced: about 2 months ago
JSON representation
Get, set and autodetect YAML schemas in your buffers.
- Host: GitHub
- URL: https://github.com/someone-stole-my-name/yaml-companion.nvim
- Owner: someone-stole-my-name
- License: mit
- Created: 2022-04-28T10:50:28.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-16T00:01:23.000Z (6 months ago)
- Last Synced: 2024-01-03T03:29:31.492Z (5 months ago)
- Topics: nvim, nvim-lsp, nvim-plugin, schema, yaml
- Language: Lua
- Homepage:
- Size: 799 KB
- Stars: 156
- Watchers: 2
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-neovim - someone-stole-my-name/yaml-companion.nvim - Get, set and autodetect YAML schemas in your buffers. (Programming Languages Support / YAML)
- awesome-neovim - someone-stole-my-name/yaml-companion.nvim - Get, set and autodetect YAML schemas in your buffers. (Programming Languages Support / YAML)
- awesome-neovim - someone-stole-my-name/yaml-companion.nvim - Get, set and autodetect YAML schemas in your buffers. (Programming Languages Support / YAML)
README
# yaml-companion.nvim [![Build](https://github.com/someone-stole-my-name/yaml-companion.nvim/actions/workflows/main.yml/badge.svg)](https://github.com/someone-stole-my-name/yaml-companion.nvim/actions/workflows/main.yml)
![telescope](./resources/screenshots/telescope.png)
![statusbar](./resources/screenshots/statusbar.png)## ⚡️ Requirements
- [plenary.nvim](https://github.com/nvim-lua/plenary.nvim)
- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
- [yaml-language-server](https://github.com/redhat-developer/yaml-language-server)## ✨ Features
- Builtin Kubernetes manifest autodetection
- Get/Set specific JSON schema per buffer
- Extensible autodetection + Schema Store support## 📦 Installation
Install the plugin and load the `telescope` extension with your preferred package manager:
**Packer**
```lua
use {
"someone-stole-my-name/yaml-companion.nvim",
requires = {
{ "neovim/nvim-lspconfig" },
{ "nvim-lua/plenary.nvim" },
{ "nvim-telescope/telescope.nvim" },
},
config = function()
require("telescope").load_extension("yaml_schema")
end,
}
```## ⚙️ Configuration
**yaml-companion** comes with the following defaults:
```lua
{
-- Built in file matchers
builtin_matchers = {
-- Detects Kubernetes files based on content
kubernetes = { enabled = true },
cloud_init = { enabled = true }
},-- Additional schemas available in Telescope picker
schemas = {
--{
--name = "Kubernetes 1.22.4",
--uri = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.4-standalone-strict/all.json",
--},
},-- Pass any additional options that will be merged in the final LSP config
lspconfig = {
flags = {
debounce_text_changes = 150,
},
settings = {
redhat = { telemetry = { enabled = false } },
yaml = {
validate = true,
format = { enable = true },
hover = true,
schemaStore = {
enable = true,
url = "https://www.schemastore.org/api/json/catalog.json",
},
schemaDownload = { enable = true },
schemas = {},
trace = { server = "debug" },
},
},
},
}
``````lua
local cfg = require("yaml-companion").setup({
-- Add any options here, or leave empty to use the default settings
-- lspconfig = {
-- cmd = {"yaml-language-server"}
-- },
})
require("lspconfig")["yamlls"].setup(cfg)
```## 🚀 Usage
### Select a schema for the current buffer
No mappings included, you need to map it yourself or call it manually:
```
:Telescope yaml_schema
```Alternatively, you can use `vim.ui.select` to use the picker of your choice. In that case, you can bind/call the function:
```lua
require("yaml-companion").open_ui_select()
```### Get the schema name for the current buffer
You can show the current schema in your statusline using a function like:
```lua
local function get_schema()
local schema = require("yaml-companion").get_buf_schema(0)
if schema.result[1].name == "none" then
return ""
end
return schema.result[1].name
end
```