echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.47k stars 175 forks source link

mini.statusline: vim.diagnostic.is_enabled null reference #901

Closed tommitah-heeros closed 1 month ago

tommitah-heeros commented 1 month ago

Contributing guidelines

Module(s)

mini.statusline

Description

mini.statusline attempts to use the vim.diagnostic.is_enabled but it seems like this is a property that doesn't exist on vim.diagnostic. I'm fairly unfamiliar with the diagnostic api and a quick :h vim.diagnostic didn't produce anything for is_enabled. Leads me to think this call is just an "inverted" version from vim.diagnostic.is_disabled.

source: statusline.lua:648

if vim.fn.has('nvim-0.10') == 1 then
  H.diagnostic_is_disabled = function(_) return not vim.diagnostic.is_enabled({ bufnr = 0 }) end

Neovim version

0.10

Steps to reproduce

open file and navigate it

Expected behavior

-

Actual behavior

statusline crashes and produces an error notification: error executing lua .../share/nvim/lazy/mini.statusline/lua/mini/statusline.lua:649 attempt to call field 'is_enabled' (a nil value)

tommitah-heeros commented 1 month ago

Switched it to

if vim.fn.has('nvim-0.10') == 1 then
  H.diagnostic_is_disabled = function(_) return vim.diagnostic.is_disabled({ bufnr = 0 }) end

Worked, I'll see if I have time to create a PR for this.

tommitah-heeros commented 1 month ago

Ah, looks like I was running a neovim 0.10 build from an ancient commit, pulling that upstream fixed this for me.

echasnovski commented 1 month ago

Ah, looks like I was running a neovim 0.10 build from an ancient commit, pulling that upstream fixed this for me.

Yes, vim.diagnostic.is_enabled() is a (very) late addition to Neovim 0.10, but it is present in released version.

ngortheone commented 3 weeks ago

Thanks. I had this issue after an update recently and upgrading neovim helped