Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
533 changes: 523 additions & 10 deletions lua/glance/git.lua

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion lua/glance/merge/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local git = require('glance.git')
local layout = require('glance.merge.layout')
local model = require('glance.merge.model')
local render = require('glance.merge.render')
local special = require('glance.merge.special')
local workspace = require('glance.workspace')

local M = {}
Expand Down Expand Up @@ -570,7 +571,7 @@ local function bind_result_tracking(diffview, file)
end

function M.is_active()
return state.active == true
return state.active == true or special.is_active()
end

function M.jump_to_conflict(diffview, index)
Expand Down Expand Up @@ -643,6 +644,9 @@ function M.jump_prev(diffview)
end

function M.equalize_panes(diffview)
if special.is_active() then
return special.equalize_panes(diffview)
end
if not state.active then
return false
end
Expand All @@ -652,6 +656,9 @@ function M.equalize_panes(diffview)
end

function M.hoverable_separator_wins(diffview)
if special.is_active() then
return special.hoverable_separator_wins(diffview)
end
if not state.active then
return nil
end
Expand Down Expand Up @@ -680,6 +687,15 @@ local function rebuild(diffview, file, existing_model)
end

function M.open(diffview, file)
local info = git.get_conflict_info(file)
if special.open(diffview, file, info) then
state.active = false
state.file = nil
state.model = nil
state.active_conflict_index = nil
return
end

local merge_model, err = model.build(file)
if not merge_model then
state.active = false
Expand Down Expand Up @@ -727,6 +743,10 @@ function M.open(diffview, file)
end

function M.refresh(diffview, file)
if special.is_active() then
return special.refresh(diffview, file)
end

if not state.active then
return false
end
Expand Down Expand Up @@ -761,6 +781,10 @@ function M.refresh(diffview, file)
end

function M.complete(diffview)
if special.is_active() then
return special.complete(diffview)
end

if not state.active or not state.file then
return false
end
Expand Down Expand Up @@ -823,6 +847,7 @@ function M.reset()
state.active_conflict_index = nil
state.write_in_progress = false
state.sync_in_progress = false
special.reset()
end

return M
35 changes: 35 additions & 0 deletions lua/glance/merge/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ M.FILETREE_ROLE = 'filetree'
M.THEIRS_ROLE = 'merge_theirs'
M.OURS_ROLE = 'merge_ours'
M.RESULT_ROLE = 'merge_result'
M.SPECIAL_ROLE = 'merge_special'

function M.workspace_spec()
return {
Expand Down Expand Up @@ -51,6 +52,40 @@ function M.open(diffview)
}
end

function M.special_workspace_spec()
return {
roles = {
{ role = M.FILETREE_ROLE, kind = 'sidebar' },
{ role = M.SPECIAL_ROLE, kind = 'content' },
},
preferred_focus_role = M.SPECIAL_ROLE,
editable_role = M.SPECIAL_ROLE,
}
end

function M.open_special(diffview)
diffview.configure_workspace(M.special_workspace_spec())
local win, buf = diffview.open_workspace_pane(M.SPECIAL_ROLE)
return {
special = { win = win, buf = buf },
}
end

function M.equalize_special(diffview)
local tree_visible = filetree.win and vim.api.nvim_win_is_valid(filetree.win)
if tree_visible then
vim.api.nvim_win_set_width(filetree.win, require('glance.config').options.windows.filetree.width)
end
end

function M.special_hoverable_separator_wins()
local wins = {}
if filetree.win and vim.api.nvim_win_is_valid(filetree.win) then
wins[#wins + 1] = filetree.win
end
return wins
end

function M.equalize(diffview)
local tree_visible = filetree.win and vim.api.nvim_win_is_valid(filetree.win)
local tree_width = 0
Expand Down
Loading
Loading