JSON
info
You can enable the extra with the :LazyExtras
command.
Plugins marked as optional will only be configured if they are installed.
Alternatively, you can add it to your lazy.nvim
imports
lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "plugins" },
},
})
Below you can find a list of included plugins and their default settings.
caution
You don't need to copy the default settings to your config. They are only shown here for reference.
nvim-treesitter
add json to treesitter
- Options
- Full Spec
opts = { ensure_installed = { "json5" } }
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "json5" } },
}
SchemaStore.nvim
yaml schema support
- Options
- Full Spec
opts = nil
{
"b0o/SchemaStore.nvim",
lazy = true,
version = false, -- last release is way too old
}
nvim-lspconfig
correctly setup lspconfig
- Options
- Full Spec
opts = {
-- make sure mason installs the server
servers = {
jsonls = {
-- lazy-load schemastore when needed
on_new_config = function(new_config)
new_config.settings.json.schemas = new_config.settings.json.schemas or {}
vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas())
end,
settings = {
json = {
format = {
enable = true,
},
validate = { enable = true },
},
},
},
},
}
{
"neovim/nvim-lspconfig",
opts = {
-- make sure mason installs the server
servers = {
jsonls = {
-- lazy-load schemastore when needed
on_new_config = function(new_config)
new_config.settings.json.schemas = new_config.settings.json.schemas or {}
vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas())
end,
settings = {
json = {
format = {
enable = true,
},
validate = { enable = true },
},
},
},
},
},
}