Skip to content

Commit

Permalink
Merge branch 'nightly' into refs-view
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey authored Nov 28, 2023
2 parents c7eae57 + fcc07f7 commit 79a1e67
Show file tree
Hide file tree
Showing 14 changed files with 794 additions and 173 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ local neogit = require('neogit')
neogit.setup {}
```

## Compatibility

The `master` branch will always be compatible with the latest **stable** release of Neovim, and with the latest **nightly** build as well.

Some features may only be available using unreleased (neovim nightly) API's - to use them, set your plugin manager to track the `nightly` branch instead.

The `nightly` branch has the same stability guarantees as the `master` branch.

## Configuration

You can configure neogit by running the `neogit.setup()` function, passing a table as the argument.
Expand Down Expand Up @@ -71,6 +79,9 @@ neogit.setup {
interval = 1000,
enabled = true,
},
-- "ascii" is the graph the git CLI generates
-- "unicode" is the graph like https://github.com/rbong/vim-flog
graph_style = "ascii",
-- Used to generate URL's for branch popup action "pull request".
git_services = {
["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1",
Expand Down
10 changes: 5 additions & 5 deletions lua/neogit/buffers/commit_view/init.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
local Buffer = require("neogit.lib.buffer")
local cli = require("neogit.lib.git.cli")
local parser = require("neogit.buffers.commit_view.parsing")
local ui = require("neogit.buffers.commit_view.ui")
local log = require("neogit.lib.git.log")
local git = require("neogit.lib.git")
local config = require("neogit.config")
local popups = require("neogit.popups")
local notification = require("neogit.lib.notification")
Expand Down Expand Up @@ -47,15 +46,15 @@ function M.new(commit_id, notify)
notification.info("Parsing commit...")
end

local commit_info = log.parse(cli.show.format("fuller").args(commit_id).call_sync().stdout)[1]
local commit_info = git.log.parse(git.cli.show.format("fuller").args(commit_id).call_sync().stdout)[1]
commit_info.commit_arg = commit_id
local instance = {
is_open = false,
commit_info = commit_info,
commit_overview = parser.parse_commit_overview(
cli.show.stat.oneline.args(commit_id).call_sync():trim().stdout
git.cli.show.stat.oneline.args(commit_id).call_sync():trim().stdout
),
commit_signature = config.values.commit_view.verify_commit and log.verify_commit(commit_id) or {},
commit_signature = config.values.commit_view.verify_commit and git.log.verify_commit(commit_id) or {},
buffer = nil,
}

Expand Down Expand Up @@ -154,6 +153,7 @@ function M:open()
[popups.mapping_for("CommitPopup")] = popups.open("commit", function(p)
p { commit = self.commit_info.oid }
end),
[popups.mapping_for("FetchPopup")] = popups.open("fetch"),
[popups.mapping_for("PushPopup")] = popups.open("push", function(p)
p { commit = self.commit_info.oid }
end),
Expand Down
36 changes: 21 additions & 15 deletions lua/neogit/buffers/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,28 @@ M.CommitEntry = Component.new(function(commit, args)

-- Parse out ref names
if args.decorate and commit.ref_name ~= "" then
local ref_name, _ = commit.ref_name:gsub("HEAD %-> ", "")
local is_head = string.match(commit.ref_name, "HEAD %->") ~= nil
local branch_highlight = is_head and "NeogitBranchHead" or "NeogitBranch"

local info = git.log.branch_info(ref_name, git.remote.list())
for _, branch in ipairs(info.untracked) do
table.insert(ref, text(branch, { highlight = "NeogitBranch" }))
table.insert(ref, text(" "))
local info = git.log.branch_info(commit.ref_name, git.remote.list())

-- Render local only branches first
for name, _ in pairs(info.locals) do
if info.remotes[name] == nil then
local branch_highlight = info.head == name and "NeogitBranchHead" or "NeogitBranch"
table.insert(ref, text(name, { highlight = branch_highlight }))
table.insert(ref, text(" "))
end
end
for branch, remotes in pairs(info.tracked) do

-- Render tracked (local+remote) branches next
for name, remotes in pairs(info.remotes) do
if #remotes == 1 then
table.insert(ref, text(remotes[1] .. "/", { highlight = "NeogitRemote" }))
end
if #remotes > 1 then
table.insert(ref, text("{" .. table.concat(remotes, ",") .. "}/", { highlight = "NeogitRemote" }))
end
table.insert(ref, text(branch, { highlight = branch_highlight }))
local branch_highlight = info.head == name and "NeogitBranchHead" or "NeogitBranch"
local locally = info.locals[name] ~= nil
table.insert(ref, text(name, { highlight = locally and branch_highlight or "NeogitRemote" }))
table.insert(ref, text(" "))
end
for _, tag in pairs(info.tags) do
Expand All @@ -152,8 +157,8 @@ M.CommitEntry = Component.new(function(commit, args)
details = col.padding_left(8) {
row(util.merge(graph, {
text(" "),
text("Author: ", { highlight = "NeogitGraphAuthor" }),
text(commit.author_name),
text("Author: ", { highlight = "Comment" }),
text(commit.author_name, { highlight = "NeogitGraphAuthor" }),
text(" <"),
text(commit.author_email),
text(">"),
Expand All @@ -178,7 +183,7 @@ M.CommitEntry = Component.new(function(commit, args)
})),
row(graph),
col(
flat_map(commit.description, function(line)
flat_map({ commit.subject, commit.body }, function(line)
local lines = map(util.str_wrap(line, vim.o.columns * 0.6), function(l)
return row(util.merge(graph, { text(" "), text(l) }))
end)
Expand All @@ -200,10 +205,11 @@ M.CommitEntry = Component.new(function(commit, args)
row(
util.merge({
text(commit.oid:sub(1, 7), {
highlight = commit.signature_code and highlight_for_signature[commit.signature_code] or "Comment",
highlight = commit.verification_flag and highlight_for_signature[commit.verification_flag]
or "Comment",
}),
text(" "),
}, graph, { text(" ") }, ref, { text(commit.description[1]) }),
}, graph, { text(" ") }, ref, { text(commit.subject) }),
{
virtual_text = {
{ " ", "Constant" },
Expand Down
2 changes: 2 additions & 0 deletions lua/neogit/buffers/log_view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function M:open()
[popups.mapping_for("CommitPopup")] = popups.open("commit", function(p)
p { commit = self.buffer.ui:get_commit_under_cursor() }
end),
[popups.mapping_for("FetchPopup")] = popups.open("fetch"),
[popups.mapping_for("PushPopup")] = popups.open("push", function(p)
p { commit = self.buffer.ui:get_commit_under_cursor() }
end),
Expand Down Expand Up @@ -87,6 +88,7 @@ function M:open()
[popups.mapping_for("CommitPopup")] = popups.open("commit", function(p)
p { commit = self.buffer.ui:get_commit_under_cursor() }
end),
[popups.mapping_for("FetchPopup")] = popups.open("fetch"),
[popups.mapping_for("PushPopup")] = popups.open("push", function(p)
p { commit = self.buffer.ui:get_commit_under_cursor() }
end),
Expand Down
1 change: 1 addition & 0 deletions lua/neogit/buffers/reflog_view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function M:open(_)
[popups.mapping_for("CommitPopup")] = popups.open("commit", function(p)
p { commit = self.buffer.ui:get_commit_under_cursor() }
end),
[popups.mapping_for("FetchPopup")] = popups.open("fetch"),
[popups.mapping_for("PushPopup")] = popups.open("push", function(p)
p { commit = self.buffer.ui:get_commit_under_cursor() }
end),
Expand Down
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" | "unicode"

---@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
1 change: 1 addition & 0 deletions lua/neogit/lib/ansi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function M.parse(str, opts)
local out = {}
for g in parsed:gmatch(".") do
if g == mark then
assert(not vim.tbl_isempty(colored), "ANSI Parser didn't construct all graph parts: " .. str)
table.insert(out, table.remove(colored, 1))
else
table.insert(out, { text = g, color = "Gray", oid = oid })
Expand Down
Loading

0 comments on commit 79a1e67

Please sign in to comment.