Closed PMassicotte closed 7 months ago
Same here. This plugin is the single most fragile plugin among all neovim plugins because it breaks after every update 😆 Do people ever test their stuff before plugging it in the PR?
Same error using bw
(which is the Bitwarden command line client) in plugin custom config like this:
api_key_cmd = bw get password <uniqueid>
results in attempt to concatenate filed OPENAI_API_KEY (a nil value).
uniqueid is an alphanumeric string without spaces
same here using builtin mac keychain
security find-generic-password -s NVIM_CHAT_GPT_TOKEN -w
same here using gopass(compatible with pass)
return {
"jackMort/ChatGPT.nvim",
event = "VeryLazy",
config = function()
require("chatgpt").setup({
api_key_cmd = "gopass show -o -f chatgpt/apikey",
})
end,
dependencies = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
keys = {
{ "<leader>Cc", "<cmd>ChatGPT<cr>", desc = "ChatGPT" },
},
}
I can confirm that https://github.com/singular0/ChatGPT.nvim/commit/3d31eacf98b00cc3fd944ef5526be6d738515649 fixed the issue
A PR has been submitted under https://github.com/jackMort/ChatGPT.nvim/pull/301
Sorry for not testing enough on the api_key_cmd
option, I will try to find a workaround and test relevant options in nvim config before submitting another patch. Sorry for the inconveniences again.
Edits:
api_key_cmd
rather than the environment variable. I will dig around when I have the time.loadConfigFromCommand
function runs the background job in async mode (as this line indicates) using plenary. It should be running in sync mode instead and by changing :start()
here to :sync()
, the config can now be read from background jobs. This is what #300 by @you-n-g is suggesting. For now, #301 works by simply changing the scope (which avoids the async problem altogether) and #300 should fix such problems in the long run.:sync()
function defaults to a timeout of 5 seconds, it might not be enough for the api_key_cmd
to return the API key (most password manager requires entering a master password or uses any other means of authentication, at least the first time). Therefore, I would suggest using :sync(20000)
, i.e., wait for 20 seconds.loadApiKey
function (#301) might have inadvertently led to #303 and #304. Fundamentally, it's still an omission on my part for not taking these cases into consideration.
Looks like the last commit (aa8a969) is breaking something.
I am getting this error:
https://github.com/jackMort/ChatGPT.nvim/blob/aa8a96901662199857e93dd9a93e262e0d36be4c/lua/chatgpt/api.lua#L267
FWIW, here is my config: