microsoft / azure-pipelines-language-server

A language server for Azure Pipelines YAML
37 stars 25 forks source link

Change on settings for the LS are not clear on the documentation. #160

Open Msouza91 opened 5 months ago

Msouza91 commented 5 months ago

Up to 0.7.0 I was able to use the language server with a good setup on Neovim with mason_lsp_config and attach the server to my files. After the recent updates I'm getting some error messages when I try to use it, yet I didn't see any warning about breaking changes.

Neovim Version: 0.9.5 I had the same errors running on ubuntu 23.04 natively and 22.04 on WSL

I installed the LSP from Mason and was running it with this config:

--- Setup Mason LSP Install
require("mason").setup({})
require("mason-lspconfig").setup({
    ensure_installed = {
        "azure_pipelines_ls",
         }
    handlers = {
        lsp.default_setup,
        azure_pipelines_ls = function()
            require("lspconfig").azure_pipelines_ls.setup(my_handlers.azure())
        end,
    },

Here is the handlers config returning the LS options table:

local M = {}
function M.azure()
    local opts = {
        settings = {
            yaml = {
                schemas = {
                    ["https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json"] = {
                        "/azure-pipeline*.y*l",
                        "/*.azure*",
                        "Azure-Pipelines/**/*.y*l",
                        "Pipelines/*.y*l",
                        "cap/**/*.y*l",
                        "cap/*.y*l",
                        "veiling/**/*.y*l",
                        "veiling/*.y*l",
                    },
                },
            },
        },
    }
    return opts
end
return M

From 0.8.0 onwards I get an assertion error when the nvim lsp client tries to start the language server.

50Wliu commented 5 months ago

What is the assertion error you're getting? We didn't knowingly introduce any breaking changes in 0.8.0.

Msouza91 commented 5 months ago

The error message is not very descriptive I think, but it happens when the Nvim client tries to attach using these configs on 0.8.0, but works fine on 0.7.0 It only happens when I open a file in which I configured the azure_ls to attach onto and after the update. If my minimal setup above is not enough to reproduce the error I'll need to take some time on the weekend to narrow it down a little bit. I edited the original issue to include my neovim version and platforms in which I encountered the error for some extra info.

In the meantime, if there are any loggin or other debug info that I could extract, kindly inform me where to gather it from.

Error  08:54:24 msg_show.lua_error Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp.lua:1308: RPC[Error] code_name = InternalError, message = "Request initialize failed with message: [UriError]: Scheme is missing: {scheme: \"\", authority: \"\", path: \"null\", query: \"\", fragment: \"\"}"
stack traceback:
    [C]: in function 'assert'
    /usr/share/nvim/runtime/lua/vim/lsp.lua:1308: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
Keltirion commented 5 months ago

I get the same issue, I've noticed when you use the file which is called azure-pipelines.yml it works, but any other which should be detected by schema patern does not work eg. azure-pipelines.yaml does not work.

Msouza91 commented 4 months ago

Maybe the binary is not expecting the same object that is passed from the table on these new versions, I'm not sure I'm capable of going through the code since I'm not a JSDev, but I can try to follow the logic and hopefully find where the issue is happening.

Ziwi01 commented 3 months ago

I have the same issue. Previously I was attaching the LSP using the autocommand based on a pattern when buffer is being opened, now I rely on the schema pattern defined here. Both ways I get the error, when couple weeks ago it was working fine.

EDIT: It is working fine on 0.7.0. I browsed through the code and I don't see any obvious suspects - so it's probably either an internal function call used in one of new PRs or the dependency updates causing this issue.

cksidharthan commented 3 months ago

I have the same issue too. I tried to configure the yamlls plugin with azure pipeline schema as a temp fix, but even that is giving warnings on the pipeline files :(

Screenshot 2024-05-15 at 15 26 50
brianrobt commented 2 months ago

I was having the same issue and fixed it by changing the value of the root_dir attribute. If you don't have root_dir set you will also get the same error.

Broken version

lspconfig["azure_pipelines_ls"].setup({
  capabilities = capabilities,
  root_dir = lspconfig.util.root_pattern("azure-pipelines.yml"),
  single_file_support = true,
  settings = {},
})

Fixed version

lspconfig["azure_pipelines_ls"].setup({
  capabilities = capabilities,
  root_dir = lspconfig.util.root_pattern("azure-pipelines.y*l"),
  single_file_support = true,
  settings = {},
})
yavorski commented 2 months ago

It is working for the specified patterns, but it is throwing error for every other yml file.

Settings:

local lsp = require("lspconfig")
local patterns = { "azure*.yml", ".azure/*.yml", "pipelines/*.yml", "azure-pipelines/*.yml" }
local service_schema = "https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json"

lsp.azure_pipelines_ls.setup({
  capabilities = LSP.capabilities(),
  root_dir = lsp.util.root_pattern(patterns),
  single_file_support = true,
  settings = {
    yaml = {
      schemas = {
        [service_schema] = patterns
      }
    }
  }
})

Example: open ~/my-project/.github/workflows/main.yml throws error:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/client.lua:589: RPC[Error] code_name = InternalError, message = "Request initialize failed with message: [UriError]: Scheme is missing: {scheme: \"\", authority: \"\", path: \"null\", query: \"\", fragment: \"\"}"
stack traceback:
  [C]: in function 'assert'
  /usr/share/nvim/runtime/lua/vim/lsp/client.lua:589: in function ''
  vim/_editor.lua: in function <vim/_editor.lua:0>
brianrobt commented 1 month ago

Should ~/my-project/.github/workflows/main.yml be managed by another YAML language server other than azure_pipelines_ls since it's not specific to Azure DevOps? That path is also missing from patterns.

yavorski commented 1 month ago

Indeed it should, but this server is also firing and throwing error, because of the yaml filetype, I think.

image

ja-albert commented 3 weeks ago

I have the same problem as @yavorski : Opening a yaml file without configured scheme, I get the same error message as in https://github.com/microsoft/azure-pipelines-language-server/issues/160#issuecomment-2198056931. My :LspInfo also matches the one in https://github.com/microsoft/azure-pipelines-language-server/issues/160#issuecomment-2199398075.

Within a Azure pipeline yaml file, everything works as intended.

I have version 0.8.0 installed with npm and use it in Neovim.