Repository: neovim/neovim
File: src/gen/gen_lsp.lua (Lua)

Code before:
    )

    output[#output + 1] = '}'
    output[#output + 1] = '-- stylua: ignore end'

    vim.list_extend(output, {
      '',
      '-- stylua: ignore start',
      '-- Generated by gen_lsp.lua, keep at end of file.',
      'protocol._method_supports_dynamic_registration = {',
    })

    --- These methods have no registrationOptions but can still be registered
    local methods_with_no_registration_options = {
      ['workspace/didChangeWorkspaceFolders'] = true,
    }

    for _, item in ipairs(all) do
      if
        item.registrationMethod
        or item.registrationOptions
        or methods_with_no_registration_options[item.method]
      then
        output[#output + 1] = ("  ['%s'] = %s,"):format(item.method, true)
      end
    end

    output[#output + 1] = '}'
    output[#output + 1] = '-- stylua: ignore end'

    vim.list_extend(output, {
      '',
      '-- stylua: ignore start',
      '-- Generated by gen_lsp.lua, keep at end of file.',
      'protocol._method_supports_static_registration = {',
    })

    for _, item in ipairs(all) do
      if
        item.registrationOptions
        and (item.serverCapability and not item.serverCapability:find('%.'))
      then
        output[#output + 1] = ("  ['%s'] = %s,"):format(item.method, true)
      end
    end

    output[#output + 1] = '}'
    output[#output + 1] = '-- stylua: ignore end'

    vim.list_extend(output, {
      '',

Review comment (suggestion):
```suggestion
    --- These methods have no registrationOptions but can still be registered
    --- TODO: remove if resolved upstream: https://github.com/microsoft/language-server-protocol/issues/2218
```

Code after:
      output[#output + 1] = ("  ['%s'] = { '%s' },"):format(
        registrationMethod,
        vim.iter(capabilities):fold(capabilities[1], function(acc, v)
          return #v < #acc and v or acc
        end)
      )
    end

    --- workspace/didChangeWatchedFiles has no server capability but we need to map it for
    --- registration
    output[#output + 1] = ("  ['%s'] = { '%s' },"):format(
      'workspace/didChangeWatchedFiles',
      'workspace/didChangeWatchedFiles'
    )

    output[#output + 1] = '}'
    output[#output + 1] = '-- stylua: ignore end'

    vim.list_extend(output, {
      '',
      '-- stylua: ignore start',
      '-- Generated by gen_lsp.lua, keep at end of file.',
      'protocol._method_supports_dynamic_registration = {',
    })

    --- These methods have no registrationOptions but can still be registered
    --- TODO: remove if resolved upstream: https://github.com/microsoft/language-server-protocol/issues/2218
    local methods_with_no_registration_options = {
      ['workspace/didChangeWorkspaceFolders'] = true,
    }

    for _, item in ipairs(all) do
      if
        item.registrationMethod
        or item.registrationOptions
        or methods_with_no_registration_options[item.method]
      then
        output[#output + 1] = ("  ['%s'] = %s,"):format(item.method, true)
      end
    end

    output[#output + 1] = '}'
    output[#output + 1] = '-- stylua: ignore end'

    vim.list_extend(output, {
      '',
      '-- stylua: ignore start',
      '-- Generated by gen_lsp.lua, keep at end of file.',
      'protocol._method_supports_static_registration = {',
    })