ChatGPT.nvim
ChatGPT.nvim copied to clipboard
Error: attempt to index field 'popup_layout' (a nil value)
Hi folks, after installing the plugin via Packer, I am getting the following error on running :ChatGPT
command
Error executing Lua callback: ...acker/start/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:47: attempt to index field 'popup_layout' (a
nil value)
stack traceback:
...acker/start/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:47: in function 'init'
...packer/start/ChatGPT.nvim/lua/chatgpt/common/classes.lua:88: in function 'new'
...acker/start/ChatGPT.nvim/lua/chatgpt/flows/chat/init.lua:13: in function 'open_chat'
...nvim/site/pack/packer/start/ChatGPT.nvim/lua/chatgpt.lua:34: in function 'openChat'
...m/site/pack/packer/start/ChatGPT.nvim/plugin/chatgpt.lua:2: in function <...m/site/pack/packer/start/ChatGPT.nvim/plugin/ch
atgpt.lua:1>
Packer Installation snippet:
use({
"jackMort/ChatGPT.nvim",
config = function()
require("chatgpt").setup()
end,
requires = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
})
If anyone familiar with the issue, kindly help. Thanks in advance : )
I guess it came from this commit: 1f69ba
@erlonbie seeing same issue in earlier commits as well ( tried randomly till 98764f0
), guessing it's something specific to my setup 🤔
I had the same issue and it turns out that probably there was some broken change in config. I used these options in my config:
{
chat = {
keymaps = {
close = { '<C-q>' },
},
},
}
And the problem here was that close
is a table. Making it just a string fixed the issue. Probably you have the same problem having custom keymaps defined as tables.
but @kuznetsss I haven't set any custom config specific to the plugin yet. As the snippet in packer is:
use({
"jackMort/ChatGPT.nvim",
config = function()
require("chatgpt").setup()
end,
requires = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
})
Am assuming it will be using the default configuration.
@RitickMadaan I just tried to run it with empty options and it worked fine for me.
I was getting this error when trying to run with the OPENAI_API_KEY
environment var. Switching to using api_key_cmd
made it go away.
If you just want to test you can stick this in your neovim config.
require("chatgpt").setup({
api_key_cmd = "echo my_key"
})
I was getting this error when trying to run with the
OPENAI_API_KEY
environment var. Switching to usingapi_key_cmd
made it go away.If you just want to test you can stick this in your neovim config.
require("chatgpt").setup({ api_key_cmd = "echo my_key" })
I confirm your workaround worked @michaelnew , thanks.
I am getting this error with a new install of the plugin (Feb 2024). The dependencies are installed, I'm not using a custom config other than providing access to my API key.
attempt to index field 'popup_layout' (a nil value)
stack traceback:
...nvim/bundle/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:52: in function 'init'
.../nvim/bundle/ChatGPT.nvim/lua/chatgpt/common/classes.lua:88: in function 'new'
...nvim/bundle/ChatGPT.nvim/lua/chatgpt/flows/chat/init.lua:13: in function 'open_chat'
.../edmund/.config/nvim/bundle/ChatGPT.nvim/lua/chatgpt.lua:34: in function 'openChat'
...mund/.config/nvim/bundle/ChatGPT.nvim/plugin/chatgpt.lua:2: in function <...mund/.config/nvim/bundle/ChatGPT.nvim/plugin/chatgpt.lua:1>