Skip to content

tonychg/nvim-k8s-lsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

nvim-k8s-lsp

Experimental plugin to auto-detect Kubernetes schemas.

Inspired by someone-stole-my-name/yaml-companion.nvim

This plugin is in the early development phase. I developed it because I couldn't find a good solution and it helps me in my daily work.

🦶 Requirements

🍚 Concept

  • Schemas detection
  • Native CRD matching
  • Minimalist
  • Dynamic yaml-language-server and helm-ls reload

👍 Setup

Plugin

Lazy

return {
  'tonychg/nvim-k8s-lsp',
  config = function()
    require("nvim-k8s-lsp").setup({
      kubernetes_version = "v1.32.2",
      lsp = {
        clients = {
          yaml = "yaml",
          helm = "helm",
        },
      },
      schema_stores = {
        kubernetes = {
          repo = "yannh/kubernetes-json-schema",
          branch = "master",
        },
        kubernetes_crds = {
          repo = "datreeio/CRDs-catalog",
          branch = "main",
        },
      },
      integrations = {
        lualine = false,
      },
      ignore_groups = {
        "kind.x-k8s.io",
        "kustomize.config.k8s.io",
        "viaduct.ai",
      },
    })
  end,
}

nix

{
    pkgs,
    ...
}: let
  nvim-k8s-lsp = pkgs.vimUtils.buildVimPlugin {
    pname = "nvim-k8s-lsp";
    version = "main";
    src = builtins.fetchGit {
      url = "https://github.com/tonychg/nvim-k8s-lsp.git";
      rev = "da0a121a34eabef458acda13997bc6ab69790073";
      ref = "main";
    };
  };
in
  programs.neovim = {
      plugins = with pkgs; [
          {
            plugin = nvim-k8s-lsp;
            type = "lua";
          }
      ]
      extraPackages = with pkgs; [
        yaml-language-server
      ]
  }

Lsp

  • ${XDG_CONFIG}/nvim/lsp/helm.lua
return {
  cmd = { "/path/to/patch/version/helm_ls", "serve" },
  root_markers = { "values.yaml", "Chart.yaml" },
  settings = {
    ["helm-ls"] = {
      yamlls = {
        enabled = true,
        enabledForFilesGlob = "*.{yaml,yml}",
        diagnosticsLimit = 50,
        showDiagnosticsDirectly = false,
        config = {
          completion = true,
          hover = true,
          schemas = {
            -- Add pre-configured schemas
            -- Must not match any kubernetes manifests to avoid duplicate match
          },
        },
      },
    },
  },
}
  • ${XDG_CONFIG}/nvim/lsp/yaml.lua
return {
  cmd = { "yaml-language-server", "--stdio" },
  filetypes = { "yaml" },
  root_markers = { ".git", ".yamlfmt" },
  settings = {
    yaml = {
      schemaDownload = { enable = true },
      validate = true,
      hover = true,
      trace = { server = "debug" },
      schemas = {
        -- Add pre-configured schemas
        -- Must not match any kubernetes manifests to avoid duplicate match
      },
    },
  },
}
  • ${XDG_CONFIG}/nvim/init.lua
vim.lsp.enable("yaml")
vim.lsp.enable("helm")

References

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages