Skip to content

Commit

Permalink
Add docs for setting up Vim jsonschema.
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Goff <[email protected]>
Co-authored-by: Adam Perlin <[email protected]>
  • Loading branch information
cpuguy83 and adamperlin committed Jul 16, 2024
1 parent 00de914 commit e57936a
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions website/docs/editor-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,60 @@ The yaml plugin will complain that it is an incorrect type. To fix this you can
args:
FOO: ""
```

## Vim

For vim there are 2 required vim plugins to add to your vimrc, though you may
find your own equivalents. The example below uses vim-plug to manage the plugins.
The first two listed below are required, the second two are recommended.

```
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
```
The `mattn/vim-lsp-settings` is a generic plugin for installing and managing
LSP servers on your system.
See the [github](https://github.com/mattn/vim-lsp-settings) repo for more details
as well as links to the other mentioned plugins.
After the plugins are installed, while editing a yaml file you need to run the
following vim command to install the correct LSP, this only needs to be done one
time:
```
:LspInstallServer
```
Finally, in your project dir you can add a file `.vim-lsp-settings/settings.json`
where we'll put the yaml LSP config for the particular project. Here is an example
similar to the vscode example above:
```json
{
"yaml-language-server": {
"schemas": [
{
"fileMatch": ["test/fixtures/*.yml"],
"url": "https://raw.githubusercontent.com/Azure/dalec/<version>/docs/spec.schema.json"
}
],
"completion": true,
"validate": true
}
}
```

In the `"fileMatch"` section you can add the file patterns to associate the schema
with.
In this case, `<version>` should be replaced with the specific Dalec frontend
version (i.e., `v0.6.1`) that is referenced in any files which match the
`fileMatch` pattern. To pick up whatever the latest schema is, released or not,
use `main`.

:::note
One or more of the above plugins depend on node.js and is known to work with
node >= 16.20 but may work with earlier releases.
:::

0 comments on commit e57936a

Please sign in to comment.