numToStr / FTerm.nvim

:fire: No-nonsense floating terminal plugin for neovim :fire:
MIT License
721 stars 24 forks source link

FTerm crashes on Windows due to latest commit #64

Closed figurae closed 1 year ago

figurae commented 1 year ago

Hi! I mean a58dc7a5cd1b9a55d1cdf5e869d3986b9f188e86. I tried setting cmd in my require'FTerm'.setup(), but it didn't work because it always asserts os.getenv('SHELL') regardless of what I set cmd to. Reverting line 26 in utils.lua makes it work again.

numToStr commented 1 year ago

I am really sorry about that. https://github.com/numToStr/FTerm.nvim/commit/db3bf919c068101195813692dbe95b3d9bb766b2 should fix the issue, but make sure to change the config.cmd

figurae commented 1 year ago

Thanks, everything's fine now. But it works regardless of config.cmd in my init, It works without it, and it works when set to nil (which is what it was before since Windows doesn't have $SHELL).

Lindenbyte commented 1 year ago

Also experienced similar effects on Windows where I got the following error and needed to set config.cmd explicitly to point to PowerShell.exe. (Tried cmd.exe as well but didn't change the result or error)

Error on any FTerm function: [FTerm] $SHELL is not present! Please provide a shell ('config.cmd') to use. Config: require('FTerm').setup({ cmd = 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe' })

Edit: Can also add that neither nil or leaving config.cmd by default changed anything and would give the same error.

Don't know if this would be of any interesting to include in default setup, but decided to let you guys know of my experience just in case. 👍

adelarsq commented 1 year ago

It's possible also to configure a default shell based on the SO:

    if has('unix')
        let s:uname = system("echo -n \"$(uname)\"")
        if !v:shell_error && s:uname ==? 'Linux'
            let g:sysop='linux'
        elseif (system('uname') ==? "Darwin\n")
            let g:sysop='mac'
        else
            let g:sysop='unix'
        endif
    elseif has('win32') || has('win64')
        let g:sysop='win'
    else
        let g:sysop='undefined'
    endif

lua << EOF
require'FTerm'.setup({
    ft = 'FTerm',
    cmd = vim.g.sysop == "win" and "pwsh" or "zsh",
    border = 'single',
    auto_close = true,
    hl = 'Normal',
    blend = 0,
    dimensions = {
        height = 0.8,
        width = 0.8,
        x = 0.5,
        y = 0.5,
    },
    on_exit = nil,
    on_stdout = nil,
    on_stderr = nil,
})
EOF