mirror of
				https://github.com/folke/lazy.nvim.git
				synced 2025-10-31 22:41:05 +00:00 
			
		
		
		
	Merge f6090f634d into 6c3bda4aca
		
	This commit is contained in:
		
				commit
				
					
						1b2a078890
					
				
			
		
					 1 changed files with 41 additions and 25 deletions
				
			
		|  | @ -25,32 +25,48 @@ function M.open(uri, opts) | ||||||
|   if not opts.system and M.file_exists(uri) then |   if not opts.system and M.file_exists(uri) then | ||||||
|     return M.float({ style = "", file = uri }) |     return M.float({ style = "", file = uri }) | ||||||
|   end |   end | ||||||
|   local Config = require("lazy.core.config") |   if vim.fn.has('nvim-0.10.0') == 1 then | ||||||
|   local cmd |     local cmd, err = vim.ui.open(uri) | ||||||
|   if not opts.system and Config.options.ui.browser then |     if cmd then | ||||||
|     cmd = { Config.options.ui.browser, uri } |       cmd:wait() | ||||||
|   elseif vim.fn.has("win32") == 1 then |  | ||||||
|     cmd = { "explorer", uri } |  | ||||||
|   elseif vim.fn.has("macunix") == 1 then |  | ||||||
|     cmd = { "open", uri } |  | ||||||
|   else |  | ||||||
|     if vim.fn.executable("xdg-open") == 1 then |  | ||||||
|       cmd = { "xdg-open", uri } |  | ||||||
|     elseif vim.fn.executable("wslview") == 1 then |  | ||||||
|       cmd = { "wslview", uri } |  | ||||||
|     else |  | ||||||
|       cmd = { "open", uri } |  | ||||||
|     end |     end | ||||||
|   end |     if err then | ||||||
| 
 |       local msg = { | ||||||
|   local ret = vim.fn.jobstart(cmd, { detach = true }) |         "Failed to open uri", | ||||||
|   if ret <= 0 then |         err, | ||||||
|     local msg = { |         vim.inspect(uri), | ||||||
|       "Failed to open uri", |       } | ||||||
|       ret, |       vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR) | ||||||
|       vim.inspect(cmd), |     end | ||||||
|     } |   else | ||||||
|     vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR) |     local Config = require("lazy.core.config") | ||||||
|  |     local cmd | ||||||
|  |     if not opts.system and Config.options.ui.browser then | ||||||
|  |       cmd = { Config.options.ui.browser, uri } | ||||||
|  |     elseif vim.fn.has("win32") == 1 then | ||||||
|  |       cmd = { "explorer", uri } | ||||||
|  |     elseif vim.fn.has("macunix") == 1 then | ||||||
|  |       cmd = { "open", uri } | ||||||
|  |     else | ||||||
|  |       if vim.fn.executable("xdg-open") == 1 then | ||||||
|  |         cmd = { "xdg-open", uri } | ||||||
|  |       elseif vim.fn.executable("wslview") == 1 then | ||||||
|  |         cmd = { "wslview", uri } | ||||||
|  |       elseif vim.fn.executable("explorer.exe") == 1 then | ||||||
|  |         cmd = { "explorer.exe", uri } | ||||||
|  |       else | ||||||
|  |         cmd = { "open", uri } | ||||||
|  |       end | ||||||
|  |     end | ||||||
|  |       local ret = vim.fn.jobstart(cmd, { detach = true }) | ||||||
|  |       if ret <= 0 then | ||||||
|  |         local msg = { | ||||||
|  |           "Failed to open uri", | ||||||
|  |           ret, | ||||||
|  |           vim.inspect(cmd), | ||||||
|  |         } | ||||||
|  |         vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR) | ||||||
|  |       end | ||||||
|   end |   end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue