rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
3k stars 80 forks source link

error get when calling `Telescope Notify`: attempt to index local `config` (a nil value) #102

Closed milanglacier closed 2 years ago

milanglacier commented 2 years ago

I am at Telescope version: commit d3aad43b3fcf707052f7dd8a7c7072fa69773f3c (latest at the time I post the issue) and nvim-notify version b517277b2782b9fe20f64220435b8b6f9f02f840 (latest at the time I post the issue)

nvim version is

NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@HMBRW-A-001-M1-004.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.7.0/share/nvim"

Run :checkhealth for more info

minimal config:

--if lazy load nvim-notify and telescope-nvim:
--vim.cmd [[packadd nvim-notify]]
--vim.cmd [[packadd telescope-nvim]]
require('telescope').setup {}
    require('notify').setup {
        max_width = 45,
        max_height = 20,
    }
vim.notify = require("notify")
require('telescope').load_extension 'notify'

vim.notify("a message", vim.log.levels.WARN)

step to reproduce:

call Telescope notify and get the following error

Error executing vim.schedule lua callback: ...ack/packer/opt/nvim-notify/lua/notify/render/default.lua:38: attempt to index local 'config' (a nil value)
stack traceback:
..ack/packer/opt/nvim-notify/lua/notify/render/default.lua:38:in function 'render'
.acker/opt/nvim-notify/lua/notify/service/buffer/init.lua:102:in function 'render'
..ker/opt/nvim-notify/la/telescope/_extensions/notifv.lua:94:in function
"define_preview'
...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:386:infunction'preview'
.pack/packer/opt/telescope.nvim/lua/telescope/pickers.lua:1075: in function
'refresh_previewer'
.pack/packer/opt/telescope.nvim/lua/telescope/pickers.lua:1024: in function
'set_selection'
..pack/packer/opt/telescope.nvim/lua/telescope/pickers.lua:1360: in function
do_ selection'
..pack/packer/opt/telescope.nvim/lua/telescope/pickers.lua:1322: in function
vim/_editor.lua: in function <vim/ editor.lua:0>

update: after some debug work, this bug happens after commit 2cfd425

milanglacier commented 2 years ago

after some debug work, this bug happens after commit 2cfd425

kiyonlin commented 2 years ago

same here 😄

milanglacier commented 2 years ago

I think the reason is at here

https://github.com/rcarriga/nvim-notify/blob/b517277b2782b9fe20f64220435b8b6f9f02f840/lua/telescope/_extensions/notify.lua#L93

now NotificationBuf needs to get a config key from the table passed in, but we don't pass to it.

We need to find a way to pass user_config like what defined here:

https://github.com/rcarriga/nvim-notify/blob/b517277b2782b9fe20f64220435b8b6f9f02f840/lua/notify/init.lua#L159

to the telescope extension calling.

rcarriga commented 2 years ago

Thanks for report :smile: Should be working in latest