Bryley / neoai.nvim

Neovim plugin for intracting with GPT models from OpenAI
MIT License
558 stars 51 forks source link

Error "attempt to index field 'ui'" when running `:NeoAI<CR>` #11

Closed cyphersnake closed 1 year ago

cyphersnake commented 1 year ago

Installed by Packer.

Lua Config With Detailed config: ```lua ... use { 'Bryley/neoai.nvim', requires = { "MunifTanjim/nui.nvim", }, config = function() require("neoai").setup({ ui = { output_popup_text = "NeoAI", input_popup_text = "Prompt", width = 30, output_popup_height = 80, }, }) end, } ... ``` And without: ```lua ... use { 'Bryley/neoai.nvim', requires = { "MunifTanjim/nui.nvim", }, config = function() require("neoai").setup() end, } ... ``` the error is the same in both cases
Error executing Lua callback: .../nvim/site/pack/packer/start/neoai.nvim/lua/neoai/ui.lua:58: attempt to index field 'ui' (a n
il value)
stack traceback:
        .../nvim/site/pack/packer/start/neoai.nvim/lua/neoai/ui.lua:58: in function 'create_ui'
        ...are/nvim/site/pack/packer/start/neoai.nvim/lua/neoai.lua:49: in function 'toggle'
        ...are/nvim/site/pack/packer/start/neoai.nvim/lua/neoai.lua:78: in function 'smart_toggle'
        .../nvim/site/pack/packer/start/neoai.nvim/plugin/neoai.lua:4: in function <.../nvim/site/pack/packer/start/neoai.nvim
/plugin/neoai.lua:3>
Bryley commented 1 year ago

Hmmm it looks like there might be an issue with the setup function not being called correctly. Could you add a debug statement or something to verify that the setup function is being called correctly?

Maybe somthing like this?

...
use { 
    'Bryley/neoai.nvim',
    requires = {
        "MunifTanjim/nui.nvim",
    },
    config = function()
        vim.notify("Running NeoAI setup!")
        require("neoai").setup()
    end,
}
...
cyphersnake commented 1 year ago

Yes you're right, I called :lua require("neoai").setup()<CR> and the plugin worked, just move that line from the plugin configuration. Probably some problems with Packer, but for other plugins it calls config correctly. 🤔

Thanks for the help! Specifically my problem is solved, if it does not reproduce, then probably have a local nature and the issue can be closed