@@ -68,7 +68,59 @@ There are several methods to install git-open:
6868zplug " chenasraf/git-open"
6969```
7070
71- ## Adding to LazyGit
71+ ## Adding to your tools
72+
73+ Feel free to post configurations you have come up with as a PR.
74+
75+ ### Adding to Neovim
76+
77+ You can add a command, a keybinding, or both to your Neovim config files.
78+ Here is a starter template you can use, feel free to adjust to your needs.
79+
80+ ``` lua
81+ -- :GitOpen command
82+ -- usage: :GitOpen [...args]
83+ vim .api .nvim_create_user_command (' GitOpen' , function (opts )
84+ local args = opts .args
85+ local cmd = " git open"
86+ if # args > 0 then
87+ cmd = cmd .. " " .. args
88+ vim .cmd (" :silent !" .. cmd )
89+ else
90+ local types = { " branch" , " pr" , " prs" , " repo" , " commit" , " file" }
91+ local type_map = {
92+ repo = " Project" ,
93+ branch = " Current branch" ,
94+ commit = " Commit" ,
95+ file = " File" ,
96+ pr = " Create/open Pull Request" ,
97+ prs = " PRs list"
98+ }
99+ vim .ui .select (types , {
100+ prompt = " Git open" ,
101+ format_item = function (item ) return type_map [item ] end
102+ }, function (selected )
103+ local extras = " "
104+ if selected == " file" then
105+ extras = vim .fn .expand (" %" )
106+ end
107+ if extras ~= " " then
108+ selected = selected .. " " .. extras
109+ end
110+ vim .cmd (" GitOpen " .. selected )
111+ end )
112+ end
113+ end , { nargs = ' *' })
114+
115+ -- keymaps
116+ vim .keymap .set (" n" , " <leader>go" , " :GitOpen<CR>" , { desc = " Git open" , silent = true })
117+ vim .keymap .set (" n" , " <leader>gOp" , " :GitOpen repo<CR>" , { desc = " Git open repo" , silent = true })
118+ vim .keymap .set (" n" , " <leader>gOb" , " :GitOpen branch<CR>" , { desc = " Git open branch" , silent = true })
119+ vim .keymap .set (" n" , " <leader>gOc" , " :GitOpen commit<CR>" , { desc = " Git open commit" , silent = true })
120+ vim .keymap .set (" n" , " <leader>gOf" , " :GitOpen file<CR>" , { desc = " Git open file" , silent = true })
121+ ```
122+
123+ ### Adding to LazyGit
72124
73125You can add ` git-open ` to your ` lazygit ` config file and open selected files/refs with it.
74126Here is an example ` customCommands ` entry, but you can of course modify it or create your own:
@@ -90,7 +142,7 @@ customCommands:
90142 value : ' commit'
91143 - name : ' Open File'
92144 value : ' file'
93- - name : ' Create Pull Request'
145+ - name : ' Create/open Pull Request'
94146 value : ' pr'
95147 - name : ' Open Pull Requests'
96148 value : ' prs'
0 commit comments