• Stars
    star
    709
  • Rank 63,285 (Top 2 %)
  • Language
    Lua
  • License
    Apache License 2.0
  • Created almost 3 years ago
  • Updated 9 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ› JSON schemas for Neovim

SchemaStore.nvim Version License: Apache 2.0 Test Status Build Status

A Neovim Lua plugin providing access to the SchemaStore catalog.

Install

Packer:

use "b0o/schemastore.nvim"

Usage

To use SchemaStore.nvim with lspconfig + jsonls:

require('lspconfig').jsonls.setup {
  settings = {
    json = {
      schemas = require('schemastore').json.schemas(),
      validate = { enable = true },
    },
  },
}

For an explanation of why the validate = { enable = true } option is recommended, see #8.

yamlls is also supported:

require('lspconfig').yamlls.setup {
  settings = {
    yaml = {
      schemaStore = {
        -- You must disable built-in schemaStore support if you want to use
        -- this plugin and its advanced options like `ignore`.
        enable = false,
        -- Avoid TypeError: Cannot read properties of undefined (reading 'length')
        url = "",
      },
      schemas = require('schemastore').yaml.schemas(),
    },
  },
}

To use a subset of the catalog, you can select schemas by name (see the catalog for a full list):

require('lspconfig').jsonls.setup {
  settings = {
    json = {
      schemas = require('schemastore').json.schemas {
        select = {
          '.eslintrc',
          'package.json',
        },
      },
      validate = { enable = true },
    },
  },
}

To ignore certain schemas from the catalog:

require('lspconfig').jsonls.setup {
  settings = {
    json = {
      schemas = require('schemastore').json.schemas {
        ignore = {
          '.eslintrc',
          'package.json',
        },
      },
      validate = { enable = true },
    },
  },
}

Note that the select and ignore options are mutually exclusive and attempting to use them together will throw an error.

To replace certain schemas from the catalog with your own:

require('lspconfig').jsonls.setup {
  settings = {
    json = {
      schemas = require('schemastore').json.schemas {
        replace = {
          ['package.json'] = {
            description = 'package.json overriden',
            fileMatch = { 'package.json' },
            name = 'package.json',
            url = 'https://example.com/package.json',
          },
        },
      },
      validate = { enable = true },
    },
  },
}

If you want to include additional schemas, you can use extra:

require('lspconfig').jsonls.setup {
  settings = {
    json = {
      schemas = require('schemastore').json.schemas {
        extra = {
          {
            description = 'My custom JSON schema',
            fileMatch = 'foo.json',
            name = 'foo.json',
            url = 'https://example.com/schema/foo.json',
          },
          {
            description = 'My other custom JSON schema',
            fileMatch = { 'bar.json', '.baar.json' },
            name = 'bar.json',
            url = 'https://example.com/schema/bar.json',
          },
        },
      },
      validate = { enable = true },
    },
  },
}

Changelog

26 May 2023                                                             v0.2.0
  Feat: Add `extra` option to add additional schemas (@williamboman)
  Docs: Mention disabling built-in for yaml (@davidosomething)
  Feat: Add support for yamlls (@ZenLian)

21 Dec 2021                                                             v0.1.0
  Perf: Add lookup table from schema name to schema index
  Note that select & ignore are mutually exclusive
  Exit with non-zero code if generate script fails
  Update docs
  Update NOTICE
  Clean up formatting
  Update tests
  Fix example in README
  Feat: Add option to ignore schemas by name

15 Oct 2021                                                             v0.0.1
  Initial Release

License

ยฉ 2021-2023 Maddison Hellstrom and Contributors.

Released under the Apache 2.0 License.

More Repositories

1

incline.nvim

๐ŸŽˆ Floating statuslines for Neovim, winbar alternative
Lua
759
star
2

surfingkeys-conf

๐Ÿ„ A SurfingKeys config which adds 180+ key mappings & 50+ search engines
JavaScript
373
star
3

mapx.nvim

๐Ÿ—บ A better way to create key mappings in Neovim
Lua
255
star
4

nvim-conf

โ˜„ Maddison's Neovim configuration!
Lua
144
star
5

awesome-by-example

๐Ÿ˜Ž A curated list of example-based learning resources.
121
star
6

aws-favicons-webextension

โ˜ Tired of all your AWS browser tabs having the same orange cube favicon? This WebExtension fixes that.
JavaScript
95
star
7

tmux-autoreload

๐Ÿง Automatically reload your tmux config file on change
Shell
74
star
8

apple-autofill-domains

Apple's allowed autofill domains
63
star
9

nvim-tree-preview.lua

๐Ÿƒ Floating preview windows for nvim-tree
Lua
59
star
10

swaynagmode

โŒจ swaynag wrapper for the love of keybindings
Shell
44
star
11

starred

๐ŸŒŸ Maddison's starred repos, updated daily!
42
star
12

blender.nvim

๐Ÿ”ถ Develop Blender Add-ons with Neovim
Lua
38
star
13

snag

๐Ÿ“ธ snag screenshots and screencasts in Sway
Shell
30
star
14

zfzf

zfzf is a fzf-based file picker for zsh which allows you to quickly navigate the directory hierarchy
Shell
25
star
15

lavi.nvim

๐Ÿชป A soft and sweet colorscheme for Neovim
Lua
25
star
16

neuron-extras

Auto-generate a Table of Contents for your Neuron Zettelkasten.
JSONiq
13
star
17

updoot

๐ŸŽบ Unify the update process for your entire system
Shell
12
star
18

arch-lwc

๐Ÿš› Create & run lightweight Arch Linux containers
Shell
10
star
19

clipshare

Securely synchronize your clipboard between computers
JavaScript
6
star
20

b0o

๐Ÿ‘ป
JavaScript
6
star
21

tmux-conf

Maddison's tmux configuration!
Shell
5
star
22

dotfiles

๐Ÿซฅ Maddison's dotfiles
5
star
23

refind-genconf

refind-genconf makes it easier to generate rEFInd configurations for multiple kernels
Shell
5
star
24

spotify-export

Export a listing of your saved tracks as JSON
JavaScript
5
star
25

zsh-conf

Maddy's zsh configuration!
Shell
5
star
26

alacritty-conf

Maddison's alacritty configuration!
Shell
4
star
27

zsh-extras

Extra completions and functions for zsh!
Shell
3
star
28

maddison.io

maddison's github pages blog
Dhall
2
star
29

Mulberry

Mulberry is a single-file Lua BDD library for testing Neovim plugins.
Lua
2
star
30

I-m-using-GitHub-like-Twitter-now

This is my first โ€œtweetโ€. I guess youโ€™d call it a gleet? Or a giit? Hubeet? A hut? Octomew?
2
star
31

nextdns-logs-export

Export your NextDNS logs
JavaScript
2
star
32

btrfs-extras

extra tools for managing btrfs and btrbk. Warning: experimental - don't use anything you find here and expect your filesystem to survive
Shell
2
star
33

wezterm-conf

Lua
1
star
34

Steam-HiDPI

HiDPI skin for Steam [WIP]
JavaScript
1
star
35

builder.vim

A VimL DSL for building Patterns and Syntax Rules
Vim Script
1
star
36

advent-of-code-2023-jq

Advent of Code 2023 in Jq
jq
1
star
37

playground

A local Golang playground optimized for tmux/vim environments
Go
1
star
38

kitty-conf

1
star
39

synergy-core

A fork of symless/synergy-core 1.9 with some added features
C++
1
star
40

ndbproxy

A proxy/bridge that runs between a Node.JS debug server and a Chromium devtools client and adds some additional features.
Python
1
star
41

suto

get sudo timeout status
Shell
1
star
42

vim-HiLinkTrace

Vim Script
1
star
43

ghostty-conf

๐Ÿ‘ป Maddison's Ghostty config!
GLSL
1
star
44

blender-addon-template

Blender Add-on Starter Template
Python
1
star