-
-
Notifications
You must be signed in to change notification settings - Fork 335
plugins/yaml-companion: init #3375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
lib, | ||
config, | ||
... | ||
}: | ||
lib.nixvim.plugins.mkNeovimPlugin { | ||
name = "yaml-companion"; | ||
packPathName = "yaml-companion.nvim"; | ||
package = "yaml-companion-nvim"; | ||
|
||
maintainers = [ lib.maintainers.GaetanLepage ]; | ||
|
||
settingsExample = { | ||
schemas = [ | ||
{ | ||
name = "Argo CD Application"; | ||
uri = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json"; | ||
} | ||
{ | ||
name = "SealedSecret"; | ||
uri = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/bitnami.com/sealedsecret_v1alpha1.json"; | ||
} | ||
]; | ||
lspconfig = { | ||
settings = { | ||
yaml = { | ||
format.enable = false; | ||
schemaStore = { | ||
enable = false; | ||
url = ""; | ||
}; | ||
schemas = lib.nixvim.nestedLiteralLua "require('schemastore').yaml.schemas()"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
callSetup = false; | ||
extraConfig = cfg: { | ||
warnings = lib.nixvim.mkWarnings "plugins.yaml-companion" [ | ||
{ | ||
when = !config.plugins.lsp.enable; | ||
message = "This plugin requires the `plugins.lsp.servers.yamlls` module to be enabled."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning condition is checking Ideally, we should use |
||
} | ||
]; | ||
|
||
plugins = { | ||
lsp.servers.yamlls.extraOptions = lib.nixvim.mkRaw "require('yaml-companion').setup(${lib.nixvim.toLuaObject cfg.settings})"; | ||
Comment on lines
+47
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
telescope.enabledExtensions = [ "yaml_schema" ]; | ||
}; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ lib, pkgs, ... }: | ||
{ | ||
empty = { | ||
plugins = { | ||
lsp = { | ||
enable = true; | ||
servers.yamlls.enable = true; | ||
}; | ||
|
||
yaml-companion.enable = true; | ||
}; | ||
}; | ||
|
||
defaults = { | ||
plugins = { | ||
lsp = { | ||
enable = true; | ||
servers.yamlls.enable = true; | ||
}; | ||
|
||
yaml-companion = { | ||
enable = true; | ||
|
||
settings = { | ||
builtin_matchers = { | ||
kubernetes.enabled = true; | ||
cloud_init.enabled = true; | ||
}; | ||
schemas = [ ]; | ||
lspconfig = { | ||
flags = { | ||
debounce_text_changes = 150; | ||
}; | ||
settings = { | ||
redhat.telemetry.enabled = false; | ||
yaml = { | ||
validate = true; | ||
format.enable = true; | ||
hover = true; | ||
schemaStore = { | ||
enable = true; | ||
url = "https://www.schemastore.org/api/json/catalog.json"; | ||
}; | ||
schemaDownload.enable = true; | ||
schemas = [ ]; | ||
trace.server = "debug"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
example = { | ||
extraPlugins = [ pkgs.vimPlugins.SchemaStore-nvim ]; | ||
plugins = { | ||
lsp = { | ||
enable = true; | ||
servers.yamlls.enable = true; | ||
}; | ||
|
||
yaml-companion = { | ||
enable = true; | ||
|
||
settings = { | ||
schemas = [ | ||
{ | ||
name = "Argo CD Application"; | ||
uri = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json"; | ||
} | ||
{ | ||
name = "SealedSecret"; | ||
uri = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/bitnami.com/sealedsecret_v1alpha1.json"; | ||
} | ||
]; | ||
lspconfig = { | ||
settings = { | ||
yaml = { | ||
format.enable = false; | ||
schemaStore = { | ||
enable = false; | ||
url = ""; | ||
}; | ||
schemas = lib.nixvim.mkRaw "require('schemastore').yaml.schemas()"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should support either
lsp
orplugins.lsp
.See example:
nixvim/plugins/by-name/schemastore/default.nix
Line 132 in 2c0a9ff
Note that
lsp
doesn't have an enable option, so we'd want to check the relevant server is enabled.For
plugins.lsp
, we may want tomkDefault
the relevant server. This warning may want to check theplugins.lsp.servers
enable option too?