File tree 1 file changed +4
-7
lines changed
1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -309,17 +309,14 @@ the URL.
309
309
310
310
``` lua
311
311
vim .keymap .set (" n" , " gx" , function ()
312
- -- select URL
313
- require (" various-textobjs" ).url ()
312
+ require (" various-textobjs" ).url () -- select URL
314
313
315
- -- plugin only switches to visual mode when textobj is found
316
- local foundURL = vim .fn .mode () == " v"
314
+ local foundURL = vim .fn .mode () == " v" -- only switches to visual mode when textobj found
317
315
if not foundURL then return end
318
316
319
- -- retrieve URL with the z-register as intermediary
320
- vim .cmd .normal { ' "zy' , bang = true }
321
- local url = vim .fn .getreg (" z" )
317
+ local url = vim .fn .getregion (vim .fn .getpos (" ." ), vim .fn .getpos (" v" ), { type = " v" })[1 ]
322
318
vim .ui .open (url ) -- requires nvim 0.10
319
+ vim .cmd .normal { " v" , bang = true } -- leave visual mode
323
320
end , { desc = " URL Opener" })
324
321
```
325
322
You can’t perform that action at this time.
0 commit comments