Linting and Autocompletion

This is a way to validate your fodder schema files and to provide helpful hints to you as you write them, such as what fields are available and what arguments they take.

Setting up linting in your IDE

Output the JSON schema to the root of your project, this is what is used to provide linting and autocompletion.

fodder -d > lint.json

VSCode

Configure your IDE to use this JSON schema. For VSCode, ensure you have the correct extension installed (YAML) and add the following to your settings.json:

{
  "yaml.schemas": {
    "./lint.json": "*.fodder.yaml"
  }
}

Neovim

If you are using Neovim with nvim-lspconfig and lazy.nvim you can use the below snippet. If you aren't, you should still be able to use the JSON schema to configure your IDE - but you will have to go on that adventure by yourself!

return {
  {
    "neovim/nvim-lspconfig",
    opts = {
      servers = {
        yamlls = {
          settings = {
            yaml = {
              schemas = {
                ["./lint.json"] = "*.fodder.yaml",
              },
            },
          },
        },
      },
    },
  },
}

Provided you have set everything up as detailed above and named your fodder schema file with the .fodder.yaml suffix you should get linting and autocompletion!