From 540268d618627079c9b958a955b586e1888b46a8 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Tue, 10 Aug 2021 23:15:04 +0200 Subject: Major refactor of nvim --- .config/nvim/lua/extra/json_schemas.lua | 99 +++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .config/nvim/lua/extra/json_schemas.lua (limited to '.config/nvim/lua/extra/json_schemas.lua') diff --git a/.config/nvim/lua/extra/json_schemas.lua b/.config/nvim/lua/extra/json_schemas.lua new file mode 100644 index 0000000..590547b --- /dev/null +++ b/.config/nvim/lua/extra/json_schemas.lua @@ -0,0 +1,99 @@ +-- https://www.schemastore.org/json/ +local M = {} + +M.setup = function() + local schemas = { + { + description = "Package JSON file", + fileMatch = { "package.json" }, + url = "https://json.schemastore.org/package.json", + }, + { + description = "TypeScript compiler configuration file", + fileMatch = { "tsconfig.json", "tsconfig.*.json" }, + url = "http://json.schemastore.org/tsconfig", + }, + { + description = "Lerna config", + fileMatch = { "lerna.json" }, + url = "http://json.schemastore.org/lerna", + }, + { + description = "Babel configuration", + fileMatch = { ".babelrc.json", ".babelrc", "babel.config.json" }, + url = "http://json.schemastore.org/lerna", + }, + { + description = "ESLint config", + fileMatch = { ".eslintrc.json", ".eslintrc" }, + url = "http://json.schemastore.org/eslintrc", + }, + { + description = "Bucklescript config", + fileMatch = { "bsconfig.json" }, + url = "https://bucklescript.github.io/bucklescript/docson/build-schema.json", + }, + { + description = "Prettier config", + fileMatch = { ".prettierrc", ".prettierrc.json", "prettier.config.json" }, + url = "http://json.schemastore.org/prettierrc", + }, + { + description = "Vercel Now config", + fileMatch = { "now.json" }, + url = "http://json.schemastore.org/now", + }, + { + description = "Stylelint config", + fileMatch = { ".stylelintrc", ".stylelintrc.json", "stylelint.config.json" }, + url = "http://json.schemastore.org/stylelintrc", + }, + { + name = "Helm Chart.yaml", + description = "The Chart.lock file locks dependencies from Chart.yaml", + fileMatch = { "Chart.lock" }, + url = "https://json.schemastore.org/chart-lock.json" + }, + { + name = "CircleCI config.yml", + description = "Schema for CircleCI 2.0 config files", + fileMatch = { ".circleci/config.yml" }, + url = "https://json.schemastore.org/circleciconfig.json" + }, + { + name = "yamllint", + description = "yamllint uses a set of rules to check source files for problems", + fileMatch = { "**/.yamllint", "**/.yamllint.yaml", "**/.yamllint.yml" }, + url = "https://json.schemastore.org/yamllint.json" + }, + { + name = "Hadolint", + description = "A smarter Dockerfile linter that helps you build best practice Docker images.", + fileMatch = { ".hadolint.yaml", "hadolint.yaml", ".hadolint.yml", "hadolint.yml" }, + url = "https://raw.githubusercontent.com/hadolint/hadolint/master/contrib/hadolint.json" + }, + { + name = "kustomization.yaml", + description = "Kubernetes native configuration management", + fileMatch = { "kustomization.yaml", "kustomization.yml" }, + url = "https://json.schemastore.org/kustomization.json" + }, + } + + local function extend(tab1, tab2) + for _, value in ipairs(tab2) do + table.insert(tab1, value) + end + return tab1 + end + + local extended_schemas = extend(schemas, require("nlspsettings.jsonls").get_default_schemas()) + + options.lang.json.lsp.setup.settings = { + json = { + schemas = extended_schemas, + }, + } +end + +return M -- cgit v1.2.3-70-g09d2