Skip to content

codecompanion-nvim does not install when blink-cmp is enabled #1423

@alv-around

Description

@alv-around

I have confirmed that this is a bug related to nvf

  • This is a bug, and not an user error or a support request. I understand that my issue will be closed if it is not a bug in nvf.
  • I have checked the issues tab and confirmed that my issue has not yet been reported. I understand that my issue will be closed if it is a duplicate.

Description

Hey! I am opening this issue, to give more visibility to #1076.

But in a nutshell, when having blink-cmp enabled trying to install codecompanion-nvim this fails. I havent' tried to installed with nvim-cmp this may as well fail. The more the reason to look into the topic 🕵️

The quickfix, as stated in #1076, is setting lazy.enable = false;, but this feels like a nuclear solution. Some better solutions would be:

  • enabling vim.lazy.plugins.codecompanion-nvim.lazy (quick-patch 🩹 )
  • Look more into the detail on what is causing the collision. I suppose that extending autocomplete like in here https://github.com/NotAShelf/nvf/pull/802/changes may do the fix. But not sure .. maybe is not blink-cmp at all 🤷

Installation Method

Home Manager Module (homeManagerModules.default)

Installation Method (Other)

No response

nvf Version

master

Reproduction steps

Here is my assistant.nix configuration:

{lib, ...}: {
  programs.nvf.settings.vim = {
    # FIX: The next line should be removed
    lazy.enable = false;

    assistant.codecompanion-nvim = {
      enable = true;
      setupOpts = {
        strategies = {
          chat = {adapter = "ollama";};
          inline = {adapter = "ollama";};
          agent = {adapter = "ollama";};
        };

        adapters = lib.generators.mkLuaInline ''
          {
            ollama = function()
              return require("codecompanion.adapters").extend("ollama", {
                env = {
                  url = "http://127.0..1:11434"
                },
                schema = {
                  model = {
                    default = "llama3.2:latest",
                  },
                },
              })
            end,
          }
        '';
      };
    };
  };
}

my blink-cmp config:

        # blink-cmp
        autocomplete.blink-cmp = {
          enable = true;
          friendly-snippets.enable = true;
          mappings = {
            # complete = "<S-Tab>";
            confirm = "<S-Tab>";
            next = "<C-j>";
            previous = "<C-k>";
          };
        };

Expected behavior

I should be able to install blink-cmp and codecompanion-nvim without disabling lazy-loading lazy.enable = false;

Actual Behavior

I have to disable lazy-loading ( lazy.enable = false;) to have codecompanion-nvim working

System Information

- system: `"x86_64-linux"`
 - host os: `Linux 6.18.7-arch1-1, Arch Linux, noversion, rolling`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.29.1`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/store/lxb3a59i0bncl2caq9bd39hkavjragjp-nixpkgs/nixpkgs`

Relevant log output

the `nvf-print-config` where blin-cmp and codecompanion-nvim are configured consecutively:

  require("blink.cmp").setup({["cmdline"] = {["keymap"] = {["<C-Space>"] = {"show",
"fallback"},
["<C-d>"] = {"scroll_documentation_up",
"fallback"},
["<C-e>"] = {"hide",
"fallback"},
["<C-f>"] = {"scroll_documentation_down",
"fallback"},
["<C-j>"] = {"select_next",
"show",
"fallback"},
["<C-k>"] = {"select_prev",
"fallback"},
["preset"] = "none"}},
["completion"] = {["documentation"] = {["auto_show"] = true,
["auto_show_delay_ms"] = 200},
["menu"] = {["auto_show"] = true}},
["fuzzy"] = {["implementation"] = "prefer_rust",
["prebuilt_binaries"] = {["download"] = false}},
["keymap"] = {["<C-Space>"] = {"show",
"fallback"},
["<C-d>"] = {"scroll_documentation_up",
"fallback"},
["<C-e>"] = {"hide",
"fallback"},
["<C-f>"] = {"scroll_documentation_down",
"fallback"},
["<C-j>"] = {"select_next",
"snippet_forward",
function(cmp)
  local line, col = unpack(vim.api.nvim_win_get_cursor(0))
  has_words_before = col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil

  if has_words_before then
    return cmp.show()
  end
end
,
"fallback"},
["<C-k>"] = {"select_prev",
"snippet_backward",
"fallback"},
["<S-Tab>"] = {"accept",
"fallback"},
["preset"] = "none"},
["sources"] = {["default"] = {"lsp",
"path",
"snippets",
"buffer"},
["providers"] = {}}})


end

do

  require("codecompanion").setup({["adapters"] = {
  ollama = function()
    return require("codecompanion.adapters").extend("ollama", {
      env = {
        url = "http://127.0..1:11434"
      },
      schema = {
        model = {
          default = "llama3.2:latest",
        },
      },
    })
  end,
}
,
["display"] = {["action_palette"] = {["height"] = 10,
["opts"] = {["show_default_actions"] = true,
["show_default_prompt_library"] = true},
["prompt"] = "Prompt ",
["provider"] = "default",
["width"] = 95},
["chat"] = {["auto_scroll"] = true,
["icons"] = {["pinned_buffer"] = "",
["watched_buffer"] = "👀 "},
["intro_message"] = "Welcome to CodeCompanion ✨! Press ? for options.",
["separator"] = "",
["show_header_separator"] = false,
["show_references"] = true,
["show_settings"] = false,
["show_token_count"] = true,
["start_in_insert_mode"] = false},
["diff"] = {["close_chat_at"] = 240,
["enabled"] = true,
["layout"] = "vertical",
["provider"] = "inline"},
["inline"] = {["layout"] = "vertical"}},
["opts"] = {["language"] = "English",
["log_level"] = "ERROR",
["send_code"] = true},
["strategies"] = {["agent"] = {["adapter"] = "ollama"},
["chat"] = {["adapter"] = "ollama"},
["inline"] = {["adapter"] = "ollama",
["keymaps"] = {["accept_change"] = {["n"] = "ga"},
["reject_change"] = {["n"] = "gr"}}}}})
  local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/codecompanion-nvim')
require("rtp_nvim").source_after_plugin_dir(path)

end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions