akinsho / toggleterm.nvim

A neovim lua plugin to help easily manage multiple terminal windows
GNU General Public License v3.0
4.21k stars 170 forks source link

[BUG] windows Custom Terminals fail #526

Closed ooing closed 8 months ago

ooing commented 8 months ago

Is there an existing issue for this?

Current Behavior

run ToggletermGitui
get error

Error executing Lua callback: .../nvim-data/lazy/toggleterm.nvim/lua/toggleterm/utils.lua:117: Invalid window id: 1020
stack traceback:
    [C]: in function 'nvim_set_option_value'
    .../nvim-data/lazy/toggleterm.nvim/lua/toggleterm/utils.lua:117: in function 'wo_setlocal'
    ...cal/nvim-data/lazy/toggleterm.nvim/lua/toggleterm/ui.lua:143: in function 'hl_term'
    ...im-data/lazy/toggleterm.nvim/lua/toggleterm/terminal.lua:492: in function 'open'
    ...im-data/lazy/toggleterm.nvim/lua/toggleterm/terminal.lua:504: in function 'toggle'
    C:/Users/tttttaa/AppData/Local/nvim/lua/config/toggleterm.lua:37: in function <C:/Users/tttttaa/AppData/Local/nvim/lua/config/toggleterm.lua:36>
local powershell_options = {
    shell = vim.fn.executable("pwsh") == 1 and "pwsh" or "powershell",
    shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;",
    shellredir = "-RedirectStandardOutput %s -NoNewWindow -Wait",
    shellpipe = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode",
    shellquote = "",
    shellxquote = "",
}

for option, value in pairs(powershell_options) do
    vim.opt[option] = value
end

require("toggleterm").setup({
    on_create = function()
        require("toggleterm").exec("clear")
    end,
    open_mapping = "<C-\\>",
    start_in_insert = true,
    direction = "float",
})

local Terminal = require("toggleterm.terminal").Terminal
local gitui = Terminal:new({
    cmd = "gitui",
    direction = "float",
    on_open = function()
        -- Stuff here
    end,
    hidden = true,
})
vim.api.nvim_create_user_command("ToggletermGitui", function()
    gitui:toggle()
end, { bang = true })

Expected Behavior

normal use

Steps To Reproduce

1 start neovim 2 run :ToggletermGitui

Environment

- OS: windows 10 
- neovim version: NVIM v0.9.4    Build type: RelWithDebInfo   LuaJIT 2.1.1696883897
- Shell:  powsershell

Anything else?

No response