b0o / SchemaStore.nvim

🛍 JSON schemas for Neovim
https://schemastore.org
Apache License 2.0
697 stars 17 forks source link

support yaml #9

Closed ZenLian closed 1 year ago

ZenLian commented 2 years ago

I'm using .clang-format file, schemas provided by yamlls, and I have to add schemas manually.

Is it possible to support yaml?

Thans a lot!

b0o commented 2 years ago

Have you seen #3?

ZenLian commented 2 years ago

🤦‍♂️Sorry didn't search before issue!

It seems yaml.schemaStore.enable just provide the ability for client to ask for a schema list from yamlls. Then client can select one from the list, and set yaml.schemas accordingly. The implementation at client side do need quite a few code, maybe another plugin.

For me, I just want some schemas. I've tried the example code you mentioned in #3, but it didn't work for me. The format of yaml.schemas is different from json.schemas. I did some tweak and it works:

local json_schemas = require('schemastore').json.schemas {}
local yaml_schemas = {}
vim.tbl_map(function(schema)
  yaml_schemas[schema.url] = schema.fileMatch
end, json_schemas)

require('lspconfig').yamlls.setup {
  settings = {
    yaml = {
      schemas = yaml_schemas,
    },
  },
}

It will be convenient if this plugin could provide a builtin support, something like require('schemastore').yaml.schemas.

❤️Thanks.