AstroNvim / astrocommunity

A community repository of common plugin specifications
GNU General Public License v3.0
1.19k stars 240 forks source link

Completion crashes when `nvim-cmp` is disabled by community plugins #829

Closed ammuench closed 6 months ago

ammuench commented 6 months ago

Checklist

Neovim version (nvim -v)

v0.9.5

Operating system/version

PopOS 22.04 LTS, Kernel 6.8.0-76060800

Terminal/GUI

kitty

Describe the bug

Hello!

I just did a fresh setup of Astronvim v4, and was going through setting up a few different community plugins.

Had no issues with most of them until I wanted to try and setup mini-cmp. I also saw the same issue occur when trying to add coq-nvim

After adding them in the community.lua file and restarting, I'm presented with this error:

Failed to source `/home/amuench/.local/share/nvim/lazy/cmp-buffer/after/plugin/cmp_buffer.lua`

vim/_editor.lua:0: /home/amuench/.config/nvim/init.lua..nvim_exec2() called at /home/amuench/.config/nvim/init.lua:0../home/amuench/.local/share/nvim/lazy/cmp-buffer/after/plugin/cmp_buffer.lua: Vim(source):E5113: Error while calling lua chunk: ...l/share/nvim/lazy/cmp-buffer/after/plugin/cmp_buffer.lua:1: module 'cmp' not found:
    no field package.preload['cmp']
cache_loader: module cmp not found
cache_loader_lib: module cmp not found
    no file './cmp.lua'
    no file '/__w/neovim/neovim/.deps/usr/share/luajit-2.1/cmp.lua'
    no file '/usr/local/share/lua/5.1/cmp.lua'
    no file '/usr/local/share/lua/5.1/cmp/init.lua'
    no file '/__w/neovim/neovim/.deps/usr/share/lua/5.1/cmp.lua'
    no file '/__w/neovim/neovim/.deps/usr/share/lua/5.1/cmp/init.lua'
    no file './cmp.so'
    no file '/usr/local/lib/lua/5.1/cmp.so'
    no file '/__w/neovim/neovim/.deps/usr/lib/lua/5.1/cmp.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
    [C]: in function 'require'
    ...l/share/nvim/lazy/cmp-buffer/after/plugin/cmp_buffer.lua:1: in main chunk
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:485: in function <...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:484>
    [C]: in function 'xpcall'
    .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:113: in function 'try'
    ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:484: in function 'source'
    ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:443: in function 'source_runtime'
    ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:144: in function 'startup'
    ...uench/.local/share/nvim/lazy/lazy.nvim/lua/lazy/init.lua:112: in function 'setup'
    /home/amuench/.config/nvim/lua/lazy_setup.lua:1: in main chunk
    [C]: in function 'require'
    /home/amuench/.config/nvim/init.lua:18: in main chunk

# stacktrace:
  - vim/_editor.lua:0 _in_ **cmd**
  - lua/lazy_setup.lua:1
  - init.lua:18

The error still occurs even if you disable opts.features.cmp in astrocore.lua. I suspect its due to disabling the other cmp plugins, which seem to be required somewhere in the Astronvim init logic. The only way I got mini working was by just adding the plugin manually without disabling nvim-cmp. It technically works, but I assume we don't want to have multiple completion engines if only one is used.

If we did want a bandaid fix in the meantime, we could just remove

{ "hrsh7th/nvim-cmp", enabled = false },

from the respective plugins to ensure they do not cause any malfunctions

Steps to Reproduce

  1. Add mini-cmp to your community.lua file by adding
    { import = "astrocommunity.completion.mini-completion"}

    to the file

  2. Restart nvim
  3. Notice there is an error about Failed to source "/home/amuench/.local/share/nvim/lazy/cmp-buffer/after/plugin/cmp_buffer.lua" when starting and that completions do not work

Expected behavior

Completion plugins in the community repo should install without error

Screenshots

No response

Additional Context

No response

Uzaaft commented 6 months ago

@ammuench See if #842 doesn't fix this.

Uzaaft commented 6 months ago

Resolved the issue for me when testing with a clean tempalte + mini-completion

ammuench commented 6 months ago

Can confirm this works @Uzaaft! Thank you! Would you like me to update the coq-nvim plugin with the same fix?

Uzaaft commented 6 months ago

@ammuench I'll patch it in a seperate PR.