Skip to content

Commit b8351e4

Browse files
committed
feat(lsp): add SchemaStore.nvim for yamlls and jsonls
1 parent f29b3cb commit b8351e4

File tree

4 files changed

+46
-49
lines changed

4 files changed

+46
-49
lines changed

lua/core/settings.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ settings["lsp_deps"] = {
112112
-- "azure_pipelines_ls",
113113
"bashls",
114114
"clangd",
115-
"docker_compose_language_service",
115+
-- "docker_compose_language_service",
116116
"dockerls",
117117
-- NOTE: not-yet registered in mason.nvim, install it via `npm i -g gh-actions-language-server`
118118
-- "gh_actions_ls",
@@ -128,7 +128,7 @@ settings["lsp_deps"] = {
128128
"pylsp",
129129
"taplo",
130130
"terraformls",
131-
-- "yamlls",
131+
"yamlls",
132132
-- "emmet_ls",
133133
-- "ltex",
134134
-- "nginx_language_server",

lua/modules/configs/completion/servers/jsonls.lua

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,11 @@ return {
33
flags = { debounce_text_changes = 500 },
44
settings = {
55
json = {
6-
-- Schemas https://www.schemastore.org
7-
schemas = {
8-
{
9-
fileMatch = { "package.json" },
10-
url = "https://json.schemastore.org/package.json",
11-
},
12-
{
13-
fileMatch = { "tsconfig*.json" },
14-
url = "https://json.schemastore.org/tsconfig.json",
15-
},
16-
{
17-
fileMatch = {
18-
".prettierrc",
19-
".prettierrc.json",
20-
"prettier.config.json",
21-
},
22-
url = "https://json.schemastore.org/prettierrc.json",
23-
},
24-
{
25-
fileMatch = { ".eslintrc", ".eslintrc.json" },
26-
url = "https://json.schemastore.org/eslintrc.json",
27-
},
28-
{
29-
fileMatch = {
30-
".babelrc",
31-
".babelrc.json",
32-
"babel.config.json",
33-
},
34-
url = "https://json.schemastore.org/babelrc.json",
35-
},
36-
{
37-
fileMatch = { "lerna.json" },
38-
url = "https://json.schemastore.org/lerna.json",
39-
},
40-
{
41-
fileMatch = {
42-
".stylelintrc",
43-
".stylelintrc.json",
44-
"stylelint.config.json",
45-
},
46-
url = "http://json.schemastore.org/stylelintrc.json",
47-
},
48-
{
49-
fileMatch = { "/.github/workflows/*" },
50-
url = "https://json.schemastore.org/github-workflow.json",
51-
},
52-
},
6+
validate = { enable = true },
7+
format = { enable = true },
8+
hover = true,
9+
schemaDownload = { enable = true },
10+
schemas = require("schemastore").json.schemas(),
5311
},
5412
},
5513
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/yamlls.lua
2+
return {
3+
cmd = { "yaml-language-server", "--stdio" },
4+
filetypes = { "yaml", "yaml.docker-compose", "yaml.gitlab" },
5+
root_dir = function(fname)
6+
return vim.fs.dirname(vim.fs.find(".git", { path = fname, upward = true })[1])
7+
end,
8+
single_file_support = true,
9+
debounce_text_changes = 150,
10+
settings = {
11+
-- https://github.com/redhat-developer/vscode-redhat-telemetry#how-to-disable-telemetry-reporting
12+
redhat = { telemetry = { enabled = false } },
13+
yaml = {
14+
validate = true,
15+
format = { enable = false },
16+
hover = true,
17+
schemaDownload = { enable = true },
18+
schemaStore = {
19+
-- You must disable built-in schemaStore support if you want to use
20+
-- SchemaStore.nvim and its advanced options like `ignore`.
21+
enable = false,
22+
-- Avoid TypeError: Cannot read properties of undefined (reading 'length')
23+
url = "",
24+
},
25+
schemas = require("schemastore").yaml.schemas({
26+
extra = {
27+
{
28+
name = "docker-compose",
29+
description = "docker-compose YAML schema",
30+
fileMatch = { "docker-compose*.{yml,yaml}", "compose*.{yml,yaml}" },
31+
url = "https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json",
32+
},
33+
},
34+
}),
35+
-- trace = { server = "debug" },
36+
},
37+
},
38+
}

lua/modules/plugins/completion.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ completion["neovim/nvim-lspconfig"] = {
88
dependencies = {
99
{ "williamboman/mason.nvim" },
1010
{ "williamboman/mason-lspconfig.nvim" },
11+
{ "b0o/schemastore.nvim" },
1112
},
1213
}
1314
completion["nvimdev/lspsaga.nvim"] = {

0 commit comments

Comments
 (0)