b0o / schemastore.nvim Goto Github PK
View Code? Open in Web Editor NEW๐ JSON schemas for Neovim
Home Page: https://schemastore.org
License: Apache License 2.0
๐ JSON schemas for Neovim
Home Page: https://schemastore.org
License: Apache License 2.0
Hello, I noticed that openapi 3.0 and 3.1 schemas are missing. Would it be as simple as adding the files from https://github.com/OAI/OpenAPI-Specification/tree/main/schemas to the repo?
When I try to open the file bitbucket-pipelines.yml
throw error below
Error executing vim.schedule lua callback: ...l/Cellar/neovim/0.9.5/share/nvim/runtime/lua/vim/lsp.lua:1308: RPC[Error] code_name = InternalError, message = "Request initialize failed with me
ssage: [UriError]: Scheme is missing: {scheme: \"\", authority: \"\", path: \"null\", query: \"\", fragment: \"\"}"
stack traceback:
[C]: in function 'assert'
...l/Cellar/neovim/0.9.5/share/nvim/runtime/lua/vim/lsp.lua:1308: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
I have tested the other yaml like docker-compose.yml
and works well
I'm using .clang-format
file, schemas provided by yamlls, and I have to add schemas manually.
Is it possible to support yaml?
Thans a lot!
I'm contributing to the schemastore repo but I would like to see if my changes work before creating a PR. Is it possible to use a local schema?
Please subscribe to this issue to be notified of any breaking changes.
After the ZEIT rebrand to Vercel seems like the now.json
file now should be named vercel.json
. (see codesandbox/codesandbox-client#5052).
I have also found the schema (hosted by Vercel): https://vercel.com/changelog/schema-autocomplete-and-validation-for-vercel-json.
I have tried to compare the two files but i couldn't tell if there are differences.
The docs for the vercel.json
file: https://vercel.com/docs/cli#project-configuration
I'm willing to make a PR but i don't know if i should add vercel.json
to the fileMatch
, create a new schema and/or delete the older schema.
Any recommendations?
Hello! Thanks for this wonderful and helpful tool.
I just added a new json schema to my configuration, but it is not being picked up. I was wondering if there is any log I can check to understand why may be happening?
In any case, here is my config
lspManager.setup("jsonls", {
settings = {
json = {
schemas = vim.list_extend({
{
description = "Haxe format schema",
fileMatch = { "hxformat.json" },
name = "hxformat.schema.json",
url = "https://raw.githubusercontent.com/vshaxe/vshaxe/master/schemas/hxformat.schema.json",
},
}, require("schemastore").json.schemas()),
validate = { enable = true },
},
},
})
ERROR packer.nvim: Error running config for nvim-lspconfig: /home/kricss/.config/nvim/lua/config/lsp/installer.lua:9: module 'schemastore' not found:
no field package.preload['schemastore']
no file './schemastore.lua'
no file '/home/runner/work/neovim/neovim/.deps/usr/share/luajit-2.1.0-beta3/schemastore.lua'
no file '/usr/local/share/lua/5.1/schemastore.lua'
no file '/usr/local/share/lua/5.1/schemastore/init.lua'
no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/schemastore.lua'
no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/schemastore/init.lua'
no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/schemastore.lua'
no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/schemastore/init.lua'
no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/schemastore.lua'
no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/schemastore/init.lua'
no file './schemastore.so'
no file '/usr/local/lib/lua/5.1/schemastore.so'
no file '/home/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/schemastore.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/schemastore.so'
plugins.lua config
use {
"neovim/nvim-lspconfig",
opt = true,
event = { "BufReadPre" },
wants = {
"nvim-lsp-installer",
"cmp-nvim-lsp",
"lua-dev.nvim",
"vim-illuminate",
"null-ls.nvim",
"schemastore.nvim",
},
config = function()
require("config.lsp").setup()
end,
requires = {
"williamboman/nvim-lsp-installer",
"folke/lua-dev.nvim",
"RRethy/vim-illuminate",
"jose-elias-alvarez/null-ls.nvim",
{
"j-hui/fidget.nvim",
config = function()
require("fidget").setup {}
end,
},
"b0o/schemastore.nvim",
"jose-elias-alvarez/typescript.nvim",
},
}
installer.lua config
local M = {}
local servers = {
gopls = {},
html = {},
jsonls = {
settings = {
json = {
schemas = require("schemastore").json.schemas(),
},
},
},
pyright = {
analysis = {
typeCheckingMode = "off",
},
},
rust_analyzer = {
settings = {
["rust-analyzer"] = {
cargo = { allFeatures = true },
checkOnSave = {
command = "clippy",
extraArgs = { "--no-deps" },
},
},
},
},
sumneko_lua = {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
-- Setup your lua path
path = vim.split(package.path, ";"),
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim", "describe", "it", "before_each", "after_each", "packer_plugins" },
-- disable = { "lowercase-global", "undefined-global", "unused-local", "unused-vararg", "trailing-space" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = {
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
},
maxPreload = 2000,
preloadFileSize = 50000,
},
completion = { callSnippet = "Both" },
telemetry = { enable = false },
},
},
},
tsserver = { disable_formatting = true },
vimls = {},
tailwindcss = {},
yamlls = {
schemastore = {
enable = true,
},
settings = {
yaml = {
hover = true,
completion = true,
validate = true,
schemas = require("schemastore").json.schemas(),
},
},
},
jdtls = {},
dockerls = {},
graphql = {},
bashls = {},
kotlin_language_server = {},
marksman = {},
volar = {},
}
function M.setup(options)
local lspconfig = require "lspconfig"
local icons = require "config.icons"
require("mason").setup {
ui = {
icons = {
package_installed = icons.server_installed,
package_pending = icons.server_pending,
package_uninstalled = icons.server_uninstalled,
},
},
}
require("mason-tool-installer").setup {
ensure_installed = {
"codelldb",
"stylua",
"shfmt",
"shellcheck",
"black",
"isort",
"prettierd",
"chrome-debug-adapter",
},
auto_update = false,
run_on_start = true,
}
require("mason-lspconfig").setup {
ensure_installed = vim.tbl_keys(servers),
automatic_installation = false,
}
-- Package installation folder
local install_root_dir = vim.fn.stdpath "data" .. "/mason"
require("mason-lspconfig").setup_handlers {
function(server_name)
local opts = vim.tbl_deep_extend("force", options, servers[server_name] or {})
lspconfig[server_name].setup { opts }
end,
["jdtls"] = function()
-- print "jdtls is handled by nvim-jdtls"
end,
["sumneko_lua"] = function()
local opts = vim.tbl_deep_extend("force", options, servers["sumneko_lua"] or {})
lspconfig.sumneko_lua.setup(require("lua-dev").setup { opts })
end,
["rust_analyzer"] = function()
local opts = vim.tbl_deep_extend("force", options, servers["rust_analyzer"] or {})
-- DAP settings - https://github.com/simrat39/rust-tools.nvim#a-better-debugging-experience
local extension_path = install_root_dir .. "/packages/codelldb/extension/"
local codelldb_path = extension_path .. "adapter/codelldb"
local liblldb_path = extension_path .. "lldb/lib/liblldb.so"
require("rust-tools").setup {
tools = {
executor = require("rust-tools/executors").toggleterm,
hover_actions = { border = "solid" },
on_initialized = function()
vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter", "CursorHold", "InsertLeave" }, {
pattern = { "*.rs" },
callback = function()
vim.lsp.codelens.refresh()
end,
})
end,
},
server = opts,
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
},
}
end,
["tsserver"] = function()
local opts = vim.tbl_deep_extend("force", options, servers["tsserver"] or {})
require("typescript").setup {
disable_commands = false,
debug = false,
server = opts,
}
end,
}
end
return M
I don't know what went wrong please help me
I was surprised to find that my tsconfig.settings.json was using the Micro JSON schema. I think that more specific FileMatchers should take precedence over less specific ones. Here is where I ran into the issue:
#30
The tsconfig.json doesn't seem to match tsconfig.*.json files.
I tried adding this:
schemas = require('schemastore').json.schemas {
select = {
'.eslintrc',
'lerna.json',
'package.json',
'prettierrc.json',
'tsconfig.json',
'tslint.json'
},
replace = {
['tsconfig.json'] = {
description = 'Custom JSON schema for typescript configuration files',
fileMatch = {'tsconfig*.json'},
name = '.tsconfig.json',
url = 'https://json.schemastore.org/tsconfig.json'
}
}
}
Any ideas?
I noticed that some objects in the store have versions. Is there a way to specify version for buffer/name/pattern in neovim? I.e. for openapi spec the store has:
{
description = "A Open API documentation files",
fileMatch = { "openapi.json", "openapi.yml", "openapi.yaml" },
name = "openapi.json",
url = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json",
versions = {
["3.0"] = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json",
["3.1"] = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"
}
}
It seems like for any openapi.yml/json it validates against 3.1. To force it to use 3.0 i had to totally override schema with replace
in config. Is there a more proper way to do this?
Schemastore.org website is offline, returning 503, today and I've experienced a couple of issues with it last week (timeouts).
It seems like clients should improve and cache things offline. The YAML and JSON language servers should probably handle this themselves, but I think if there was a central cache that neovim manages it would be better. And your plugin seems like a natural fit for providing that API/managing the cache.
Like .eslintrc.js
, prettier.config.js
, .prettier.js
, babel.config.js
, .babelrc.js
and such. JSON ones work perfectly for me but some of the files I used is in their .js
form. Is there a workaround for them?
Great plugin by the way, thanks!
Any chance to get TOML support?
According to the TOML docs, it supports JSON schema.
I'd be happy to help :)
neovim-awesome is a repo with a lot of links to awesome neovim projects.
I found this project really nicely done, so I wanted to add it there so other people can find it more easily.
I added it under the LSP category in the PR.
EDIT: Sorry for creating an issue for this. I didn't know how else to notify you appropriately for this.
NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3
SchemaStore.nvim a6759df
My LSP config with SchemaStore.nvim
Special characters are prefixed by \
resulting in broken URLs.
This behaviour happens both in YAML and JSON files.
Escaping symbols like \
is not visible in the hover window. Links are usable.
https://github.com/SchemaStore/schemastore/blob/master/.pre-commit-config.yaml
---
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v3.0.2'
hooks:
- id: prettier
types_or: [yaml, json, javascript, css, markdown]
always_run: true
additional_dependencies:
- [email protected]
- [email protected]
Hi,
Apologies if this is the wrong repo to report this too, but I've narrowed down nvim not showing diagnostics for json files to the configuration used to reference the schemastore json schemas.
Specifically, adding this to the lsp setup
stops diagnostics from rendering in nvim (though I do see them in the LSP log if I use debug
)
settings = {
json = {
schemas = require('schemastore').json.schemas(),
},
},
lsp log:
[DEBUG][2022-05-17 11:23:58] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "textDocument/publishDiagnostics", params = { diagnostics = {}, uri = "file:///home/mcritchlow/projects/ucsd/highfive/renovate.json" }}
[DEBUG][2022-05-17 11:24:27] .../vim/lsp/rpc.lua:347 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { end = { character = 11, line = 1 }, start = { character = 10, line = 1 } }, rangeLength = 1, text = "'" } }, textDocument = { uri = "file:///home/mcritchlow/projects/ucsd/highfive/renovate.json", version = 4 } }}
[DEBUG][2022-05-17 11:24:27] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "textDocument/publishDiagnostics", params = { diagnostics = {}, uri = "file:///home/mcritchlow/projects/ucsd/highfive/renovate.json" }}
minimal init.lua
(borrowed from lspconfig and modified for this issue)
local on_windows = vim.loop.os_uname().version:match 'Windows'
local function join_paths(...)
local path_sep = on_windows and '\\' or '/'
local result = table.concat({ ... }, path_sep)
return result
end
vim.cmd [[set runtimepath=$VIMRUNTIME]]
local temp_dir = vim.loop.os_getenv 'TEMP' or '/tmp'
vim.cmd('set packpath=' .. join_paths(temp_dir, 'nvim', 'site'))
local package_root = join_paths(temp_dir, 'nvim', 'site', 'pack')
local install_path = join_paths(package_root, 'packer', 'start', 'packer.nvim')
local compile_path = join_paths(install_path, 'plugin', 'packer_compiled.lua')
local function load_plugins()
require('packer').startup {
{
'wbthomason/packer.nvim',
'b0o/schemastore.nvim',
'williamboman/nvim-lsp-installer', {
'neovim/nvim-lspconfig',
}
},
config = {
package_root = package_root,
compile_path = compile_path,
},
}
end
_G.load_config = function()
vim.lsp.set_log_level 'trace'
if vim.fn.has 'nvim-0.5.1' == 1 then
require('vim.lsp.log').set_format_func(vim.inspect)
end
local nvim_lsp = require 'lspconfig'
local lsp_installer = require("nvim-lsp-installer")
local on_attach = function(_, bufnr)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap = true, silent = true }
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
end
local name = 'jsonls'
local capabilities = vim.lsp.protocol.make_client_capabilities()
lsp_installer.setup {
ensure_installed = name,
automatic_installation = true,
}
nvim_lsp[name].setup {
on_attach = on_attach,
capabilities = capabilities,
settings = {
json = {
schemas = require('schemastore').json.schemas(),
},
},
}
print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
end
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]
else
load_plugins()
require('packer').sync()
_G.load_config()
end
Hello, could you add FHIR R4 schema to the repo?
I've tried to add it locally, but it doesn't work :(
require("schemastore").json.schemas({
extra = {
{
description = "FHIR JSON schema",
fileMatch = "*.fhir.json",
name = "fhir.json",
url = "/home/me/fhir.schema.json", -- or '/path/to/your/schema.json'
},
},
})
Also, I've moved to "extra" to jsonls config, and nothing happens..
Hey! I would like to display current schema in status line. Is it possible to access it somehow?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.