First of all im still learning lua and just started with my current project (a bitbucket reviewer).
And im facing an issue which i cannt solve for some hours now.
So what do i try to archieve?
I want a NuiTree which contains all the comments of a pr with their corresponding subcomments.
So i thought alright just set the node id to the comment id and if in the decoded json the key "parent" exists then lets use the value of the subkey "id" in add_node as second value but there i get invalid parent_id when im trying to use
But still im getting this issue. I tried for both "methods" to cast to a string with tostring(value) but this still didnt solve the issue.
So im pretty much clueless how to solve this. But im pretty sure im facing a totally lua beginner issue.
So the full function which is causin the issue is down below following
function M.get_comments(id)
id = id or pull_request_id
local request_url = base_request_url .. "/pullrequests/" .. id .. "/comments"
local response = curl.get(request_url, {
accept = "application/json",
auth = username .. ":" .. app_password
})
local values = vim.fn.json_decode(response.body)["values"]
local buffer_number = utils.create_vertial_slit()
local tree = NuiTree({bufnr = buffer_number})
local node_ids = {}
for index ,value in pairs(values) do
local comment_text = value["content"]["html"]
local author = value["user"]["display_name"]
comment_text = author
local comment_id = value["id"]
local node_uuid = utils.uuid()
local node = NuiTree.Node({text=comment_text,id=node_uuid, comment_id= comment_id})
node_ids[comment_id] = node_uuid
if value["parent"] then
tree:add_node(node, node_ids[value["parent"]["id"]])
else
tree:add_node(node)
end
end
tree:render()
end
Hello there,
First of all im still learning lua and just started with my current project (a bitbucket reviewer). And im facing an issue which i cannt solve for some hours now. So what do i try to archieve? I want a NuiTree which contains all the comments of a pr with their corresponding subcomments. So i thought alright just set the node id to the comment id and if in the decoded json the key "parent" exists then lets use the value of the subkey "id" in add_node as second value but there i get invalid parent_id when im trying to use
So i thought this might be because its not a uuid so i just google and fully copied from here https://gist.github.com/jrus/3197011
But still im getting this issue. I tried for both "methods" to cast to a string with tostring(value) but this still didnt solve the issue. So im pretty much clueless how to solve this. But im pretty sure im facing a totally lua beginner issue.
So the full function which is causin the issue is down below following