Bugfix: Don't Start Server Right Away (#40)

This MR simplifies the plugin quite a bit by only attempting to start the Go server after you specifically try to run a command. This streamlines working on feature branches and removes the need for a `base_branch` property entirely.
This commit is contained in:
Harrison (Harry) Cramer
2023-08-17 16:22:53 -04:00
committed by GitHub
parent f4aafe46a9
commit f5bf720b61
9 changed files with 91 additions and 156 deletions

View File

@@ -19,30 +19,4 @@ M.set_keymap_keys = function(keyTable)
state.keymaps = u.merge_tables(state.keymaps, keyTable)
end
M.set_keymaps = function()
local ok, _ = pcall(require, "diffview")
vim.keymap.set("n", state.keymaps.review.toggle, function()
if not ok then
require("notify")("You must have diffview.nvim installed to use this command!", "error")
return
end
local isDiff = vim.fn.getwinvar(nil, "&diff")
local bufName = vim.api.nvim_buf_get_name(0)
local has_develop = u.branch_exists("main") -- TODO: Write this function
if not has_develop then
require("notify")('No ' .. state.BASE_BRANCH .. ' branch, cannot review.', "error")
return
end
if isDiff ~= 0 or u.string_starts(bufName, "diff") then
vim.cmd.tabclose()
vim.cmd.tabprev()
else
vim.cmd.DiffviewOpen(state.BASE_BRANCH)
u.press_enter()
end
end)
end
return M