Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GaetanLepage
Copy link
Member

Add support for yaml-companion.nvim, a plugin to get, set and autodetect YAML schemas in buffers.

Closes #3328

@GaetanLepage GaetanLepage requested a review from MattSturgeon May 24, 2025 12:32
Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plugin is very similar to https://github.com/nix-community/nixvim/blob/main/plugins/by-name/schemastore/default.nix, you may want to check how we handled things there

extraConfig = cfg: {
warnings = lib.nixvim.mkWarnings "plugins.yaml-companion" [
{
when = !config.plugins.lsp.enable;
Copy link
Member

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 or plugins.lsp.

See example:

cfg.json.enable && !(config.plugins.lsp.servers.jsonls.enable || config.lsp.servers.jsonls.enable);

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 to mkDefault the relevant server. This warning may want to check the plugins.lsp.servers enable option too?

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.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning condition is checking plugins.lsp.enable, while the warning message is referencing plugins.lsp.servers.yamlls.

Ideally, we should use "${opt.foo.bar}", as interpolating an actual option will lead to the correctly prefixed option path being used, and it verifies that the option we're referencing actually exists. This is only possible when the option is in in the same level of module eval; i.e. we can't easily reference submodule suboptions.

Comment on lines +47 to +48
plugins = {
lsp.servers.yamlls.extraOptions = lib.nixvim.mkRaw "require('yaml-companion').setup(${lib.nixvim.toLuaObject cfg.settings})";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should this be extraOptions or settings?
  2. We should consider plugins.lsp.servers.yamlls.enable = mkDefault true here
  3. We should also set the (new) lsp.servers.yamlls.settings option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PLUGIN REQUEST] yaml-companion.nvim
2 participants