Skip to content

Repository with JSON schemas of Spack config files for editor support

Notifications You must be signed in to change notification settings

pranav-sivaraman/schemas

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Editor support for Spack config files

To get validation and autocompletion of Spack configuration files, enable an extension for the YAML Language Server Protocol (LSP) in your editor of choice.

  • Visual Studio Code: Install the YAML Language Support extension by Red Hat.

  • Neovim: Install yaml-language-server.

    0.11.x and newer
    --- $XDG_CONFIG_HOME/nvim/lsp/yamlls.lua
    return {
      cmd = { "yaml-language-server", "--stdio" },
      filetypes = { "yaml", "yaml.docker-compose", "yaml.gitlab" },
      single_file_support = true,
      settings = {
        -- https://github.com/redhat-developer/vscode-redhat-telemetry#how-to-disable-telemetry-reporting
        redhat = { telemetry = { enabled = false } },
      },
    }
    
    --- $XDG_CONFIG_HOME/nvim/init.lua
    vim.lsp.enable("yamlls")
    
    -- Bootstrap lazy.nvim
    local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
    if not (vim.uv or vim.loop).fs_stat(lazypath) then
        local lazyrepo = "https://github.com/folke/lazy.nvim.git"
        local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
        if vim.v.shell_error ~= 0 then
            vim.api.nvim_echo({
                { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
                { out, "WarningMsg" },
                { "\nPress any key to exit..." },
            }, true, {})
            vim.fn.getchar()
            os.exit(1)
        end
    end
    vim.opt.rtp:prepend(lazypath)
    
    vim.g.mapleader = " "
    vim.g.maplocalleader = "\\"
    
    -- Setup lazy.nvim
    require("lazy").setup({
        spec = {
            -- For completions.
            -- See https://cmp.saghen.dev/ for more config options
            { "saghen/blink.cmp", opts = {} },
        },
        checker = { enabled = true },
    })
    0.10.x and older
    -- Bootstrap lazy.nvim
    local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
    if not (vim.uv or vim.loop).fs_stat(lazypath) then
        local lazyrepo = "https://github.com/folke/lazy.nvim.git"
        local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
        if vim.v.shell_error ~= 0 then
            vim.api.nvim_echo({
                { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
                { out, "WarningMsg" },
                { "\nPress any key to exit..." },
            }, true, {})
            vim.fn.getchar()
            os.exit(1)
        end
    end
    vim.opt.rtp:prepend(lazypath)
    
    vim.g.mapleader = " "
    vim.g.maplocalleader = "\\"
    
    -- Setup lazy.nvim
    require("lazy").setup({
        spec = {
            {
              "neovim/nvim-lspconfig",
              config = function()
                local lspconfig = require("lspconfig")
    
                lspconfig.yamlls.setup({})
              end,
            }
            -- For completions.
            -- See https://cmp.saghen.dev/ for more config options
            { "saghen/blink.cmp", opts = {} },
        },
        checker = { enabled = true },
    })

Then add the following line at the top of your YAML file:

Environments (spack.yaml)

# yaml-language-server: $schema=https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/spack.json

Packages (packages.yaml)

# yaml-language-server: $schema=https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/packages.json

Config (config.yaml)

# yaml-language-server: $schema=https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/config.json

Modules (modules.yaml)

# yaml-language-server: $schema=https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/modules.json

Mirrors (mirrors.yaml)

# yaml-language-server: $schema=https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/mirrors.json

Concretizer (concretizer.yaml)

# yaml-language-server: $schema=https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/concretizer.json

CI (ci.yaml)

# yaml-language-server: $schema=https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/ci.json

About

Repository with JSON schemas of Spack config files for editor support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%