From ca7c702fd075b8fde5801019e9f77d4aa33d360b Mon Sep 17 00:00:00 2001 From: Harrison Cramer Date: Fri, 19 May 2023 17:36:37 -0700 Subject: [PATCH] Added port to job function --- lua/gitlab/init.lua | 6 +++--- lua/gitlab/job.lua | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/gitlab/init.lua b/lua/gitlab/init.lua index cee060b..f28382c 100644 --- a/lua/gitlab/init.lua +++ b/lua/gitlab/init.lua @@ -80,14 +80,14 @@ M.setup = function(args, build_only) local error_message = "Failed to set up gitlab.nvim, could not get project information." if u.is_gitlab_repo() then - local port = args.port or 21036 - vim.fn.jobstart(state.BIN .. " " .. state.PROJECT_ID .. " " .. port, { + state.PORT = args.port or 21036 + vim.fn.jobstart(state.BIN .. " " .. state.PROJECT_ID .. " " .. state.PORT, { on_stdout = function(job_id) if job_id <= 0 then notify(error_message, "error") return else - local response_ok, response = pcall(curl.get, "localhost:" .. port .. "/info", + local response_ok, response = pcall(curl.get, "localhost:" .. state.PORT .. "/info", { timeout = 750 }) if response == nil or not response_ok then notify(error_message, "error") diff --git a/lua/gitlab/job.lua b/lua/gitlab/job.lua index 257358e..59623a6 100644 --- a/lua/gitlab/job.lua +++ b/lua/gitlab/job.lua @@ -1,9 +1,10 @@ local notify = require("notify") local Job = require("plenary.job") +local state = require("gitlab.state") local M = {} M.run_job = function(endpoint, method, body, callback) - local args = { "-s", "-X", (method or "POST"), "localhost:8081/" .. endpoint } + local args = { "-s", "-X", (method or "POST"), string.format("localhost:%s/", state.PORT) .. endpoint } if body ~= nil then table.insert(args, 1, "-d")