numToStr / FTerm.nvim

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

Run custom command returns an error on Windows #46

Closed kishikaisei closed 2 years ago

kishikaisei commented 2 years ago

Running this command :lua require('FTerm').run('lazygit') (or anything in quotes) returns an empty window, with an error message on windows:

E5108: Error executing lua Vim:E475: Invalid argument: expected a String or List

image

numToStr commented 2 years ago

What's your fterm config?

kishikaisei commented 2 years ago

This is it right now for testing et al.

require'FTerm'.setup({
    -- Command to run inside the terminal. It could be a `string` or `table`
    -- cmd = os.getenv('pwsh'),

    -- Neovim's native window border. See `:h nvim_open_win` for more configuration options.
    border = 'rounded',

    -- Close the terminal as soon as shell/command exits.
    -- Disabling this will mimic the native terminal behaviour.
    auto_close = true,

    -- Highlight group for the terminal. See `:h winhl`
    hl = 'Normal',

    -- Transparency of the floating window. See `:h winblend`
    blend = 0,

    -- Object containing the terminal window dimensions.
    -- The value for each field should be between `0` and `1`
    dimensions = {
        height = 0.9, -- Height of the terminal window
        width = 0.9, -- Width of the terminal window
        x = 0.5, -- X axis of the terminal window
        y = 0.5, -- Y axis of the terminal window
    }
})

-- -- Example keybindings
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
map('n', '<A-g>', "<CMD>lua require('FTerm').run('lazygit')<CR>", opts)

vim.cmd('command! FTermOpen lua require("FTerm").open()')
vim.cmd('command! FTermClose lua require("FTerm").close()')
vim.cmd('command! FTermExit lua require("FTerm").exit()')
vim.cmd('command! FTermToggle lua require("FTerm").toggle()')
numToStr commented 2 years ago

Config looks fine to me. IDK what's the issue then as this doesn't happen on Linux. And I don't have access to any windows machine so I won't be able to fix this issue. If you can fix it that will be great and I'll be happy to assist you :)

atulpatildbz commented 2 years ago

I'm facing this issue on windows too.

numToStr commented 2 years ago

@atulpatildbz If you are able to fix the issue that would be much appreciated.

numToStr commented 2 years ago

@kishikaisei @atulpatildbz Does https://github.com/numToStr/FTerm.nvim/commit/c2a4c4bbd00da68d864683cd09a5d3a2b80de11d solve the issue?

Jesspu commented 2 years ago

I am getting this same error with this setup

`require('FTerm').setup({})

vim.api.nvim_create_user_command('FTermOpen', require('FTerm').open, { bang = true }) vim.api.nvim_create_user_command('FTermClose', require('FTerm').close, { bang = true })`

When I run :FTermOpen, I get the same error as above, and a blank floating window.

I have the latest version with the commit above.

Update: I actually just resolved this.

Had to change the setup step to require('FTerm').setup({cmd = 'cmd.exe'})

numToStr commented 2 years ago

Had to change the setup step to require('FTerm').setup({cmd = 'cmd.exe'})

I guess that must be the issue. The default value of cmd is os.getenv('SHELL') and I am not sure whether this is available or not on windows.

I am closing this for now. If anyone else having this issue please try to update cmd option in setup().