File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,8 @@ In `visual` mode, searches for the selected text.
66
77### Demo
88
9-
109https://user-images.githubusercontent.com/33713262/226383032-113b4db8-27a3-4b8f-aa36-c0765b2cc903.mp4
1110
12-
13-
1411### Install
1512
1613``` lua
@@ -21,18 +18,18 @@ https://user-images.githubusercontent.com/33713262/226383032-113b4db8-27a3-4b8f-
2118 {
2219 " <leader>feg" ,
2320 function ()
24- local url = require (" csgithub" ).search ({
21+ local csgithub = require (" csgithub" )
22+
23+ local url = csgithub .search ({
2524 includeFilename = false ,
2625 includeExtension = true ,
2726 })
2827
29- if url then
30- require (" util" ).open_url (url )
31- end
28+ csgithub .open (url )
3229 end ,
3330 mode = { " n" , " v" },
3431 desc = " Search Github" ,
3532 },
3633 },
37- },
34+ }
3835```
Original file line number Diff line number Diff line change @@ -17,4 +17,20 @@ M.search = function(args)
1717 return url
1818end
1919
20+ function M .open (url )
21+ -- return if url is empty
22+ if url == nil or url == " " then
23+ print (" Error: url is empty!" )
24+ return
25+ end
26+
27+ if vim .fn .has (" mac" ) == 1 then
28+ vim .fn .jobstart ({ " open" , url }, { detach = true })
29+ elseif vim .fn .has (" unix" ) == 1 then
30+ vim .fn .jobstart ({ " xdg-open" , url }, { detach = true })
31+ else
32+ print (" Error: unknown open command on this OS!" )
33+ end
34+ end
35+
2036return M
You can’t perform that action at this time.
0 commit comments