Minor comment changes in init.lua
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
local state = require("gitlab.state")
|
local state = require("gitlab.state")
|
||||||
local discussions = require("gitlab.discussions")
|
local discussions = require("gitlab.discussions")
|
||||||
local summary = require("gitlab.summary")
|
local summary = require("gitlab.summary")
|
||||||
local keymaps = require("gitlab.keymaps")
|
local keymaps = require("gitlab.keymaps")
|
||||||
local comment = require("gitlab.comment")
|
local comment = require("gitlab.comment")
|
||||||
local job = require("gitlab.job")
|
local job = require("gitlab.job")
|
||||||
local u = require("gitlab.utils")
|
local u = require("gitlab.utils")
|
||||||
|
|
||||||
-- Ensures the plugin's state is initialized prior to running other calls. This state contains the basic information about the current merge request, like description, author, etc
|
-- Ensures the plugin's state is initialized prior to running other calls. This state contains the basic information about the current merge request, like description, author, etc
|
||||||
local ensureState = function(callback)
|
local ensureState = function(callback)
|
||||||
return function()
|
return function()
|
||||||
if type(state.INFO) ~= "table" then
|
if type(state.INFO) ~= "table" then
|
||||||
job.run_job("info", "GET", nil, function(data)
|
job.run_job("info", "GET", nil, function(data)
|
||||||
@@ -21,20 +21,19 @@ local ensureState = function(callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Root Module Scope
|
-- Root Module Scope
|
||||||
local M = {}
|
local M = {}
|
||||||
M.summary = ensureState(summary.summary)
|
M.summary = ensureState(summary.summary)
|
||||||
M.approve = ensureState(job.approve)
|
M.approve = ensureState(job.approve)
|
||||||
M.revoke = ensureState(job.revoke)
|
M.revoke = ensureState(job.revoke)
|
||||||
M.create_comment = ensureState(comment.create_comment)
|
M.create_comment = ensureState(comment.create_comment)
|
||||||
M.list_discussions = ensureState(discussions.list_discussions)
|
M.list_discussions = ensureState(discussions.list_discussions)
|
||||||
M.edit_comment = ensureState(comment.edit_comment)
|
M.edit_comment = ensureState(comment.edit_comment)
|
||||||
M.delete_comment = ensureState(comment.delete_comment)
|
M.delete_comment = ensureState(comment.delete_comment)
|
||||||
M.reply = ensureState(discussions.reply)
|
M.reply = ensureState(discussions.reply)
|
||||||
M.state = state
|
M.state = state
|
||||||
|
|
||||||
-- Builds the binary (if not built); starts the Go server; calls the /info endpoint,
|
-- Builds the binary (if not built); starts the Go server; sets the keymaps
|
||||||
-- which sets the Gitlab project's information in gitlab.nvim's INFO module
|
M.setup = function(args)
|
||||||
M.setup = function(args)
|
|
||||||
if args == nil then args = {} end
|
if args == nil then args = {} end
|
||||||
local file_path = u.current_file_path()
|
local file_path = u.current_file_path()
|
||||||
local parent_dir = vim.fn.fnamemodify(file_path, ":h:h:h:h")
|
local parent_dir = vim.fn.fnamemodify(file_path, ":h:h:h:h")
|
||||||
@@ -44,7 +43,7 @@ M.setup = function(args)
|
|||||||
local binary_exists = vim.loop.fs_stat(state.BIN)
|
local binary_exists = vim.loop.fs_stat(state.BIN)
|
||||||
if binary_exists == nil then M.build() end
|
if binary_exists == nil then M.build() end
|
||||||
|
|
||||||
if not M.setPluginState(args) then return end -- Return if not a valid gitlab project
|
if not M.setPluginConfiguration(args) then return end -- Return if not a valid gitlab project
|
||||||
|
|
||||||
local command = state.BIN
|
local command = state.BIN
|
||||||
.. " "
|
.. " "
|
||||||
@@ -75,7 +74,7 @@ M.setup = function(args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Builds the Go binary
|
-- Builds the Go binary
|
||||||
M.build = function()
|
M.build = function()
|
||||||
local command = string.format("cd %s && make", state.BIN_PATH)
|
local command = string.format("cd %s && make", state.BIN_PATH)
|
||||||
local installCode = os.execute(command .. "> /dev/null")
|
local installCode = os.execute(command .. "> /dev/null")
|
||||||
if installCode ~= 0 then
|
if installCode ~= 0 then
|
||||||
@@ -87,7 +86,7 @@ end
|
|||||||
|
|
||||||
-- Initializes state for the project based on the arguments
|
-- Initializes state for the project based on the arguments
|
||||||
-- provided in the `.gitlab.nvim` file per project, and the args provided in the setup function
|
-- provided in the `.gitlab.nvim` file per project, and the args provided in the setup function
|
||||||
M.setPluginState = function(args)
|
M.setPluginConfiguration = function(args)
|
||||||
local config_file_path = vim.fn.getcwd() .. "/.gitlab.nvim"
|
local config_file_path = vim.fn.getcwd() .. "/.gitlab.nvim"
|
||||||
local config_file_content = u.read_file(config_file_path)
|
local config_file_content = u.read_file(config_file_path)
|
||||||
if config_file_content == nil then
|
if config_file_content == nil then
|
||||||
|
|||||||
Reference in New Issue
Block a user