Removed notify as a dependency (#11)
Fixes: https://www.reddit.com/r/neovim/comments/14irqwt/comment/jphw2cx/?utm_source=share&utm_medium=web2x&context=3
This commit is contained in:
committed by
GitHub
parent
4069b95b3d
commit
23a21b867b
@@ -14,7 +14,6 @@ https://user-images.githubusercontent.com/32515581/233739969-216dad6e-fa77-417f-
|
|||||||
|
|
||||||
- Go
|
- Go
|
||||||
- <a href="https://github.com/MunifTanjim/nui.nvim">nui.nvim</a>
|
- <a href="https://github.com/MunifTanjim/nui.nvim">nui.nvim</a>
|
||||||
- <a href="https://github.com/rcarriga/nvim-notify">nvim-notify</a>
|
|
||||||
- <a href="https://github.com/nvim-lua/plenary.nvim">plenary.nvim</a>
|
- <a href="https://github.com/nvim-lua/plenary.nvim">plenary.nvim</a>
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -31,14 +30,11 @@ Then install the plugin. Here's what it looks like with <a href="https://github.
|
|||||||
return {
|
return {
|
||||||
"harrisoncramer/gitlab.nvim",
|
"harrisoncramer/gitlab.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"rcarriga/nvim-notify",
|
|
||||||
"MunifTanjim/nui.nvim",
|
"MunifTanjim/nui.nvim",
|
||||||
"nvim-lua/plenary.nvim"
|
"nvim-lua/plenary.nvim"
|
||||||
},
|
},
|
||||||
build = function () require("gitlab").build() end, -- Builds the Go binary
|
build = function () require("gitlab").build() end, -- Builds the Go binary
|
||||||
config = function()
|
config = function()
|
||||||
vim.opt.termguicolors = true -- This is required if you aren't already initializing notify
|
|
||||||
require("notify").setup({ background_colour = "#000000" }) -- This is required if you aren't already initializing notify
|
|
||||||
require("gitlab").setup()
|
require("gitlab").setup()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
@@ -50,15 +46,12 @@ And with Packer:
|
|||||||
use {
|
use {
|
||||||
'harrisoncramer/gitlab.nvim',
|
'harrisoncramer/gitlab.nvim',
|
||||||
requires = {
|
requires = {
|
||||||
"rcarriga/nvim-notify",
|
|
||||||
"MunifTanjim/nui.nvim",
|
"MunifTanjim/nui.nvim",
|
||||||
"nvim-lua/plenary.nvim"
|
"nvim-lua/plenary.nvim"
|
||||||
},
|
},
|
||||||
run = function() require("gitlab").build() end,
|
run = function() require("gitlab").build() end,
|
||||||
config = function()
|
config = function()
|
||||||
vim.opt.termguicolors = true
|
require("gitlab").setup()
|
||||||
require("notify").setup({ background_colour = "#000000" })
|
|
||||||
require("gitlab").setup() -- This can be found under the project details section of your Gitlab repository.
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
local Menu = require("nui.menu")
|
local Menu = require("nui.menu")
|
||||||
local NuiTree = require("nui.tree")
|
local NuiTree = require("nui.tree")
|
||||||
local notify = require("notify")
|
|
||||||
local job = require("gitlab.job")
|
local job = require("gitlab.job")
|
||||||
local state = require("gitlab.state")
|
local state = require("gitlab.state")
|
||||||
local u = require("gitlab.utils")
|
local u = require("gitlab.utils")
|
||||||
@@ -25,7 +24,7 @@ M.find_deletion_commit = function(file)
|
|||||||
local handle = io.popen(command)
|
local handle = io.popen(command)
|
||||||
local output = handle:read("*line")
|
local output = handle:read("*line")
|
||||||
if output == nil then
|
if output == nil then
|
||||||
notify("Error reading SHA of deletion commit", "error")
|
vim.notify("Error reading SHA of deletion commit", vim.log.levels.ERROR)
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
handle:close()
|
handle:close()
|
||||||
@@ -111,7 +110,7 @@ M.delete_comment = function()
|
|||||||
|
|
||||||
local json = string.format('{"discussion_id": "%s", "note_id": %d}', discussion_id, note_id)
|
local json = string.format('{"discussion_id": "%s", "note_id": %d}', discussion_id, note_id)
|
||||||
job.run_job("comment", "DELETE", json, function(data)
|
job.run_job("comment", "DELETE", json, function(data)
|
||||||
notify(data.message, "success")
|
vim.notify(data.message, vim.log.levels.INFO)
|
||||||
state.tree:remove_node("-" .. note_id)
|
state.tree:remove_node("-" .. note_id)
|
||||||
local discussion_node = state.tree:get_node("-" .. discussion_id)
|
local discussion_node = state.tree:get_node("-" .. discussion_id)
|
||||||
if not discussion_node:has_children() then
|
if not discussion_node:has_children() then
|
||||||
@@ -179,7 +178,7 @@ M.send_edits = function(text)
|
|||||||
state.tree:render()
|
state.tree:render()
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
u.darken_metadata(buf, '')
|
u.darken_metadata(buf, '')
|
||||||
notify("Edited comment!")
|
vim.notify("Edited comment!", vim.log.levels.INFO)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local u = require("gitlab.utils")
|
local u = require("gitlab.utils")
|
||||||
local NuiTree = require("nui.tree")
|
local NuiTree = require("nui.tree")
|
||||||
local job = require("gitlab.job")
|
local job = require("gitlab.job")
|
||||||
local notify = require("notify")
|
|
||||||
local state = require("gitlab.state")
|
local state = require("gitlab.state")
|
||||||
local Job = require("plenary.job")
|
local Job = require("plenary.job")
|
||||||
local Popup = require("nui.popup")
|
local Popup = require("nui.popup")
|
||||||
@@ -29,7 +28,7 @@ M.send_reply = function(text)
|
|||||||
state.tree:render()
|
state.tree:render()
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
u.darken_metadata(buf, '')
|
u.darken_metadata(buf, '')
|
||||||
notify("Sent reply!")
|
vim.notify("Sent reply!", vim.log.levels.INFO)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -45,7 +44,7 @@ M.list_discussions = function()
|
|||||||
if data_ok and data ~= nil then
|
if data_ok and data ~= nil then
|
||||||
local status = (data.status >= 200 and data.status < 300) and "success" or "error"
|
local status = (data.status >= 200 and data.status < 300) and "success" or "error"
|
||||||
if status == "error" then
|
if status == "error" then
|
||||||
notify("Could not fetch discussions!", "error")
|
vim.notify("Could not fetch discussions!", vim.log.levels.ERROR)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
M.discussions = data.discussions
|
M.discussions = data.discussions
|
||||||
@@ -88,7 +87,7 @@ M.list_discussions = function()
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_stderr = function(_, output)
|
on_stderr = function(_, output)
|
||||||
notify("Could not run approve command!", "error")
|
vim.notify("Could not run approve command!", vim.log.levels.ERROR)
|
||||||
error(output)
|
error(output)
|
||||||
end,
|
end,
|
||||||
}):start()
|
}):start()
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
local curl = require("plenary.curl")
|
local curl = require("plenary.curl")
|
||||||
local state = require("gitlab.state")
|
local state = require("gitlab.state")
|
||||||
local notify = require("notify")
|
|
||||||
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")
|
||||||
@@ -24,7 +23,7 @@ local function build_binary()
|
|||||||
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
|
||||||
notify("Could not install gitlab.nvim!", "error")
|
vim.notify("Could not install gitlab.nvim!", vim.log.levels.ERROR)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@@ -71,19 +70,19 @@ M.setup = function(args)
|
|||||||
vim.fn.jobstart(state.BIN .. " " .. state.PROJECT_ID .. " " .. state.PORT, {
|
vim.fn.jobstart(state.BIN .. " " .. state.PROJECT_ID .. " " .. state.PORT, {
|
||||||
on_stdout = function(job_id)
|
on_stdout = function(job_id)
|
||||||
if job_id <= 0 then
|
if job_id <= 0 then
|
||||||
notify("Could not start gitlab.nvim binary", "error")
|
vim.notify("Could not start gitlab.nvim binary", vim.log.levels.ERROR)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
local response_ok, response = pcall(curl.get, "localhost:" .. state.PORT .. "/info",
|
local response_ok, response = pcall(curl.get, "localhost:" .. state.PORT .. "/info",
|
||||||
{ timeout = 750 })
|
{ timeout = 750 })
|
||||||
if response == nil or not response_ok then
|
if response == nil or not response_ok then
|
||||||
notify("The gitlab.nvim server did not respond", "error")
|
vim.notify("The gitlab.nvim server did not respond", vim.log.levels.ERROR)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local body = response.body
|
local body = response.body
|
||||||
local parsed_ok, data = pcall(vim.json.decode, body)
|
local parsed_ok, data = pcall(vim.json.decode, body)
|
||||||
if parsed_ok ~= true then
|
if parsed_ok ~= true then
|
||||||
notify("The gitlab.nvim server returned an invalid response to the /info endpoint", "error")
|
vim.notify("The gitlab.nvim server returned an invalid response to the /info endpoint", vim.log.levels.ERROR)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
state.INFO = data
|
state.INFO = data
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
local notify = require("notify")
|
|
||||||
local Job = require("plenary.job")
|
local Job = require("plenary.job")
|
||||||
local state = require("gitlab.state")
|
local state = require("gitlab.state")
|
||||||
local M = {}
|
local M = {}
|
||||||
@@ -20,14 +19,14 @@ M.run_job = function(endpoint, method, body, callback)
|
|||||||
if callback ~= nil then
|
if callback ~= nil then
|
||||||
callback(data)
|
callback(data)
|
||||||
else
|
else
|
||||||
notify(data.message, status)
|
vim.notify(data.message, vim.log.levels.DEBUG)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
notify("Could not parse command output!", "error")
|
vim.notify("Could not parse command output!", vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_stderr = function(_, output)
|
on_stderr = function(_, output)
|
||||||
notify("Could not run command!", "error")
|
vim.notify("Could not run command!", vim.log.levels.ERROR)
|
||||||
error(output)
|
error(output)
|
||||||
end
|
end
|
||||||
}):start()
|
}):start()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
local state = require("gitlab.state")
|
local state = require("gitlab.state")
|
||||||
local notify = require("notify")
|
|
||||||
|
|
||||||
local function get_git_root()
|
local function get_git_root()
|
||||||
local output = vim.fn.system('git rev-parse --show-toplevel 2>/dev/null')
|
local output = vim.fn.system('git rev-parse --show-toplevel 2>/dev/null')
|
||||||
@@ -81,14 +80,14 @@ local base_invalid = function()
|
|||||||
local current_branch = string.gsub(current_branch_raw, "\n", "")
|
local current_branch = string.gsub(current_branch_raw, "\n", "")
|
||||||
|
|
||||||
if current_branch == "main" or current_branch == "master" then
|
if current_branch == "main" or current_branch == "master" then
|
||||||
notify('On ' .. current_branch .. ' branch, no MRs available', "error")
|
vim.notify('On ' .. current_branch .. ' branch, no MRs available', vim.log.levels.ERROR)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local base = state.BASE_BRANCH
|
local base = state.BASE_BRANCH
|
||||||
local hasBaseBranch = feature_branch_exists(base)
|
local hasBaseBranch = feature_branch_exists(base)
|
||||||
if not hasBaseBranch then
|
if not hasBaseBranch then
|
||||||
notify('No base branch. If this is a Gitlab repository, please check your setup function!', "error")
|
vim.notify('No base branch. If this is a Gitlab repository, please check your setup function!', vim.log.levels.ERROR)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -169,13 +168,13 @@ end
|
|||||||
|
|
||||||
local function print_success(_, line)
|
local function print_success(_, line)
|
||||||
if line ~= nil and line ~= "" then
|
if line ~= nil and line ~= "" then
|
||||||
notify(line, "info")
|
vim.notify(line, vim.log.levels.INFO)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function print_error(_, line)
|
local function print_error(_, line)
|
||||||
if line ~= nil and line ~= "" then
|
if line ~= nil and line ~= "" then
|
||||||
notify(line, "error")
|
vim.notify(line, vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user