Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

msvechla/yaml-companion.nvim

Open more actions menu
 
 

Repository files navigation

yaml-companion.nvim Build

telescope statusbar

⚡️ Requirements

✨ 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

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:

{
  -- 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" },
      },
    },
  },
}
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:

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:

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

About

Get, set and autodetect YAML schemas in your buffers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 91.8%
  • Perl 4.5%
  • Makefile 3.0%
  • Vim Script 0.7%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.