File tree Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,12 @@ Enable `show_builtin_git_pickers` to additionally show builtin git pickers.
136
136
``` lua
137
137
{
138
138
-- Browse command to open commits in browser. Default fugitive GBrowse.
139
- browse_command = " GBrowse" ,
139
+ -- {commit_hash} is the placeholder for the commit hash.
140
+ browse_command = " GBrowse {commit_hash}" ,
141
+ -- when {commit_hash} is not provided, the commit will be appended to the specified command seperated by a space
142
+ -- browse_command = "GBrowse",
143
+ -- => both will result in calling `:GBrowse commit`
144
+
140
145
-- fugitive or diffview
141
146
diff_plugin = " fugitive" ,
142
147
-- customize git in previewer
Original file line number Diff line number Diff line change 55
55
--- General action: Open commit in browser
56
56
--- @param commit_hash string
57
57
M .open_in_browser = function (commit_hash )
58
- vim .api .nvim_command (" :" .. config .get_browse_command () .. commit_hash )
58
+ vim .api .nvim_command (" :" .. config .get_browse_command (commit_hash ) )
59
59
end
60
60
61
61
--- General action: Checkout commit
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ local open_commit_in_browser = function(prompt_bufnr)
34
34
actions .close (prompt_bufnr )
35
35
local selection = action_state .get_selected_entry ()
36
36
37
- vim . api . nvim_command ( " :GBrowse " .. selection .opts .commit_hash )
37
+ global_actions . open_in_browser ( selection .opts .commit_hash )
38
38
end
39
39
40
40
--- Open browser at commmit (from entry) with <C-o>
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ local config = {}
5
5
M .setup = function (ext_config )
6
6
ext_config = ext_config or {}
7
7
8
- ext_config .browse_command = ext_config .browse_command or " GBrowse"
8
+ ext_config .browse_command = ext_config .browse_command
9
+ or " GBrowse {commit_hash}"
9
10
ext_config .diff_plugin = ext_config .diff_plugin or " fugitive"
10
11
ext_config .git_diff_flags = ext_config .git_diff_flags or {}
11
12
ext_config .show_builtin_git_pickers = ext_config .show_builtin_git_pickers
@@ -165,8 +166,15 @@ M.show_builtin_git_pickers = function()
165
166
return config [" show_builtin_git_pickers" ]
166
167
end
167
168
168
- M .get_browse_command = function ()
169
- return config [" browse_command" ]
169
+ M .get_browse_command = function (commit_hash )
170
+ local cmd = config [" browse_command" ]
171
+ local commit_pattern = " %{commit_hash%}"
172
+
173
+ if string.find (config [" browse_command" ], commit_pattern ) == nil then
174
+ return cmd .. " " .. commit_hash
175
+ end
176
+
177
+ return string.gsub (cmd , commit_pattern , commit_hash )
170
178
end
171
179
172
180
return M
You can’t perform that action at this time.
0 commit comments