From 0541f862368e1cf9153525830c52aa4b53b7f6f4 Mon Sep 17 00:00:00 2001 From: redjax Date: Mon, 29 Sep 2025 17:08:35 -0400 Subject: [PATCH] fix(floaterm): Fix shell detection --- config/nvim/lua/plugins/lazy/packages/floaterm.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/config/nvim/lua/plugins/lazy/packages/floaterm.lua b/config/nvim/lua/plugins/lazy/packages/floaterm.lua index 32cbd06e..401b1ea3 100644 --- a/config/nvim/lua/plugins/lazy/packages/floaterm.lua +++ b/config/nvim/lua/plugins/lazy/packages/floaterm.lua @@ -11,22 +11,23 @@ return { { "fx", "FloatermKill", desc = "Kill Floaterm" }, }, init = function() - if vim.g.platform == "windows" then + -- Detect Windows properly using vim.fn.has() + local is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1 + + if is_windows then -- Use pwsh if available, otherwise fallback to powershell local shell = vim.fn.executable("pwsh") == 1 and "pwsh" or "powershell" vim.opt.shell = shell - vim.opt.shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;" - vim.opt.shellredir = "-RedirectStandardOutput %s -NoNewWindow -Wait" + vim.opt.shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command" + vim.opt.shellredir = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode" vim.opt.shellpipe = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode" vim.opt.shellquote = "" vim.opt.shellxquote = "" - -- Floaterm settings (optional) + -- Floaterm settings vim.g.floaterm_shell = shell - vim.g.floaterm_shellcmd = "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command -" else vim.opt.shell = "bash" vim.g.floaterm_shell = "bash" - vim.g.floaterm_shellcmd = nil end vim.g.floaterm_position = 'center' vim.g.floaterm_width = 0.8