Skip to content

Commit 2a0675a

Browse files
Merge branch 'NeogitOrg:master' into master
2 parents b81070a + 614a634 commit 2a0675a

File tree

31 files changed

+833
-241
lines changed

31 files changed

+833
-241
lines changed

README.md

Lines changed: 104 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,84 @@ Here's an example spec for [Lazy](https://github.com/folke/lazy.nvim), but you'r
4444
```lua
4545
{
4646
"NeogitOrg/neogit",
47+
lazy = true,
4748
dependencies = {
4849
"nvim-lua/plenary.nvim", -- required
4950
"sindrets/diffview.nvim", -- optional - Diff integration
5051

5152
-- Only one of these is needed.
5253
"nvim-telescope/telescope.nvim", -- optional
5354
"ibhagwan/fzf-lua", -- optional
54-
"echasnovski/mini.pick", -- optional
55+
"nvim-mini/mini.pick", -- optional
5556
"folke/snacks.nvim", -- optional
5657
},
58+
cmd = "Neogit",
59+
keys = {
60+
{ "<leader>gg", "<cmd>Neogit<cr>", desc = "Show Neogit UI" }
61+
}
5762
}
5863
```
5964

60-
## Compatibility
65+
## Usage
6166

62-
The `master` branch will always be compatible with the latest **stable** release of Neovim, and usually with the latest **nightly** build as well.
67+
You can either open Neogit by using the `Neogit` command:
68+
69+
```vim
70+
:Neogit " Open the status buffer in a new tab
71+
:Neogit cwd=<cwd> " Use a different repository path
72+
:Neogit cwd=%:p:h " Uses the repository of the current file
73+
:Neogit kind=<kind> " Open specified popup directly
74+
:Neogit commit " Open commit popup
75+
76+
" Map it to a key
77+
nnoremap <leader>gg <cmd>Neogit<cr>
78+
```
79+
80+
```lua
81+
-- Or via lua api
82+
vim.keymap.set("n", "<leader>gg", "<cmd>Neogit<cr>", { desc = "Open Neogit UI" })
83+
```
84+
85+
Or using the lua api:
86+
87+
```lua
88+
local neogit = require('neogit')
89+
90+
-- open using defaults
91+
neogit.open()
92+
93+
-- open a specific popup
94+
neogit.open({ "commit" })
95+
96+
-- open as a split
97+
neogit.open({ kind = "split" })
98+
99+
-- open with different project
100+
neogit.open({ cwd = "~" })
101+
102+
-- You can map this to a key
103+
vim.keymap.set("n", "<leader>gg", neogit.open, { desc = "Open Neogit UI" })
104+
105+
-- Wrap in a function to pass additional arguments
106+
vim.keymap.set(
107+
"n",
108+
"<leader>gg",
109+
function() neogit.open({ kind = "split" }) end,
110+
{ desc = "Open Neogit UI" }
111+
)
112+
```
113+
114+
The `kind` option can be one of the following values:
115+
- `tab` (default)
116+
- `replace`
117+
- `split`
118+
- `split_above`
119+
- `split_above_all`
120+
- `split_below`
121+
- `split_below_all`
122+
- `vsplit`
123+
- `floating`
124+
- `auto` (`vsplit` if window would have 80 cols, otherwise `split`)
63125

64126
## Configuration
65127

@@ -78,6 +140,8 @@ neogit.setup {
78140
disable_context_highlighting = false,
79141
-- Disables signs for sections/items/hunks
80142
disable_signs = false,
143+
-- Path to git executable. Defaults to "git". Can be used to specify a custom git binary or wrapper script.
144+
git_executable = "git",
81145
-- Offer to force push when branches diverge
82146
prompt_force_push = true,
83147
-- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to
@@ -99,12 +163,33 @@ neogit.setup {
99163
log_date_format = nil,
100164
-- Show message with spinning animation when a git command is running.
101165
process_spinner = false,
102-
-- Used to generate URL's for branch popup action "pull request".
166+
-- Used to generate URL's for branch popup action "pull request", "open commit" and "open tree"
103167
git_services = {
104-
["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1",
105-
["bitbucket.org"] = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1",
106-
["gitlab.com"] = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}",
107-
["azure.com"] = "https://dev.azure.com/${owner}/_git/${repository}/pullrequestcreate?sourceRef=${branch_name}&targetRef=${target}",
168+
["github.com"] = {
169+
pull_request = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1",
170+
commit = "https://github.com/${owner}/${repository}/commit/${oid}",
171+
tree = "https://${host}/${owner}/${repository}/tree/${branch_name}",
172+
},
173+
["bitbucket.org"] = {
174+
pull_request = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1",
175+
commit = "https://bitbucket.org/${owner}/${repository}/commits/${oid}",
176+
tree = "https://bitbucket.org/${owner}/${repository}/branch/${branch_name}",
177+
},
178+
["gitlab.com"] = {
179+
pull_request = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}",
180+
commit = "https://gitlab.com/${owner}/${repository}/-/commit/${oid}",
181+
tree = "https://gitlab.com/${owner}/${repository}/-/tree/${branch_name}?ref_type=heads",
182+
},
183+
["azure.com"] = {
184+
pull_request = "https://dev.azure.com/${owner}/_git/${repository}/pullrequestcreate?sourceRef=${branch_name}&targetRef=${target}",
185+
commit = "",
186+
tree = "",
187+
},
188+
["codeberg.org"] = {
189+
pull_request = "https://${host}/${owner}/${repository}/compare/${branch_name}",
190+
commit = "https://${host}/${owner}/${repository}/commit/${oid}",
191+
tree = "https://${host}/${owner}/${repository}/src/branch/${branch_name}",
192+
},
108193
},
109194
-- Allows a different telescope sorter. Defaults to 'fuzzy_with_index_bias'. The example below will use the native fzf
110195
-- sorter instead. By default, this function returns `nil`.
@@ -133,6 +218,13 @@ neogit.setup {
133218
-- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt
134219
-- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options
135220
sort_branches = "-committerdate",
221+
-- Value passed to the `--<commit_order>-order` flag of the `git log` command
222+
-- Determines how commits are traversed and displayed in the log / graph:
223+
-- "topo" topological order (parents always before children, good for graphs, slower on large repos)
224+
-- "date" chronological order by commit date
225+
-- "author-date" chronological order by author date
226+
-- "" disable explicit ordering (fastest, recommended for very large repos)
227+
commit_order = "topo"
136228
-- Default for new branch name prompts
137229
initial_branch_name = "",
138230
-- Change the default way of opening neogit
@@ -424,47 +516,6 @@ neogit.setup {
424516
```
425517
</details>
426518

427-
## Usage
428-
429-
You can either open Neogit by using the `Neogit` command:
430-
431-
```vim
432-
:Neogit " Open the status buffer in a new tab
433-
:Neogit cwd=<cwd> " Use a different repository path
434-
:Neogit cwd=%:p:h " Uses the repository of the current file
435-
:Neogit kind=<kind> " Open specified popup directly
436-
:Neogit commit " Open commit popup
437-
```
438-
439-
Or using the lua api:
440-
441-
```lua
442-
local neogit = require('neogit')
443-
444-
-- open using defaults
445-
neogit.open()
446-
447-
-- open a specific popup
448-
neogit.open({ "commit" })
449-
450-
-- open as a split
451-
neogit.open({ kind = "split" })
452-
453-
-- open with different project
454-
neogit.open({ cwd = "~" })
455-
```
456-
457-
The `kind` option can be one of the following values:
458-
- `tab` (default)
459-
- `replace`
460-
- `split`
461-
- `split_above`
462-
- `split_above_all`
463-
- `split_below`
464-
- `split_below_all`
465-
- `vsplit`
466-
- `floating`
467-
- `auto` (`vsplit` if window would have 80 cols, otherwise `split`)
468519

469520
## Popups
470521

@@ -525,6 +576,10 @@ Neogit emits the following events:
525576

526577
Neogit follows semantic versioning.
527578

579+
## Compatibility
580+
581+
The `master` branch will always be compatible with the latest **stable** release of Neovim, and usually with the latest **nightly** build as well.
582+
528583
## Contributing
529584

530585
See [CONTRIBUTING.md](https://github.com/NeogitOrg/neogit/blob/master/CONTRIBUTING.md) for more details.

doc/neogit.txt

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ to Neovim users.
9494
disable_context_highlighting = false,
9595
-- Disables signs for sections/items/hunks
9696
disable_signs = false,
97+
-- Path to git executable. Defaults to "git". Can be used to specify a custom git binary or wrapper script.
98+
git_executable = "git",
9799
-- Offer to force push when branches diverge
98100
prompt_force_push = true,
99101
-- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to
@@ -113,12 +115,33 @@ to Neovim users.
113115
-- Show relative date by default. When set, use `strftime` to display dates
114116
commit_date_format = nil,
115117
log_date_format = nil,
116-
-- Used to generate URL's for branch popup action "pull request".
118+
-- Used to generate URL's for branch popup action "pull request" or opening a commit.
117119
git_services = {
118-
["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1",
119-
["bitbucket.org"] = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1",
120-
["gitlab.com"] = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}",
121-
["azure.com"] = "https://dev.azure.com/${owner}/_git/${repository}/pullrequestcreate?sourceRef=${branch_name}&targetRef=${target}",
120+
["github.com"] = {
121+
pull_request = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1",
122+
commit = "https://github.com/${owner}/${repository}/commit/${oid}",
123+
tree = "https://${host}/${owner}/${repository}/tree/${branch_name}",
124+
},
125+
["bitbucket.org"] = {
126+
pull_request = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1",
127+
commit = "https://bitbucket.org/${owner}/${repository}/commits/${oid}",
128+
tree = "https://bitbucket.org/${owner}/${repository}/branch/${branch_name}",
129+
},
130+
["gitlab.com"] = {
131+
pull_request = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}",
132+
commit = "https://gitlab.com/${owner}/${repository}/-/commit/${oid}",
133+
tree = "https://gitlab.com/${owner}/${repository}/-/tree/${branch_name}?ref_type=heads",
134+
},
135+
["azure.com"] = {
136+
pull_request = "https://dev.azure.com/${owner}/_git/${repository}/pullrequestcreate?sourceRef=${branch_name}&targetRef=${target}",
137+
commit = "",
138+
tree = "",
139+
},
140+
["codeberg.org"] = {
141+
pull_request = "https://${host}/${owner}/${repository}/compare/${branch_name}",
142+
commit = "https://${host}/${owner}/${repository}/commit/${oid}",
143+
tree = "https://${host}/${owner}/${repository}/src/branch/${branch_name}",
144+
},
122145
},
123146
-- Allows a different telescope sorter. Defaults to 'fuzzy_with_index_bias'. The example below will use the native fzf
124147
-- sorter instead. By default, this function returns `nil`.
@@ -147,11 +170,18 @@ to Neovim users.
147170
-- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt
148171
-- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options
149172
sort_branches = "-committerdate",
173+
-- Value passed to the `--<commit_order>-order` flag of the `git log` command
174+
-- Determines how commits are traversed and displayed in the log / graph:
175+
-- "topo" topological order (parents always before children, good for graphs, slower on large repos)
176+
-- "date" chronological order by commit date
177+
-- "author-date" chronological order by author date
178+
-- "" disable explicit ordering (fastest, recommended for very large repos)
179+
commit_order = "topo"
150180
-- Default for new branch name prompts
151181
initial_branch_name = "",
152182
-- Change the default way of opening neogit
153183
kind = "tab",
154-
-- Floating window style
184+
-- Floating window style
155185
floating = {
156186
relative = "editor",
157187
width = 0.8,
@@ -658,12 +688,17 @@ these yourself before the plugin loads, that will be respected. If they do not
658688
exist, they will be created with sensible defaults based on your colorscheme.
659689

660690
STATUS BUFFER
691+
NeogitNormal Normal text
692+
NeogitFloat Normal text when using a floating window
693+
NeogitFloatBorder Border wen using a floating window
661694
NeogitBranch Local branches
662695
NeogitBranchHead Accent highlight for current HEAD in LogBuffer
663696
NeogitRemote Remote branches
664697
NeogitObjectId Object's SHA hash
665698
NeogitStash Stash name
666699
NeogitFold Folded text highlight
700+
NeogitFoldColumn Column where folds are displayed
701+
NeogitSignColumn Column where signs are displayed
667702
NeogitRebaseDone Current position within rebase
668703
NeogitTagName Closest Tag name
669704
NeogitTagDistance Number of commits between the tag and HEAD
@@ -1333,16 +1368,16 @@ Actions: *neogit_commit_popup_actions*
13331368
• Alter *neogit_commit_alter*
13341369
Create a squash commit, authoring the final message now.
13351370

1336-
During a later rebase, when this commit gets squashed into it's targeted
1371+
During a later rebase, when this commit gets squashed into its targeted
13371372
commit, the original message of the targeted commit is replaced with the
13381373
message of this commit, without the user automatically being given a
13391374
chance to edit it again.
13401375

13411376
`git commit --fixup=amend:COMMIT --edit`
13421377

13431378
• Revise *neogit_commit_revise*
1344-
Reword the message of an existing commit, without editing it's tree.
1345-
Later, when the commit is squashed into it's targeted commit, a combined
1379+
Reword the message of an existing commit, without editing its tree.
1380+
Later, when the commit is squashed into its targeted commit, a combined
13461381
commit is created which uses the message of the fixup commit and the tree
13471382
of the targeted commit.
13481383

@@ -1578,7 +1613,7 @@ Actions: *neogit_pull_popup_actions*
15781613
pulled from and used to set `branch.<name>.pushRemote`.
15791614

15801615
• Pull into <current> from @{upstream} *neogit_pull_upstream*
1581-
Pulls into the current branch from it's upstream counterpart. If that is
1616+
Pulls into the current branch from its upstream counterpart. If that is
15821617
unset, the user will be prompted to select a remote branch, which will
15831618
pulled from and set as the upstream.
15841619

@@ -1648,7 +1683,7 @@ Actions: *neogit_push_popup_actions*
16481683
and pushed to.
16491684

16501685
• Push <current> to @{upstream} *neogit_push_upstream*
1651-
Pushes the current branch to it's upstream branch. If not set, then the
1686+
Pushes the current branch to its upstream branch. If not set, then the
16521687
user will be prompted to select a remote, which will be set as the
16531688
current branch's upstream and pushed to.
16541689

@@ -1770,13 +1805,13 @@ Arguments: *neogit_rebase_popup_args*
17701805

17711806
Actions: *neogit_rebase_popup_actions*
17721807
• Rebase onto pushRemote *neogit_rebase_pushRemote*
1773-
This action rebases the current branch onto it's pushRemote.
1808+
This action rebases the current branch onto its pushRemote.
17741809

17751810
When the pushRemote is not configured, then the user can first set it
17761811
before rebasing.
17771812

17781813
• Rebase onto upstream *neogit_rebase_upstream*
1779-
This action rebases the current branch onto it's upstream branch.
1814+
This action rebases the current branch onto its upstream branch.
17801815

17811816
When the upstream is not configured, then the user can first set it
17821817
before rebasing.
@@ -2166,7 +2201,7 @@ Popup Builder *neogit_popup_builder*
21662201

21672202
You can leverage Neogit's infrastructure to create your own popups and
21682203
actions. For example, you can define actions as a function which will take the
2169-
popup instance as it's argument:
2204+
popup instance as its argument:
21702205
>lua
21712206
local function my_action(popup)
21722207
-- You can access the popup state (enabled flags) like so:
@@ -2194,7 +2229,7 @@ popup instance as it's argument:
21942229
-- A switch is a boolean CLI flag, like `--no-verify`
21952230
:switch("s", "my-switch", "My switch")
21962231
-- An "_if" variant exists for builder methods, that takes a boolean
2197-
-- as it's first argument.
2232+
-- as its first argument.
21982233
:switch_if(true, "S", "conditional-switch", "This switch is conditional")
21992234
-- Options are CLI flags that have a value, like `--strategy=octopus`
22002235
:option("o", "my-option", "default_value", "My option", { key_prefix = "-" })
@@ -2234,7 +2269,7 @@ Customizing Popups *neogit_custom_popups*
22342269

22352270
You can customize existing popups via the Neogit config.
22362271

2237-
Below is an example of adding a custom switch, but you can use any function
2272+
Below is an example of adding a custom switch, but you can use any function
22382273
from the builder API.
22392274
>lua
22402275
require("neogit").setup({

0 commit comments

Comments
 (0)