improvements for windows cmd line

This commit is contained in:
ray-x 2023-11-08 17:03:33 +11:00
parent 3b673f2560
commit 7b818ad49d
3 changed files with 15 additions and 7 deletions

View File

@ -6,7 +6,7 @@ local trace = util.trace
local getopt = require('go.alt_getopt') local getopt = require('go.alt_getopt')
local os_name = vim.loop.os_uname().sysname 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 local is_git_shell = is_windows
and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil) 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 if _GO_NVIM_CFG.run_in_floaterm or optarg['F'] then
local term = require('go.term').run local term = require('go.term').run
local cmdstr = table.concat(cmd, ' ') term({ cmd = cmd, autoclose = false })
term({ cmd = cmdstr, autoclose = false })
return cmd return cmd
end end
return M.runjob(cmd, runner, efm, args) return M.runjob(cmd, runner, efm, args)

View File

@ -1,6 +1,7 @@
local utils = require('go.utils') local utils = require('go.utils')
local api = vim.api local api = vim.api
local log = utils.log local log = utils.log
local is_windows = utils.is_windows()
local guihua_term = utils.load_plugin('guihua.lua', 'guihua.floating') local guihua_term = utils.load_plugin('guihua.lua', 'guihua.floating')
if not guihua_term then if not guihua_term then
utils.warn('guihua not installed, please install ray-x/guihua.lua for GUI functions') 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 opts.autoclose = true
end end
-- run in neovim shell -- run in neovim shell
local cmdstr = opts.cmd or 'go'
if type(opts.cmd) == 'table' then if type(opts.cmd) == 'table' then
opts.cmd = table.concat(opts.cmd, ' ') cmdstr = table.concat(opts.cmd, ' ')
end 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) utils.log(opts)
local buf, win, closer = guihua_term.floating_term(opts) local buf, win, closer = guihua_term.floating_term(opts)
@ -106,5 +115,5 @@ local term = function(opts)
return buf, win, closer return buf, win, closer
end end
-- term({ cmd = 'echo abddeefsfsafd', autoclose = false }) -- term({ cmd = { 'go', 'list' }, autoclose = false })
return { run = term, close = close_float_terminal } return { run = term, close = close_float_terminal }

View File

@ -3,7 +3,7 @@ local fn = vim.fn
local uv = vim.loop local uv = vim.loop
local os_name = uv.os_uname().sysname 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 local is_git_shell = is_windows
and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil) and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil)