Skip to content

Commit

Permalink
chore: fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tanvirtin committed Jun 14, 2024
1 parent bcd836c commit 2924520
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 66 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ require('vgit').setup({
['n <leader>gu'] = function() require('vgit').buffer_reset() end,
['n <leader>gg'] = function() require('vgit').buffer_gutter_blame_preview() end,
['n <leader>gd'] = function() require('vgit').project_diff_preview() end,
['n <leader>gq'] = function() require('vgit').project_hunks_qf() end,
['n <leader>gx'] = function() require('vgit').toggle_diff_preference() end,
},
settings = {
Expand Down
1 change: 0 additions & 1 deletion doc/vgit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ More advanced configuration:
['n <leader>gu'] = function() require('vgit').buffer_reset() end,
['n <leader>gg'] = function() require('vgit').buffer_gutter_blame_preview() end,
['n <leader>gd'] = function() require('vgit').project_diff_preview() end,
['n <leader>gq'] = function() require('vgit').project_hunks_qf() end,
['n <leader>gx'] = function() require('vgit').toggle_diff_preference() end,
},
settings = {
Expand Down
1 change: 0 additions & 1 deletion lua/vgit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ return {
buffer_conflict_accept_current_change = buffer.conflict_accept_current_change,
buffer_conflict_accept_incoming_change = buffer.conflict_accept_incoming_change,
buffer_conflict_accept_both_changes = buffer.conflict_accept_both_changes,
project_hunks_qf = project.hunks_qf,
project_diff_preview = project.diff_preview,
project_logs_preview = project.logs_preview,
project_stash_preview = project.stash_preview,
Expand Down
2 changes: 1 addition & 1 deletion lua/vgit/core/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function fs.read_file(filepath)

if not line == '' then split_data[#split_data + 1] = line end

return split_data
return split_data
end

function fs.write_file(filepath, lines)
Expand Down
2 changes: 1 addition & 1 deletion lua/vgit/core/utils/math.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local M = {}

function M.round(x)
return x >= 0 and math.floor(x + 0.5) or math.floor(x - 0.5)
return x >= 0 and math.floor(x + 0.5) or math.ceil(x - 0.5)
end

function M.uuid()
Expand Down
16 changes: 12 additions & 4 deletions lua/vgit/features/buffer/LiveConflict.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function LiveConflict:conflict_accept_current_change(buffer)

lines = utils.list.replace(lines, conflict_top, conflict_bot, current_lines)
buffer:set_lines(lines)
buffer:call(function() vim.cmd('LspStart') end)
buffer:call(function()
vim.cmd('LspStart')
end)
end

function LiveConflict:conflict_accept_incoming_change(buffer)
Expand All @@ -39,7 +41,9 @@ function LiveConflict:conflict_accept_incoming_change(buffer)

lines = utils.list.replace(lines, conflict_top, conflict_bot, incoming_lines)
buffer:set_lines(lines)
buffer:call(function() vim.cmd('LspStart') end)
buffer:call(function()
vim.cmd('LspStart')
end)
end

function LiveConflict:conflict_accept_both_changes(buffer)
Expand All @@ -57,15 +61,19 @@ function LiveConflict:conflict_accept_both_changes(buffer)

lines = utils.list.replace(lines, conflict_top, conflict_bot, replacement_lines)
buffer:set_lines(lines)
buffer:call(function() vim.cmd('LspStart') end)
buffer:call(function()
vim.cmd('LspStart')
end)
end

function LiveConflict:render(buffer)
local has_conflict = buffer:has_conflict()
if not has_conflict then return end

loop.free_textlock()
buffer:call(function() vim.cmd('LspStop') end)
buffer:call(function()
vim.cmd('LspStop')
end)
buffer:parse_conflicts()
buffer:render_conflicts()
end
Expand Down
10 changes: 5 additions & 5 deletions lua/vgit/features/screens/ProjectCommitScreen/Store.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ function Store:get_lines()
if self.err then return nil, self.err end

return utils.list.concat(
{ '' },
utils.list.map(self.data, function(line)
return '# ' .. line
end)
)
{ '' },
utils.list.map(self.data, function(line)
return '# ' .. line
end)
)
end

return Store
6 changes: 3 additions & 3 deletions lua/vgit/features/screens/ProjectDiffScreen/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function ProjectDiffScreen:constructor(opts)
app_bar_view = AppBarView(scene, store),
diff_view = DiffView(scene, store, {
row = 1,
col = '20vw',
width = '80vw',
col = '25vw',
width = '75vw',
}, {
elements = {
header = true,
Expand All @@ -41,7 +41,7 @@ function ProjectDiffScreen:constructor(opts)
}, layout_type),
foldable_list_view = FoldableListView(scene, store, {
row = 1,
width = '20vw',
width = '25vw',
}, {
elements = {
header = false,
Expand Down
18 changes: 6 additions & 12 deletions lua/vgit/git/GitStatus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,11 @@ function GitStatus:has(status)
local actual_first, actual_second = self.first, self.second

if first == '*' then
if second == actual_second then
return true
end
if second == actual_second then return true end
elseif second == '*' then
if first == actual_first then
return true
end
if first == actual_first then return true end
else
if first == actual_first and second == actual_second then
return true
end
if first == actual_first and second == actual_second then return true end
end

return false
Expand All @@ -57,19 +51,19 @@ function GitStatus:has_both(status)
end

function GitStatus:is_unmerged()
return utils.list.some({ 'DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU' }, function (status)
return utils.list.some({ 'DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU' }, function(status)
return self:has(status)
end)
end

function GitStatus:is_staged()
return utils.list.some({ 'A*', 'M*', 'T*', 'D*', 'R*', 'C*' }, function (status)
return utils.list.some({ 'A*', 'M*', 'T*', 'D*', 'R*', 'C*' }, function(status)
return self:has(status)
end)
end

function GitStatus:is_unstaged()
return utils.list.some({ '*M', '*T', '*D', '*R', '*C', '??' }, function (status)
return utils.list.some({ '*M', '*T', '*D', '*R', '*C', '??' }, function(status)
return self:has(status)
end)
end
Expand Down
2 changes: 1 addition & 1 deletion lua/vgit/git/git_commit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function git_commit.create(reponame, description)
if has_no_changes then return nil, { 'Nothing to commit, working tree clean' } end
if is_uncommitted then return nil, { 'No changes added to commit (use "git add" and/or "git commit -a")' } end

return true
return true
end

function git_commit.dry_run(reponame)
Expand Down
8 changes: 4 additions & 4 deletions lua/vgit/git/git_repo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ function git_repo.discover(filepath)
local result, err = gitcli.run({ '-C', dirname, 'rev-parse', '--show-toplevel' })

if err then return nil, err end
return result[1]
return result[1]
end

function git_repo.exists(filepath)
local dirname = (filepath and vim.fn.fnamemodify(filepath, ':p:h')) or vim.loop.cwd()
local _, err = gitcli.run({ '-C', dirname, 'rev-parse', '--is-inside-git-dir' })

if err then return false end
return true
return true
end

function git_repo.has(reponame, filename, commit)
Expand All @@ -41,7 +41,7 @@ function git_repo.has(reponame, filename, commit)

if err then return nil, err end
if #result == 0 then return false end
return true
return true
end

function git_repo.ignores(reponame, filename)
Expand All @@ -52,7 +52,7 @@ function git_repo.ignores(reponame, filename)

if err then return nil, err end
if #result == 0 then return false end
return true
return true
end

function git_repo.checkout(reponame, name)
Expand Down
10 changes: 4 additions & 6 deletions lua/vgit/ui/FSListGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,10 @@ function FSListGenerator:create_node(path)
value = path.current,
}

if icon then
list_entry.icon_before = {
icon = icon,
hl = icon_hl,
}
end
if icon then list_entry.icon_before = {
icon = icon,
hl = icon_hl,
} end

return list_entry
end
Expand Down
14 changes: 6 additions & 8 deletions lua/vgit/ui/StatusListGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,14 @@ function StatusListGenerator:create_node(path)
before = {
text = status.value,
hl = self:derive_status_hl(status),
}
}
},
},
}

if icon then
list_entry.icon_before = {
icon = icon,
hl = icon_hl,
}
end
if icon then list_entry.icon_before = {
icon = icon,
hl = icon_hl,
} end

return list_entry
end
Expand Down
2 changes: 1 addition & 1 deletion lua/vgit/ui/components/AppBarComponent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end

function AppBarComponent:set_default_win_plot(win_plot)
win_plot.focusable = false
win_plot.zindex = 3
win_plot.zindex = 5
win_plot.height = 1

return self
Expand Down
3 changes: 3 additions & 0 deletions lua/vgit/ui/components/DiffComponent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ function DiffComponent:constructor(props)
header = true,
footer = true,
},
win_plot = {
zindex = 3
}
},
}, props)
return Component.constructor(self, props)
Expand Down
8 changes: 5 additions & 3 deletions lua/vgit/ui/components/FoldableListComponent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function FoldableListComponent:generate_lines()
if depth == 0 then
depth_0_item_counts[#depth_0_item_counts + 1] = {
lnum = depth_0_lnum,
count = item_count_for_depth_0
count = item_count_for_depth_0,
}
end
else
Expand All @@ -190,7 +190,9 @@ function FoldableListComponent:generate_lines()

-- NOTE: This sorts the root categories only.
-- For example, in project_diff_preview, Staged Changes will always come before Changes.
table.sort(self.state.list, function(item1, item2) return item1.value > item2.value end)
table.sort(self.state.list, function(item1, item2)
return item1.value > item2.value
end)
generate_lines(self.state.list, 0)

for i = 1, #depth_0_item_counts do
Expand Down Expand Up @@ -228,7 +230,7 @@ function FoldableListComponent:paint()
hl = virtual_text.hl,
row = virtual_text.lnum - 1,
col = 0,
pos = 'eol'
pos = 'eol',
})
end
end
Expand Down
2 changes: 1 addition & 1 deletion lua/vgit/ui/components/HeaderComponent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ end

function HeaderComponent:set_default_win_plot(win_plot)
win_plot.focusable = false
win_plot.zindex = 3
win_plot.zindex = 5
win_plot.height = 1

return self
Expand Down
1 change: 1 addition & 0 deletions lua/vgit/ui/dimensions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function dimensions.relative_win_plot(parent, child)
width = dimensions.relative_size(parent.width, child.width),
row = dimensions.relative_size(parent.row, child.row, 'add'),
col = dimensions.relative_size(parent.col, child.col, 'add'),
zindex = child.zindex
}
end

Expand Down
2 changes: 1 addition & 1 deletion lua/vgit/ui/elements/FooterElement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function FooterElement:mount(opts)
col = opts.col,
width = opts.width,
height = 1,
zindex = 3,
zindex = 5,
}):assign_options({
cursorbind = false,
scrollbind = false,
Expand Down
2 changes: 1 addition & 1 deletion lua/vgit/ui/elements/HeaderElement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function HeaderElement:mount(opts)
col = opts.col,
width = opts.width,
height = 1,
zindex = 3,
zindex = 5,
}):assign_options({
cursorbind = false,
scrollbind = false,
Expand Down
13 changes: 3 additions & 10 deletions lua/vgit/ui/views/DiffView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function DiffView:define()
height = '100vh',
width = '50vw',
col = '50vw',
zindex = 4
}),
},
})
Expand Down Expand Up @@ -752,18 +753,10 @@ function DiffView:render()

self.state = DiffView:get_initial_state()

return self:clear_title()
:clear_lines()
:clear_notification()
:reset_cursor()
return self:clear_title():clear_lines():clear_notification():reset_cursor()
end

return self:reset_cursor()
:render_title()
:render_filetype()
:render_lines()
:render_line_numbers()
:paint()
return self:reset_cursor():render_title():render_filetype():render_lines():render_line_numbers():paint()
end)

if not ok then console.debug.error(msg) end
Expand Down
2 changes: 1 addition & 1 deletion lua/vgit/ui/views/TableView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function TableView:move(direction)
end

function TableView:get_current_row()
local entries = self.store:get_all()
local entries = self.store:get_all()
if not entries then return nil end

return entries[self.scene:get('table'):get_lnum()]
Expand Down

0 comments on commit 2924520

Please sign in to comment.