Skip to content

🐞 Bug: local state (a nil value) ERROR when I delete .md buffer. #394

@Jaehaks

Description

@Jaehaks

🤖 Which branch are you using?

  • dev
  • main

📜 Issue description:

I am Windows user and use recent commit today [b1d648d].

If I set `hybrid_modes = {'n'}, this error is invoked.

Error executing vim.schedule lua callback: ...ER/.config/nvim-data/lazy/markview.nvim/lua/markview.lua:295: attempt to index local 'state' (a nil value)                                                                                                
stack traceback:                                                                                                                    
...ER/.config/nvim-data/lazy/markview.nvim/lua/markview.lua:295: in function 'render'                                       
....config/nvim-data/lazy/markview.nvim/plugin/markview.lua:360: in function 'fn'                                           
vim/_editor.lua:615: in function 'fn'                                                                                      
 vim/_editor.lua:366: in function <vim/_editor.lua:365>  

My configuration is like this. If hybrid_modes = {'i'}, there are no error. but {'n'} has it.

opts = {
  preview = {
    modes = {'n', 'no', 'c'},
    hybrid_modes         = {'n'}, -- disable conceal specific region under cursor
    linewise_hybrid_mode = true,  -- apply hybrid mode with line-wise not block-wise
  },

📑 Reproduction steps:

  1. set the config
  2. open .md anything
  3. :bd to delete this.
  4. error is shown

💻 Minimal init:

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        {
            "nvim-treesitter/nvim-treesitter",
            build = ":TSUpdate",

            ensure_installed = { "html", "latex", "markdown", "markdown_inline", "typst", "yaml" }
        },
        {
            "OXY2DEV/markview.nvim",
            -- branch = "dev",
            lazy = false,
            opts = {
            preview = {
                modes = {'n', 'no', 'c'},
                hybrid_modes         = {'n'}, -- disable conceal specific region under cursor
                linewise_hybrid_mode = true,  -- apply hybrid mode with line-wise not block-wise
              },
            }
        }
    },
});

📜 Logs:

Plugin: markview.nvim
Time: 9/23/2025 2:44:07 PM
Nvim version: 0.11.3
Colorscheme: tokyonight-moon

Level description,
1 = START
2 = PAUSE
3 = STOP
4 = ERROR
5 = LOG
6 = ENABLE
7 = DISABLE
8 = ATTACH
9 = DETACH

Trace,
-----------------------•-------•--------------------------------------------------------------------------------------------------
Time-stamp | Level | Action
-----------------------•-------•--------------------------------------------------------------------------------------------------
%k:%M:%S | 5 | Added tree-sitter directive {conceal-patch!}
%k:%M:%S | 8 | Attached: 4
%k:%M:%S | 1 | Callback: {on_attach}
%k:%M:%S | 1 | Callback: {on_enable}
%k:%M:%S | 1 | Clearing: 4
%k:%M:%S | 3 | Clearing(end, 0ms): 4
%k:%M:%S | 1 | Parsing(start): 4
%k:%M:%S | 3 | Parsing(end, 4ms): 4
%k:%M:%S | 1 | Rendering(main): 4
%k:%M:%S | 3 | Render(main): 0ms
%k:%M:%S | 3 | Render(post): 0ms
%k:%M:%S | 3 | Rendering(end, 0ms): 4
%k:%M:%S | 1 | Callback: {on_hybrid_enable}
%k:%M:%S | 1 | Mode(c): 4
%k:%M:%S | 1 | Callback: {on_mode_change}
%k:%M:%S | 1 | Mode(n): 4
%k:%M:%S | 1 | Callback: {on_mode_change}
%k:%M:%S | 8 | Attached: 5
%k:%M:%S | 1 | Callback: {on_attach}
%k:%M:%S | 1 | Callback: {on_enable}
%k:%M:%S | 1 | Clearing: 5
%k:%M:%S | 3 | Clearing(end, 0ms): 5
%k:%M:%S | 1 | Parsing(start): 5
%k:%M:%S | 3 | Parsing(end, 0ms): 5
%k:%M:%S | 1 | Rendering(main): 5
%k:%M:%S | 3 | Render(main): 0ms
%k:%M:%S | 3 | Render(post): 0ms
%k:%M:%S | 3 | Rendering(end, 0ms): 5
%k:%M:%S | 1 | Callback: {on_hybrid_enable}
%k:%M:%S | 1 | Mode(c): 5
%k:%M:%S | 1 | Callback: {on_mode_change}
%k:%M:%S | 1 | Mode(n): 5
%k:%M:%S | 1 | Callback: {on_mode_change}
%k:%M:%S | 1 | Mode(c): 4
%k:%M:%S | 1 | Callback: {on_mode_change}
%k:%M:%S | 1 | Mode(n): 4
%k:%M:%S | 1 | Callback: {on_mode_change}
-----------------------•-------•--------------------------------------------------------------------------------------------------

vim:nomodifiable:nowrap:nospell:

Neovim version:

nvim v0.11.4

✅ Expected behavior:

I cannot reproduce this problem when I use the same config.
error is gone. whe I delete buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions