Skip to content

Commit

Permalink
Allow configuring graph style
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey committed Nov 28, 2023
1 parent 7eccfc4 commit e1a0a9d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
4 changes: 4 additions & 0 deletions lua/neogit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ end

---@alias NeogitConfigMappingsPopup "HelpPopup" | "DiffPopup" | "PullPopup" | "RebasePopup" | "MergePopup" | "PushPopup" | "CommitPopup" | "LogPopup" | "RevertPopup" | "StashPopup" | "IgnorePopup" | "CherryPickPopup" | "BranchPopup" | "FetchPopup" | "ResetPopup" | "RemotePopup" | "TagPopup" | false

---@alias NeogitGraphStyle "ascii" | "flog"

---@class NeogitConfigMappings Consult the config file or documentation for values
---@field finder? { [string]: NeogitConfigMappingsFinder } A dictionary that uses finder commands to set multiple keybinds
---@field status? { [string]: NeogitConfigMappingsStatus } A dictionary that uses status commands to set a single keybind
---@field popup? { [string]: NeogitConfigMappingsPopup } A dictionary that uses popup commands to set a single keybind

---@class NeogitConfig Neogit configuration settings
---@field filewatcher? NeogitFilewatcherConfig Values for filewatcher
---@field graph_style? NeogitGraphStyle Style for graph
---@field disable_hint? boolean Remove the top hint in the Status buffer
---@field disable_context_highlighting? boolean Disable context highlights based on cursor position
---@field disable_signs? boolean Special signs to draw for sections etc. in Neogit
Expand Down Expand Up @@ -141,6 +144,7 @@ function M.get_default_values()
disable_context_highlighting = false,
disable_signs = false,
disable_commit_confirmation = false,
graph_style = "ascii",
filewatcher = {
interval = 1000,
enabled = false,
Expand Down
9 changes: 7 additions & 2 deletions lua/neogit/lib/git/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ end
---@param graph? table
---@param files? table
---@return CommitLogEntry[]
function M.list(options, graph, files)
function M.list(options, graph, files, graph_color)
files = files or {}

local signature = false
Expand All @@ -399,7 +399,12 @@ function M.list(options, graph, files)

local graph_output
if graph then
graph_output = require("neogit.lib.graph").build(commits)
if config.values.graph_style == "flog" then
graph_output = require("neogit.lib.graph").build(commits)
elseif config.values.graph_style == "ascii" then
util.remove_item_from_table(options, "--show-signature")
graph_output = M.graph(options, files, graph_color)
end
else
graph_output = {}
end
Expand Down
17 changes: 2 additions & 15 deletions lua/neogit/popups/log/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ local FuzzyFinderBuffer = require("neogit.buffers.fuzzy_finder")

local operation = require("neogit.operations")

---Builds a graph for the popup if required
---@param popup table Contains the argument list
---@param flags table extra CLI flags like --branches or --remotes
---@return table|nil
local function maybe_graph(popup, flags)
local args = popup:get_internal_arguments()
if args.graph then
local external_args = popup:get_arguments()
util.remove_item_from_table(external_args, "--show-signature")

return git.log.graph(util.merge(external_args, flags), popup.state.env.files, args.color)
end
end

--- Runs `git log` and parses the commits
---@param popup table Contains the argument list
---@param flags table extra CLI flags like --branches or --remotes
Expand All @@ -31,7 +17,8 @@ local function commits(popup, flags)
return git.log.list(
util.merge(popup:get_arguments(), flags),
popup:get_internal_arguments().graph,
popup.state.env.files
popup.state.env.files,
popup:get_internal_arguments().color
)
end

Expand Down

0 comments on commit e1a0a9d

Please sign in to comment.