folke / lazy.nvim

💤 A modern plugin manager for Neovim
https://lazy.folke.io/
Apache License 2.0
14.68k stars 353 forks source link

bug: Lazy autocmds error: attempt to compare nil with number #1564

Closed MauricioBorawski closed 4 months ago

MauricioBorawski commented 4 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478

Operating system/version

arch-linux

Describe the bug

When opening any file this error shows up

 Error  11:12:48 AM msg_show.lua_error Error detected while processing function <SNR>41_NetrwBrowseChgDir[194]..<SNR>41_NetrwEditFile[7]..BufReadPost Autocommands for "*":
11:12:48 AM msg_show Error executing lua callback: .../share/nvim/lazy/LazyVim/lua/lazyvim/config/autocmds.lua:122: attempt to compare nil with number
stack traceback:
    .../share/nvim/lazy/LazyVim/lua/lazyvim/config/autocmds.lua:122: in function <.../share/nvim/lazy/LazyVim/lua/lazyvim/config/autocmds.lua:121>
    vim/filetype.lua: in function ''
    vim/filetype.lua: in function 'match'
    /usr/share/nvim/runtime/filetype.lua:14: in function </usr/share/nvim/runtime/filetype.lua:10>

After some debugging I notice that the error comes from changing my colorscheme

 return {
  { "shaunsingh/nord.nvim" },
  {
    "LazyVim/LazyVim",
    opts = {
      colorscheme = "nord",
    },
  },
}

After deleting the colorscheme option the errors doesn't show up (ofc I have no colors on my editor :sweat_smile: )

Also I have tried using the default lazy.vim configuration and everything works fine, so I suspect that this is a problem with my configuration

Also I share the checkhealth promp if that's usefull

lazy.nvim ~
- OK {git} `version 2.45.2`
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found

LazyVim ~
- OK Using Neovim >= 0.9.0
- OK `git` is installed
- OK `rg` is installed
- OK `fd` is installed
- WARNING `lazygit` is not installed

Steps To Reproduce

This is my repo with my config

  1. Clone repo
  2. Install all packages
  3. Open any file with nvim

Expected Behavior

The error not to show up

folke commented 4 months ago

Fixed in LAzyVim. Will make a new release later

varo6 commented 4 months ago

I'm having the same problem with colorscheme.lua file. My colorscheme file is exactly like described by mauricio, it works fine if I don't load it, and lazy checkhealth is fine.

folke commented 4 months ago

just made a new release

dylandjian commented 4 months ago

I'm having the same issue as well ! I'm also having trouble finding how to downgrade my lazy.nvim version, any tips on that? Also when will the release be available? Thanks!

max397574 commented 4 months ago

the release is available ig https://github.com/LazyVim/LazyVim/releases/tag/v12.20.1

dylandjian commented 4 months ago

Indeed it has been released but even with the new commit, I'm getting the nil error. After debugging for a bit, I found that vim.g.bigfile_size is nil. I don't really understand well lua and the project to understand why it is nil sadly, especially when it seems defined properly in options.lua...

Do you want me to make a new issue or do you have an idea of what could be in play? Thanks!

max397574 commented 4 months ago

well perhaps open an issue in lazyvim/lazyvim repo

folke commented 4 months ago

@dylandjian that's just not possible. Are you really using LazyVim? Or did you copy/paste some things from LazyVim? Are you loading options manually somehow?

varo6 commented 4 months ago

I may say that even with the last release I had the same problem. Still all configuration was ok until I wanted to load colorscheme.lua file.

Loaded my colorscheme as the example given in lazy.folke.io (and lazy=false) and works great with every theme I use, thanks @folke for your help 🙂. I'm no longer using LazyVim/LazyVim but I tried and loads fine if I split colorscheme and lazyvim config. Idk if you need to load your theme using lazyvim plugin but this is what it worked for me. @dylandjian

  {
    "folke/tokyonight.nvim",
    lazy = false, -- make sure we load this during startup if it is your main colorscheme
    priority = 1000, -- make sure to load this before all the other start plugins
    config = function()
      -- load the colorscheme here
      vim.cmd([[colorscheme tokyonight]])
    end,
  },
dylandjian commented 4 months ago

Thanks for the fix @varo6 :heart:

For a bit more context, I was using LazyVim/LazyVim for the theme only too, I just removed it and used what @varo6 sent ! Thanks again

folke commented 4 months ago

Seriously guys, why didn't you tell from the start? Would have helped not to waste that much time on this.