Skip to content

Commit

Permalink
Run viewer asynchronously using vim.system (#873)
Browse files Browse the repository at this point in the history
Previously, when the viewer opened, the editor was blocked until the
user closes the viewer. Now, the viewer opens asynchronously (using
`vim.system` rather than the old `vim.fn.system`); in this way, the user
can view the PDF while continuing editing the org file in the editor.
  • Loading branch information
moreka authored Jan 28, 2025
1 parent fa5f3d9 commit f9a74a4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/orgmode/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,18 @@ end

function utils.open(target)
if vim.fn.executable('xdg-open') == 1 then
return vim.fn.system(string.format('xdg-open %s', target))
vim.system({ 'xdg-open', target }, { text = false })
return 0
end

if vim.fn.executable('open') == 1 then
return vim.fn.system(string.format('open %s', target))
vim.system({ 'open', target }, { text = false })
return 0
end

if vim.fn.has('win32') == 1 then
return vim.fn.system(string.format('start "%s"', target))
vim.system({ 'start', target }, { text = false })
return 0
end
end

Expand Down

0 comments on commit f9a74a4

Please sign in to comment.