From f13957d8ec2a2269b197e360a0b98971c937b9df Mon Sep 17 00:00:00 2001 From: basham00 Date: Thu, 14 Nov 2024 15:44:19 -0500 Subject: [PATCH 1/2] fix: Windows OS cmd with echo --- lua/sf/sub/raw_term.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lua/sf/sub/raw_term.lua b/lua/sf/sub/raw_term.lua index adfce75..7cbb93f 100644 --- a/lua/sf/sub/raw_term.lua +++ b/lua/sf/sub/raw_term.lua @@ -59,7 +59,15 @@ function T:run_after_setup(cmd, cb) api.nvim_set_current_win(self.win) local echo_msg = string.gsub(cmd, '"', '\\"') - local cmd_with_echo = string.format('echo -e "\\e[0;35m %s \\e[0m";%s', echo_msg, cmd) -- echo Cyan color + local cmd_with_echo = '' + + if H.is_windows_os() then + local c27 = string.char(27) + cmd_with_echo = string.format('echo %s && %s', c27 .. '[0;35m' .. echo_msg .. c27 .. '[0m', cmd) + else + cmd_with_echo = string.format('echo -e "\\e[0;35m %s \\e[0m";%s', echo_msg, cmd) -- echo Cyan color + end + -- local cmd_with_echo = string.format('echo -e "\\e[0;35m %s \\e[0m";%s', echo_msg, cmd) -- echo Cyan color vim.fn.termopen(cmd_with_echo, { clear_env = self.config.clear_env, env = self.config.env, @@ -213,4 +221,11 @@ function H.get_dimension(opts) } end +function H.is_windows_os() + if vim.fn.has("win32") then + return true + end + return false +end + return T From 95c77f7f86969375a17d168a93da848b6d66e8d8 Mon Sep 17 00:00:00 2001 From: basham00 Date: Thu, 14 Nov 2024 16:00:14 -0500 Subject: [PATCH 2/2] fix: Windows root path formatting --- lua/sf/util.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/sf/util.lua b/lua/sf/util.lua index 6e7338c..4ff6ae0 100644 --- a/lua/sf/util.lua +++ b/lua/sf/util.lua @@ -36,7 +36,10 @@ end M.get_default_dir_path = function() local dir_path = M.get_sf_root() .. vim.g.sf.default_dir dir_path = dir_path:gsub("//", "/") - if dir_path:sub(1, 1) ~= "/" and dir_path:sub(1, 1) ~= "." then + if M.is_windows_os() then + dir_path = dir_path:gsub("\\", "/") + end + if dir_path:sub(1, 1) ~= "/" and dir_path:sub(1, 1) ~= "." and not M.is_windows_os() then dir_path = "/" .. dir_path end if dir_path:sub(-1) ~= "/" then