Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lua/nvchad/term/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,27 @@ local function create(opts)
local buf_exists = opts.buf
opts.buf = opts.buf or vim.api.nvim_create_buf(false, true)

-- handle cmd opt
-- handle cmd and flag
local shell = vim.o.shell
local cmd = shell
local shellcmdflag = vim.o.shellcmdflag
local cmd = { shell }

if opts.cmd and opts.buf then
cmd = { shell, "-c", format_cmd(opts.cmd) .. "; " .. shell }
else
cmd = { shell }
for flag in string.gmatch(shellcmdflag, "%S+") do
table.insert(cmd, flag)
end

table.insert(cmd, shell)

if vim.uv.os_uname().sysname:find "Windows" ~= nil then
table.insert(cmd, "-NoLogo")
end

M.display(opts)

save_term_info(opts.buf, opts)

opts.termopen_opts = vim.tbl_extend("force", opts.termopen_opts or {}, { detach = false })
if not buf_exists then
vim.fn.termopen(cmd, opts.termopen_opts)
vim.fn.jobstart(cmd, { term = true })
end

vim.g.nvhterm = opts.pos == "sp"
Expand Down