Skip to content

Commit

Permalink
using nvim_open_term for better output
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisonleao committed Jan 14, 2023
1 parent 4e4c648 commit 83f1840
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lua/glow/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,26 @@ local function open_window(cmd, tmp)
vim.api.nvim_buf_set_option(buf, "filetype", "glowpreview")

-- keymaps
local keymaps_opts = { noremap = true, silent = true, buffer = buf }
local keymaps_opts = { silent = true, buffer = buf }
vim.keymap.set("n", "q", close_window, keymaps_opts)
vim.keymap.set("n", "<Esc>", close_window, keymaps_opts)

local cbs = {
on_exit = function()
on_input = function()
if tmp ~= nil then
vim.fn.delete(tmp)
end
end,
}
job_id = vim.fn.termopen(cmd, cbs)

local chan = vim.api.nvim_open_term(buf, cbs)
vim.fn.jobstart(cmd, {
on_stdout = function(_, data, _)
for _, d in ipairs(data) do
vim.api.nvim_chan_send(chan, d .. "\r\n")
end
end,
})

if glow.config.pager then
vim.cmd("startinsert")
Expand Down

0 comments on commit 83f1840

Please sign in to comment.