diff --git a/lua/go/asyncmake.lua b/lua/go/asyncmake.lua index 68e82c8..d4d85ca 100644 --- a/lua/go/asyncmake.lua +++ b/lua/go/asyncmake.lua @@ -6,7 +6,7 @@ local trace = util.trace local getopt = require('go.alt_getopt') local os_name = vim.loop.os_uname().sysname -local is_windows = os_name == 'Windows' or os_name == 'Windows_NT' +local is_windows = os_name == 'Windows' or os_name == 'Windows_NT' or os_name:find('MINGW64_NT') local is_git_shell = is_windows and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil) @@ -208,8 +208,7 @@ function M.make(...) if _GO_NVIM_CFG.run_in_floaterm or optarg['F'] then local term = require('go.term').run - local cmdstr = table.concat(cmd, ' ') - term({ cmd = cmdstr, autoclose = false }) + term({ cmd = cmd, autoclose = false }) return cmd end return M.runjob(cmd, runner, efm, args) diff --git a/lua/go/term.lua b/lua/go/term.lua index 537e3b6..44ad36f 100644 --- a/lua/go/term.lua +++ b/lua/go/term.lua @@ -1,6 +1,7 @@ local utils = require('go.utils') local api = vim.api local log = utils.log +local is_windows = utils.is_windows() local guihua_term = utils.load_plugin('guihua.lua', 'guihua.floating') if not guihua_term then utils.warn('guihua not installed, please install ray-x/guihua.lua for GUI functions') @@ -93,10 +94,18 @@ local term = function(opts) opts.autoclose = true end -- run in neovim shell + local cmdstr = opts.cmd or 'go' if type(opts.cmd) == 'table' then - opts.cmd = table.concat(opts.cmd, ' ') + cmdstr = table.concat(opts.cmd, ' ') end - opts.title = opts.title or opts.cmd:sub(1, win_width - 4) + -- convert to string for linux like systems + if not is_windows then + opts.cmd = cmdstr + end + + opts.title = opts.title or cmdstr + assert(opts.title ~= nil, 'title is nil' .. cmdstr) + opts.title = (opts.title):sub(1, win_width - 4) utils.log(opts) local buf, win, closer = guihua_term.floating_term(opts) @@ -106,5 +115,5 @@ local term = function(opts) return buf, win, closer end --- term({ cmd = 'echo abddeefsfsafd', autoclose = false }) +-- term({ cmd = { 'go', 'list' }, autoclose = false }) return { run = term, close = close_float_terminal } diff --git a/lua/go/utils.lua b/lua/go/utils.lua index 7a12b11..0ee69ee 100644 --- a/lua/go/utils.lua +++ b/lua/go/utils.lua @@ -3,7 +3,7 @@ local fn = vim.fn local uv = vim.loop local os_name = uv.os_uname().sysname -local is_windows = os_name == 'Windows' or os_name == 'Windows_NT' +local is_windows = os_name == 'Windows' or os_name == 'Windows_NT' or os_name:find('MINGW') local is_git_shell = is_windows and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil)