redhat-developer / yaml-language-server

Language Server for YAML Files
MIT License
1.05k stars 257 forks source link

Issue with YAML Language Server integration in Neovim and VSCode #887

Open szechp opened 1 year ago

szechp commented 1 year ago

Hello,

I've been facing an issue when trying to use the YAML Language Server (yamlls) with Neovim's built-in LSP client on MacOS 13. While the language server appears to attach correctly to the buffer and my configuration seems to be set up correctly, I'm not getting any syntax highlighting, autocomplete, or suggestions. Additionally, the YAML Language Server is not working in Visual Studio Code either, even when using the official YAML extension.

Here are the relevant details:

Despite these steps, I'm still not seeing syntax highlighting, autocomplete, or suggestions in YAML files in both Neovim and VSCode. Any guidance on how to debug or fix this issue would be greatly appreciated.

Thank you

rene-descartes2021 commented 1 year ago

I'm just a Vim user. With Vim I use vim-lsp and vim-lsp-settings, which provide ways to configure the yaml-language-server settings. I don't know how you'd do those settings using Mason.

resoliwan commented 3 months ago

I had the same issue, but after setting the file pattern to enable the schema, it worked. For Kubernetes, you can do it like this: "*.yaml"

require("lspconfig").yamlls.setup {
  on_attach = on_attach,
  capabilities = capabilities,
  settings = {
    yaml = {
      schemas = {
        kubernetes = "*.yaml",
      },
    },
  },
}
cwrau commented 3 months ago

I'm facing the same issue, in my case with the overridden schema via

  client.config.settings = vim.tbl_deep_extend("force", client.config.settings, {
    yaml = {
      schemas = {
        [schema] = uri,
      },
    },
  })
  client.notify("workspace/didChangeConfiguration")

see https://github.com/cwrau/yaml-schema-detect.nvim

cwrau commented 3 months ago

I'm facing the same issue, in my case with the overridden schema via

  client.config.settings = vim.tbl_deep_extend("force", client.config.settings, {
    yaml = {
      schemas = {
        [schema] = uri,
      },
    },
  })
  client.notify("workspace/didChangeConfiguration")

see cwrau/yaml-schema-detect.nvim

The only thing that is working, are the # yaml-language-server: $schema= overrides, but the config.settings.yaml.schemas.$schema=$file aren't working

cwrau commented 3 months ago

Lua code for reproduction;

  local client = require("lspconfig.util").get_active_client_by_name(vim.api.nvim_get_current_buf(), "yamlls")
  client.config.settings = vim.tbl_deep_extend("force", client.config.settings, {
    yaml = {
      schemas = {
        [https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/deployment-apps-v1.json] = vim.uri_from_bufnr(vim.api.nvim_get_current_buf()),
      },
    },
  })
  client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })

In other words,

{
  redhat = {
    telemetry = {
      enabled = false
    }
  },
  yaml = {
    schemas = {
      ["file:///tmp/lua_5MZoE1"] = "file:///home/cwr/work/clusters/1111-test-cwr-ffm3-2207/cluster.yaml"
    }
  }
}

is not working