Skip to content

Commit

Permalink
refactor!: remove system_open function as one should use vim.ui.open
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Sep 16, 2024
1 parent 6a4e469 commit c8c5354
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions lua/astrocore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,36 +124,6 @@ function M.exec_buffer_autocmds(event, opts)
end
end

--- Open a URL under the cursor with the current operating system
---@param path string The path of the file to open with the system opener
function M.system_open(path)
if not path then
path = vim.fn.expand "<cfile>"
elseif not path:match "%w+:" then
path = vim.fn.expand(path)
end
-- TODO: remove deprecated method check after dropping support for neovim v0.9
if vim.ui.open then return vim.ui.open(path) end
local cmd
if vim.fn.has "mac" == 1 then
cmd = { "open" }
elseif vim.fn.has "win32" == 1 then
if vim.fn.executable "rundll32" then
cmd = { "rundll32", "url.dll,FileProtocolHandler" }
else
cmd = { "cmd.exe", "/K", "explorer" }
end
elseif vim.fn.has "unix" == 1 then
if vim.fn.executable "explorer.exe" == 1 then
cmd = { "explorer.exe" }
elseif vim.fn.executable "xdg-open" == 1 then
cmd = { "xdg-open" }
end
end
if not cmd then M.notify("Available system opening tool not found!", vim.log.levels.ERROR) end
vim.fn.jobstart(vim.list_extend(cmd, { path }), { detach = true })
end

--- Helper function to read a file and return it's content
---@param path string the path to the file to read
---@return string content the contents of the file
Expand Down

0 comments on commit c8c5354

Please sign in to comment.