mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/schemastore: adapt to new lsp module
Modify warnings, tests, and default settings to work with the new lsp module. Update plugins/by-name/schemastore/default.nix Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk> Update plugins/by-name/schemastore/default.nix Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
This commit is contained in:
parent
4b27678512
commit
8523385bd8
2 changed files with 130 additions and 56 deletions
|
@ -128,15 +128,22 @@ lib.nixvim.plugins.mkVimPlugin {
|
||||||
message = "You have enabled the plugin, but neither `json` or `yaml` schemas are enabled.";
|
message = "You have enabled the plugin, but neither `json` or `yaml` schemas are enabled.";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
when = !(cfg.json.enable -> config.plugins.lsp.servers.jsonls.enable);
|
when =
|
||||||
message = "You have enabled `json` schemas, but `plugins.lsp.servers.jsonls` is not enabled.";
|
cfg.json.enable && !(config.plugins.lsp.servers.jsonls.enable || config.lsp.servers.jsonls.enable);
|
||||||
|
message = ''
|
||||||
|
You have enabled `json` schemas, but neither `plugins.lsp.servers.jsonls` nor `lsp.servers.jsonls` is enabled.
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
when = !(cfg.yaml.enable -> config.plugins.lsp.servers.yamlls.enable);
|
when =
|
||||||
message = "You have enabled `yaml` schemas, but `plugins.lsp.servers.yamlls` is not enabled.";
|
cfg.yaml.enable && !(config.plugins.lsp.servers.yamlls.enable || config.lsp.servers.yamlls.enable);
|
||||||
|
message = ''
|
||||||
|
You have enabled `yaml` schemas, but neither `plugins.lsp.servers.yamlls` nor `lsp.servers.yamlls` is enabled.
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# TODO: Remove once `plugins.lsp` is defunct.
|
||||||
plugins.lsp.servers = {
|
plugins.lsp.servers = {
|
||||||
jsonls.settings = mkIf cfg.json.enable {
|
jsonls.settings = mkIf cfg.json.enable {
|
||||||
schemas.__raw = ''
|
schemas.__raw = ''
|
||||||
|
@ -163,5 +170,32 @@ lib.nixvim.plugins.mkVimPlugin {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lsp.servers = {
|
||||||
|
jsonls.settings.settings = mkIf cfg.json.enable {
|
||||||
|
schemas.__raw = ''
|
||||||
|
require('schemastore').json.schemas(${lib.nixvim.toLuaObject cfg.json.settings})
|
||||||
|
'';
|
||||||
|
|
||||||
|
# The plugin recommends to enable this option in its README.
|
||||||
|
# Learn more: https://github.com/b0o/SchemaStore.nvim/issues/8
|
||||||
|
validate.enable = mkDefault true;
|
||||||
|
};
|
||||||
|
|
||||||
|
yamlls.settings.settings = mkIf cfg.yaml.enable {
|
||||||
|
schemaStore = {
|
||||||
|
# From the README: "You must disable built-in schemaStore support if you want to use
|
||||||
|
# this plugin and its advanced options like `ignore`."
|
||||||
|
enable = mkDefault false;
|
||||||
|
|
||||||
|
# From the README: "Avoid TypeError: Cannot read properties of undefined (reading 'length')"
|
||||||
|
url = mkDefault "";
|
||||||
|
};
|
||||||
|
|
||||||
|
schemas.__raw = ''
|
||||||
|
require('schemastore').yaml.schemas(${lib.nixvim.toLuaObject cfg.yaml.settings})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,94 @@
|
||||||
{
|
{
|
||||||
empty = {
|
empty = {
|
||||||
|
lsp = {
|
||||||
|
servers = {
|
||||||
|
jsonls.enable = true;
|
||||||
|
yamlls.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
plugins.schemastore.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
lsp = {
|
||||||
|
servers = {
|
||||||
|
jsonls.enable = true;
|
||||||
|
yamlls.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
plugins.schemastore = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
json = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
replace."package.json" = {
|
||||||
|
description = "package.json overridden";
|
||||||
|
fileMatch = [ "package.json" ];
|
||||||
|
name = "package.json";
|
||||||
|
url = "https://example.com/package.json";
|
||||||
|
};
|
||||||
|
extra = [
|
||||||
|
{
|
||||||
|
description = "My custom JSON schema";
|
||||||
|
fileMatch = "foo.json";
|
||||||
|
name = "foo.json";
|
||||||
|
url = "https://example.com/schema/foo.json";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
description = "My other custom JSON schema";
|
||||||
|
fileMatch = [
|
||||||
|
"bar.json"
|
||||||
|
".baar.json"
|
||||||
|
];
|
||||||
|
name = "bar.json";
|
||||||
|
url = "https://example.com/schema/bar.json";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
yaml = {
|
||||||
|
enable = true;
|
||||||
|
settings = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
withJson = {
|
||||||
|
lsp = {
|
||||||
|
servers.jsonls.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
plugins.schemastore = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
json = {
|
||||||
|
enable = true;
|
||||||
|
settings = { };
|
||||||
|
};
|
||||||
|
yaml.enable = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
withYaml = {
|
||||||
|
lsp = {
|
||||||
|
servers.yamlls.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
plugins.schemastore = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
json.enable = false;
|
||||||
|
yaml = {
|
||||||
|
enable = true;
|
||||||
|
settings = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
emptyOld = {
|
||||||
plugins = {
|
plugins = {
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -14,57 +103,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
example = {
|
withJsonOld = {
|
||||||
plugins = {
|
|
||||||
lsp = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
servers = {
|
|
||||||
jsonls.enable = true;
|
|
||||||
yamlls.enable = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
schemastore = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
json = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
replace."package.json" = {
|
|
||||||
description = "package.json overridden";
|
|
||||||
fileMatch = [ "package.json" ];
|
|
||||||
name = "package.json";
|
|
||||||
url = "https://example.com/package.json";
|
|
||||||
};
|
|
||||||
extra = [
|
|
||||||
{
|
|
||||||
description = "My custom JSON schema";
|
|
||||||
fileMatch = "foo.json";
|
|
||||||
name = "foo.json";
|
|
||||||
url = "https://example.com/schema/foo.json";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
description = "My other custom JSON schema";
|
|
||||||
fileMatch = [
|
|
||||||
"bar.json"
|
|
||||||
".baar.json"
|
|
||||||
];
|
|
||||||
name = "bar.json";
|
|
||||||
url = "https://example.com/schema/bar.json";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
yaml = {
|
|
||||||
enable = true;
|
|
||||||
settings = { };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
withJson = {
|
|
||||||
plugins = {
|
plugins = {
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -83,7 +122,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
withYaml = {
|
withYamlOld = {
|
||||||
plugins = {
|
plugins = {
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -101,4 +140,5 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue