Robitx / gp.nvim

Gp.nvim (GPT prompt) Neovim AI plugin: ChatGPT sessions & Instructable text/code operations & Speech to text [OpenAI]
MIT License
537 stars 49 forks source link

bug: gp checkhealth gp.deprecated #105

Closed dostoievsky closed 4 months ago

dostoievsky commented 4 months ago
    if #gp._deprecated > 0 then
        local msg = "deprecated config option(s) in setup():"
        for _, v in ipairs(gp._deprecated) do
            msg = msg .. "\n\n- " .. v.msg
        end
        vim.health.warn(msg)
    else
        vim.health.ok("no deprecated config options")
    end

throws:

gp: require("gp.health").check()

- ERROR Failed to run healthcheck for "gp" plugin. Exception:
  function health#check, line 25
  Vim(eval):E5108: Error executing lua ~/.config/nvim/plugged/gp.nvim/lua/gp/health.lua:72: attempt to get length of field '_deprecated' (a nil value)
  stack traceback:
~/.config/nvim/plugged/gp.nvim/lua/gp/health.lua:72: in function 'check'
  [string "luaeval()"]:1: in main chunk

Removing it makes the checks run ok:

gp: require("gp.health").check()

gp.nvim checks ~
- OK require('gp') succeeded
- ERROR require('gp').setup() has not been called
- ERROR require('gp').setup({openai_api_key: ???}) is not set: nil
- OK curl is installed
- OK grep is installed
- OK ln is installed
- WARNING sox is not installed

it is throwing some errors that I will yet find a way to manage, but I found the error on checkhealth strange and decided to report here.

Robitx commented 4 months ago

Hey,
sorry for late response, I've been away for few weeks.

gp._deprecated is being set inside the setup function and since setup hasn't been called in this case

- ERROR require('gp').setup() has not been called
- ERROR require('gp').setup({openai_api_key: ???}) is not set: nil

it troughs this error. Will fix.