olimorris / codecompanion.nvim

✨ A Copilot Chat experience in Neovim. Supports Anthropic, Ollama and OpenAI LLMs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: ollama list is called, even if ollama is not used

sevvie opened this issue · comments

Your minimal.lua config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- Your CodeCompanion setup
local plugins = {
  {
    "olimorris/codecompanion.nvim",
    dependencies = {
      { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate"},
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
      {
        "stevearc/dressing.nvim",
        opts = {},
      },
    },
    config = function()
      require("codecompanion").setup({
        strategies = { -- Change the adapters as required
          chat = "openai",
          inline = "openai",
        },
      })
    end,
  }
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
  treesitter.setup({
    ensure_installed = "all",
    ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
    highlight = { enable = true },
  })
end

Error messages

Error: could not connect to ollama app, is it running?

Health check output

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

codecompanion.nvim report ~

  • Log file: /home/sev/.repro/state/nvim/codecompanion.log
  • OK nvim-treesitter installed
  • OK plenary.nvim installed
  • OK dressing.nvim installed
  • WARNING edgy.nvim not found
  • OK curl installed

Log output

Error: could not connect to ollama app, is it running?

Describe the bug

I would expect, if I'm not using ollama at all, for CodeCompanion to not attempt to call io.popen 'ollama list' on line 4 of lua/codecompanion/adapters/ollama.lua, or at least expect and ignore the Error log message.

Instead, it draws the error text into my window, wherever the cursor is, requiring a Ctrl-L to redraw every time I open nvim.

2024-04-23-165508_463x202_scrot

Reproduce the bug

  1. Install CodeCompanion exactly as recommended, even with the minimal.lua config
  2. Open an existing file

Final checks

  • I have made sure this issue exists in the latest version of the plugin
  • I have tested with the minimal.lua config file above and still get the issue
commented

Thanks for spotting this! Such a dumb mistake on my part. Fix should improve performance too.