numToStr / FTerm.nvim

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

[Bug?] "FTerm: setup() is optional..." On call to fterm.new() #62

Closed distek closed 2 years ago

distek commented 2 years ago

Hello!

Having a small issue.

I have the following function:

function LazygitFloat()
    local cfg = {
        ft = 'lazygit',
        cmd = "lazygit",
        auto_close = true,
        dimensions = {
            height = 0.8, -- Height of the terminal window
            width = 0.8, -- Width of the terminal window
        },
    }

    local term = require('FTerm').new(cfg)

    if not term then
        return
    end

    term.open()
end

When I attempt to run this, I get this message:

FTerm: setup() is optional. Please remove it!

What am I doing wrong in the above function to get this?

If I just run require('FTerm').run("lazygit"), it works fine enough, but I am unable to customize the options in this case.

small update: from init.lua for FTerm

---Creates a custom terminal
---@param cfg Config
---@return Term
function M:new(cfg)
    print(cfg)
    return Term:new():setup(cfg)
end

I'm getting a nil for the print(cfg) I added. I must be doing something wrong.

Any help is greatly appreciated.

Thanks!

distek commented 2 years ago

Colons.

function LazygitFloat()
    local cfg = {
        ft = 'lazygit',
        cmd = "lazygit",
        auto_close = true,
        dimensions = {
            height = 0.9, -- Height of the terminal window
            width = 0.9, -- Width of the terminal window
        },
    }

    local term = require('FTerm'):new(cfg)

    term:open()
end

This works exactly as intended.

Closing.