folke / noice.nvim

💥 Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.
Apache License 2.0
3.95k stars 88 forks source link

bug: `health` error and `backend` field not being processed. #817

Closed DrKJeff16 closed 1 month ago

DrKJeff16 commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.11.0-dev-35+g666911be9

Operating system/version

Arch Linux (Linux 6.9.1-zen1-1-zen)

Describe the bug

Backend Error

When opening nvim, I get a notification for the following error:

 noice.nvim  ERROR ...f16/.local/share/nvim/lazy/Noice/lua/noice/view/init.lua:63: attempt to concatenate field 'backend' (a boolean value)

Note: A more detailed log from noice.log tells:

[...]
mar 21 may 2024 11:03:31
...f16/.local/share/nvim/lazy/Noice/lua/noice/view/init.lua:63: attempt to concatenate field 'backend' (a boolean value)

stack traceback:
        [C]: in function 'pcall'
        ...f16/.local/share/nvim/lazy/Noice/lua/noice/util/call.lua:144: in function '__concat'
        ...f16/.local/share/nvim/lazy/Noice/lua/noice/view/init.lua:63: in function 'get_view'
        ...local/share/nvim/lazy/Noice/lua/noice/message/router.lua:54: in function 'add'
        ...local/share/nvim/lazy/Noice/lua/noice/message/router.lua:106: in function 'setup'
        ...drjeff16/.local/share/nvim/lazy/Noice/lua/noice/init.lua:22: in function <...drjeff16/.local/share/nvim/lazy/Noice/lua/noice/init.lua:19>
        [C]: in function 'xpcall'
        ...f16/.local/share/nvim/lazy/Noice/lua/noice/util/call.lua:149: in function 'try'
        ...drjeff16/.local/share/nvim/lazy/Noice/lua/noice/init.lua:19: in function <...drjeff16/.local/share/nvim/lazy/Noice/lua/noice/init.lua:18>

Health Error

When re-sourcing my config for Noice, before Noice features dying, I get the following error:

E5108: Error executing lua: vim/_editor.lua:431: nvim_exec2(): Vim(luafile):E5113: Error while calling lua chunk: ...jeff16/.local/share/nvim/lazy/Noice/lua/noice/health.lua:211: bad argument #1 to getinfo' (function or level expected)
stack traceback:
        [C]: in function 'getinfo'
        ...jeff16/.local/share/nvim/lazy/Noice/lua/noice/health.lua:211: in function 'get_source'
        ...jeff16/.local/share/nvim/lazy/Noice/lua/noice/health.lua:189: in function 'check'
        ...drjeff16/.local/share/nvim/lazy/Noice/lua/noice/init.lua:14: in function 'setup'
        lua/lazy_cfg/noice/init.lua:210: in main chunk
        [C]: in function 'nvim_exec2'
        vim/_editor.lua:431: in function 'cmd'
        /home/drjeff16/.config/nvim/init.lua:92: in function </home/drjeff16/.config/nvim/init.lua:87>
stack traceback:
        [C]: in function 'nvim_exec2'
        vim/_editor.lua:431: in function 'cmd'
        /home/drjeff16/.config/nvim/init.lua:92: in function </home/drjeff16/.config/nvim/init.lua:87>

Steps To Reproduce

Backend

  1. Use the configuration laid out in the README, including personal customizations.
  2. Restart nvim.

    Health

  3. Use the configuration laid out in the README, including personal customizations.
  4. Restart nvim.
  5. Source the file containing these configurations after opening nvim (:luafile %).

Expected Behavior

In escense, for Noice to work properly. These configurations worked for me some time befor v0.11.0...

Repro

--- vim:sw=4:ts=4:sts=4:et:ai:ci:pi:sta:si:ru:ls=2:stal=2:nu:

--- NOTE: I have an extremely modular config for nearly every plugin I install,
---       so this is my best shot at trying to replicate thousands of
---       lines of code. Any questions I can provide answers for I shall
---       respond to as best I can.

--- NOTE: Also aplogies in advance if I overlooked something.

-- Set installation dir for `Lazy`.
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'

-- Install `Lazy` automatically.
if not vim.uv.fs_stat(lazypath) then
    vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', lazypath })
end

-- Add `Lazy` to runtimepath
vim.opt.rtp:prepend(lazypath)

local Lazy = require('lazy')

local noice_src = function()
    local Noice = require('noice')
    local Util = require('noice.util')

---@type NoiceConfig
local Opts = {
    cmdline = {
        enabled = true,
        ---@type 'cmdline_popup'|'cmdline'
        view = 'cmdline_popup',
        ---@type NoiceFormatOptions
        format = {
            -- conceal: (default=true) This will hide the text in the cmdline that matches the pattern.
            -- view: (default is cmdline view)
            -- opts: any options passed to the view
            -- icon_hl_group: optional hl_group for the icon
            -- title: set to anything or empty string to hide
            cmdline = { pattern = "^:", icon = "", lang = "vim" },
            search_down = { kind = "search", pattern = "^/", icon = " ", lang = "regex" },
            search_up = { kind = "search", pattern = "^%?", icon = " ", lang = "regex" },
            filter = { pattern = "^:%s*!", icon = "$", lang = "bash" },
            lua = { pattern = { "^:%s*lua%s+", "^:%s*lua%s*=%s*", "^:%s*=%s*" }, icon = "", lang = "lua" },
            help = { pattern = "^:%s*he?l?p?%s+", icon = "" },
            input = {}, -- Used by input()
            -- lua = false, -- to disable a format, set to `false`
        },
    },
    messages = {
        -- NOTE: If you enable messages, then the cmdline is enabled automatically.
        -- This is a current Neovim limitation.
        enabled = true,  -- enables the Noice messages UI
        view = "mini",   -- default view for messages
        view_error = "notify", -- view for errors
        view_warn = "mini", -- view for warnings
        view_history = true, -- view for :messages
        view_search = true, -- view for search count messages. Set to `false` to disable
    },
    popupmenu = {
        enabled = true, -- enables the Noice popupmenu UI
        ---@type 'nui'|'cmp'
        backend = 'nui', -- backend to use to show regular cmdline completions
        -- Icons for completion item kinds (see defaults at noice.config.icons.kinds)
        ---@type NoicePopupmenuItemKind|false
        kind_icons = {}, -- set to `false` to disable icons
    },
    -- default options for require('noice').redirect
    -- see the section on Command Redirection
    ---@type NoiceRouteConfig
    redirect = {
        view = 'popup',
        filter = { event = 'msg_show' },
    },
    commands = {
        history = {
            -- options for the message history that you get with `:Noice`
            view = "split",
            opts = { enter = true, format = "details" },
            filter = {
                any = {
                    { event = "notify" },
                    { error = true },
                    { warning = true },
                    { event = "msg_show", kind = { "" } },
                    { event = "lsp",      kind = "message" },
                },
            },
        },
        -- :Noice last
        last = {
            view = "popup",
            opts = { enter = true, format = "details" },
            filter = {
                any = {
                    { event = "notify" },
                    { error = true },
                    { warning = true },
                    { event = "msg_show", kind = { "" } },
                    { event = "lsp",      kind = "message" },
                },
            },
            filter_opts = { count = 1 },
        },
        -- :Noice errors
        errors = {
            -- options for the message history that you get with `:Noice`
            view = "notify",
            opts = { enter = true, format = "details" },
            filter = { error = true },
            filter_opts = { reverse = true },
        },
    },
    notify = {
        enabled = true,
        view = 'notify',
    },
    lsp = {
        progress = {
            enabled = true,
            -- Lsp Progress is formatted using the builtins for lsp_progress. See config.format.builtin
            -- See the section on formatting for more details on how to customize.
            --- @type NoiceFormat|string
            format = "lsp_progress",
            --- @type NoiceFormat|string
            format_done = "lsp_progress_done",
            throttle = 1000 / 30, -- frequency to update lsp progress message
            view = "mini",
        },
        -- override markdown rendering so that **cmp** and other plugins use **Treesitter**
        override = {
            ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
            ["vim.lsp.util.stylize_markdown"] = true,
            ["cmp.entry.get_documentation"] = true,
        },
        hover = {
            enabled = true,
            silent = false,
            view = 'hover',
            ---@type NoiceViewOptions
            opts = {},
        },
        signature = {
            enabled = true,
            auto_open = {
                enabled = true,
                trigger = true,
                luasnip = true,
                throttle = 50,
            },
            view = 'hover',
            ---@type NoiceViewOptions
            opts = {},
        },
        documentation = {
            view = 'hover',
            ---@type NoiceViewOptions
            opts = {
                lang = 'markdown',
                replace = true,
                render = 'plain',
                format = { '{message}' },
                win_options = { concealcursor = 'n', conceallevel = 3 },
            },
        },
    },
    markdown = {
        hover = {
            ['|(%S-)|'] = vim.cmd.help,
            ['%[.-%]%((%S-)%)'] = Util.open,
        },
        highlights = {
            ["|%S-|"] = "@text.reference",
            ["@%S+"] = "@parameter",
            ["^%s*(Parameters:)"] = "@text.title",
            ["^%s*(Return:)"] = "@text.title",
            ["^%s*(See also:)"] = "@text.title",
            ["{%S-}"] = "@parameter",
        },
    },
    health = { checker = true },
    smart_move = {
        enabled = true,
        excluded_filetypes = { "cmp_menu", "cmp_docs", "notify" },
    },
    -- you can enable a preset for easier configuration
    presets = {
        bottom_search = false,  -- use a classic bottom cmdline for search
        command_palette = true, -- position the cmdline and popupmenu together
        long_message_to_split = true, -- long messages will be sent to a split
        inc_rename = false,     -- enables an input dialog for inc-rename.nvim
        lsp_doc_border = true,  -- add a border to hover docs and signature help
    },
    throttle = 1000 / 50,
    ---@type NoiceConfigViews
    views = {}, ---@see section on views
    ---@type NoiceRouteConfig
    routes = {
        view = 'notify',
        filter = {},
        opts = {
            align = 'center',
        },
    }, ---@see section on routes
    ---@type table<string, NoiceFilter>
    status = {}, ---@see section on statusline components
    ---@type NoiceFormatOptions
    format = {
        default = { '{level} ', '{title} ', '{message}' },
        notify = { '{message}' },
        details = {
            "{level} ",
            "{date} ",
            "{event}",
            { "{kind}", before = { ".", hl_group = "NoiceFormatKind" } },
            " ",
            "{title} ",
            "{cmdline} ",
            "{message}",
        },
    }, ---@see section on formatting
}

    Noice.setup(Opts)
end
Lazy.setup({
    'folke/tokyonight.nvim',

    {
        "folke/noice.nvim",
        event = "VeryLazy",
        name = 'Noice',
        version = false, -- UNRELATED NOTE: Please folke, make it more clear that `false`
        --                 means bleeding-edge unlike `'*'`
        dependencies = {
            "MunifTanjim/nui.nvim",
            'rcarriga/nvim-notify',
            'nvim-lua/plenary.nvim',
            'echasnovski/mini.nvim',
            'hrsh7th/nvim-cmp',
        },
        config = noice_src,
    },
    {
        'hrsh7th/nvim-cmp',
        dependencies = {
            'neovim/nvim-lspconfig',
            'hrsh7th/cmp-nvim-lsp',
            'hrsh7th/cmp-buffer',
            'hrsh7th/cmp-path',
            'hrsh7th/cmp-cmdline',
            'petertriho/cmp-git',

            'L3MON4D3/LuaSnip',
            'saadparwaiz1/cmp_luasnip',
        },
        init = function()
            vim.opt.completeopt = { 'menu', 'menuone', 'noinsert', 'noselect', 'preview' }
        end,
        config = function()
            local cmp = require('cmp')

            cmp.setup({
                snippet = {
                    -- REQUIRED - you must specify a snippet engine
                    expand = function(args)
                        require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
                    end,
                },
                window = {
                    -- completion = cmp.config.window.bordered(),
                    -- documentation = cmp.config.window.bordered(),
                },
                mapping = cmp.mapping.preset.insert({
                    ['<C-b>'] = cmp.mapping.scroll_docs(-4),
                    ['<C-f>'] = cmp.mapping.scroll_docs(4),
                    ['<C-Space>'] = cmp.mapping.complete(),
                    ['<C-e>'] = cmp.mapping.abort(),
                    ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
                }),
                sources = cmp.config.sources({
                    { name = 'nvim_lsp' },
                    { name = 'luasnip' }, -- For luasnip users.
                }, {
                    { name = 'buffer' },
                })
            })

            -- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below
            -- Set configuration for specific filetype.
            cmp.setup.filetype('gitcommit', {
                sources = cmp.config.sources({
                    { name = 'git' },
                }, {
                    { name = 'buffer' },
                })
            })
            require("cmp_git").setup()

            -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
            cmp.setup.cmdline({ '/', '?' }, {
                mapping = cmp.mapping.preset.cmdline(),
                sources = {
                    { name = 'buffer' }
                }
            })

            -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
            cmp.setup.cmdline(':', {
                mapping = cmp.mapping.preset.cmdline(),
                sources = cmp.config.sources({
                    { name = 'path' }
                }, {
                    { name = 'cmdline' }
                }),
                matching = { disallow_symbol_nonprefix_matching = false }
            })
        end
    },
})

vim.cmd('colorscheme tokyonight-night')
folke commented 1 month ago

view_history = true, -- view for :messages view_search = true, -- view for s

Those should be noice views (Strings), not booleans. Check the docs please