olimorris / codecompanion.nvim

✨ AI-powered coding, seamlessly in Neovim. Supports Anthropic, Copilot, Gemini, Ollama and OpenAI LLMs
MIT License
772 stars 51 forks source link

[Bug]: fzf output hard to read #214

Closed Konfekt closed 4 weeks ago

Konfekt commented 4 weeks ago

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 = { {"junegunn/fzf"}, { "olimorris/codecompanion.nvim", dependencies = { { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate"}, "nvim-lua/plenary.nvim", "hrsh7th/nvim-cmp", { "stevearc/dressing.nvim", opts = {}, }, }, } }

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

Error messages

.

Log output

.

Health check output

No response

Describe the bug

This follows up on https://github.com/olimorris/codecompanion.nvim/issues/213

If FZF is installed, then the FZF window that opens after entering :CodeCompanionActions<cr> is unreadably even with fullscreen vim.

If https://github.com/ibhagwan/fzf-lua is installed, then it becomes readable in fullscreen, but still unreadable

grafik

if, say, the columwidth is, say, below 100 as shown below

Instead, ensure that the first column is always show and rather shorten the rightmost.

So the first step would be to add https://github.com/ibhagwan/fzf-lua as a dependency (which can optionally be replaced by telescope), and then ensure that at least the leftmost columns stays readable.

Reproduce the bug

Run

NVIM v0.11.0-dev-684+g53af02adb
Build type: RelWithDebInfo
LuaJIT 2.1.1724512491

Enter :CodeCompanionActions<cr>.

Final checks

olimorris commented 4 weeks ago

Firstly, I don't understand why you're not using the minimal.lua file that comes with the bug report or respecting the template.

Secondly, I cannot recreate your issue:

2024-09-12 11_20_33 - WezTerm

This was my minimal file:

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

-- Copilot adapter override
vim.env["CODECOMPANION_TOKEN_PATH"] = vim.fn.expand("~/.config")

-- 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 = {
  { "junegunn/fzf" },
  {
    "olimorris/codecompanion.nvim",
    dependencies = {
      { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
      "nvim-lua/plenary.nvim",
      "hrsh7th/nvim-cmp",
      "nvim-telescope/telescope.nvim",
      {
        "stevearc/dressing.nvim",
        opts = {},
      },
    },
    opts = {
      -- Refer to: https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/config.lua
      strategies = { -- Change the adapters as required
        chat = { adapter = "copilot" },
        inline = { adapter = "copilot" },
        agent = { adapter = "copilot" },
      },
      opts = {
        log_level = "DEBUG",
      },
    },
  },
}

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

-- setup Tree-sitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
  treesitter.setup({
    ensure_installed = { "lua", "markdown", "markdown_inline", "yaml" },
    highlight = { enable = true },
  })
end

-- Setup completion
local ok, cmp = pcall(require, "cmp")
if ok then
  cmp.setup({
    mapping = cmp.mapping.preset.insert({
      ["<C-b>"] = cmp.mapping.scroll_docs(-4),
      ["<C-f>"] = cmp.mapping.scroll_docs(4),
      ["<C-Space>"] = cmp.mapping.complete(),
      ["<C-e>"] = cmp.mapping.abort(),
      ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
    }),
  })
end
Konfekt commented 4 weeks ago

I thought mininal.lua to be minimal (and tried to keep my setup minimal). Could you try mine without the optional telescope dependency contained in yours?

Konfekt commented 4 weeks ago

It works fine if either fzf.vim is not there or telescope supplants it. So one could for example check for :FZF and try to ignore the FZF adaptions.

olimorris commented 4 weeks ago

Please try again with the minimal setup I shared. Run nvim --clean -u minimal.lua to launch Neovim. I can't recreate this issue.

Removing Telescope:

2024-09-12 11_48_02 - WezTerm

Removing Telescope and Dressing.nvim:

2024-09-12 11_50_48 - WezTerm@2x

Konfekt commented 4 weeks ago

Remove telescope, but not "stevearc/dressing.nvim".

Konfekt commented 4 weeks ago

I am using

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 = {
  { "junegunn/fzf" },
  {
    "olimorris/codecompanion.nvim",
    dependencies = {
      { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
      "nvim-lua/plenary.nvim",
      "hrsh7th/nvim-cmp",
      {
        "stevearc/dressing.nvim",
        opts = {},
      },
    },
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})
olimorris commented 4 weeks ago

I can't recreate this with your minimal.lua file:

2024-09-12 12_41_39 - WezTerm

I think the issue is on your end and with your config.

Konfekt commented 4 weeks ago

Thank you, indeed. $FZF_DEFAULT_OPTS contained --keep-right. How about ignoring this option for more reproducible behavior?

olimorris commented 4 weeks ago

$FZF_DEFAULT_OPTS is an FZF option. CodeCompanion has no support for junegunn/fzf.

Konfekt commented 4 weeks ago

This is a dressing.nvim issue?

Konfekt commented 4 weeks ago

Enlargening the actions window (shown in your above screencast) could also help.

olimorris commented 4 weeks ago

FZF...surely?

Konfekt commented 4 weeks ago

I wonder how FZF interferes if Codecompanion does not use it.

Another issue: Can you verify that selecting option 4, workflows, the focus of the popup window is lost?