Skip to content

KevinNitroG/kubernetes-schema-snippets.nvim

Repository files navigation

Kubernetes Schema Snippets

Add inline schema references for Kubernetes resources and CRDs using snippets

kube-snip-v2

Source of video: https://asciinema.org/a/730906

The differences from other plugins is that it doesn't patch, interfere the language server's settings, auto match base on file content. It just provide a fast way to add inline schema.

Note

Support L3MON4D3/LuaSnip only

Important

You will need to use yaml-language-server to have suggestions and documentations like in the video.


ToC


Usage

Installation

-- lazy.nvim
{
  "KevinNitroG/kubernetes-schema-snippets.nvim",
  ft = "yaml",
  config = true,
  dependencies = "L3MON4D3/LuaSnip",
}

Default options

---@module 'kubernetes-json-schema'
---@type KubernetesJsonSchema.Opts
{
  filetypes = {
    "yaml",
  },
  integrations = {
    kubernetes = true,
    kustomize = true,
    crds_catalog = true,
    argocd = true,
    flux2 = true,
  },
}

Use

  • Snippets:
    • schema-kube
    • schema-kustomize, kus
    • schema-crds-catalog
    • schema-argocd, argocd-app, argocd-appset
    • schema-flux2
  • Choose version, type, resources by iterating versions either using:
    • Next:
      <Plug>luasnip-next-choice
    • Prev:
      <Plug>luasnip-prev-choice
    • Open choices with vim.ui.select using:
      require("luasnip.extras.select_choice")()
    • Enter yourself by going to the last choice and type string

Warning

The resources of Kubernetes, argocd are from the master version. Choosing older versions might not have the resources of the latest one.

LuaSnip keymaps

Below is an example of my personal keymaps configuration for LuaSnip. You may use it as a reference for your setup.

---@module 'lazy'
---@type LazySpec
return {
  "L3MON4D3/LuaSnip",
  keys = {
    {
      "<C-n>",
      "<Plug>luasnip-next-choice",
      silent = true,
      mode = { "i", "s" },
    },
    {
      "<C-p>",
      "<Plug>luasnip-prev-choice",
      silent = true,
      mode = { "i", "s" },
    },
    {
      "<M-e>",
      function()
        if require("luasnip").expand_or_jumpable() then
          require("luasnip").expand_or_jump()
        end
      end,
      silent = true,
      mode = { "i", "s" },
      noremap = true,
    },
    {
      "<M-c>",
      function()
        if require("luasnip").choice_active() then
          require("luasnip.extras.select_choice")()
        end
      end,
      silent = true,
      mode = { "i", "s" },
    },
  },
}

Others

Resources' Sources

Related plugins

Acknowledgements

About

Add inline schema references for Kubernetes resources and CRDs using snippets

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages