lukas-reineke / indent-blankline.nvim

Indent guides for Neovim
MIT License
4.22k stars 105 forks source link

Neovim freezes when deleting specific lines #930

Closed Rolv-Apneseth closed 4 weeks ago

Rolv-Apneseth commented 1 month ago

Problem

I'm having a very specific bug from what I can tell, though I have been able to get a minimal reproducible example. When deleting certain lines in a Rust file, neovim will freeze the terminal completely and ramp up CPU usage. It seems to be some interaction between this plugin and treesitter, and disabling either of them fixes the issue.

I have also tried other versions of this plugin, all the way to v3.0.0 and the same issue is there so it doesn't seem to be a recent regression. I have had freezes in the past but this was just the first time I chose to dig into it.

Hope this is enough info, but let me know if you need more. Also happy to test stuff if needed.

Steps to reproduce

Run:

nvim --clean main.rs -u minimal.lua

Then delete lines 7 and 8 (the ones inside the Command struct) at the same time (dj, dk, di{, etc.) and the program freezes.

minimal.lua

local plugins = {
    ts = "https://github.com/nvim-treesitter/nvim-treesitter",
    indent = "https://github.com/lukas-reineke/indent-blankline",
}

for name, url in pairs(plugins) do
    local install_path = "/tmp/nvim/site/" .. name
    if vim.fn.isdirectory(install_path) == 0 then
        vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
    end
    vim.o.runtimepath = install_path .. "," .. vim.o.runtimepath
end

require("nvim-treesitter.configs").setup({
    ensure_installed = {
        "rust",
    },
    highlight = {
        enable = true,
    },
    sync_install = true,
    auto_install = true,
    ignore_install = {},
})

require("ibl").setup({})

main.rs

use clap::{Parser, Subcommand};

#[derive(Debug, Parser)]
#[clap(args_conflicts_with_subcommands = true)]
#[clap(subcommand_negates_reqs = true)]
pub struct Command {
    #[command(flatten, next_help_heading = "Request options")]
    pub request: Request,
}

fn main() {
    println!("Hello, world!");
}

Expected behavior

Shouldn't freeze.

Neovim version (nvim -v)

v0.10.2

lukas-reineke commented 4 weeks ago

Thanks It looks like a bug in treesitter, but I added a fix here so it doesn't freeze Neovim.

Rolv-Apneseth commented 4 weeks ago

Ah I see, do you think I should open an issue there then? Thank you for the workaround though!

HochuSirok commented 3 days ago

Hello! I get the same error on version 3.8.3 (nvim 0.10.2). Configuration

    {
        "lukas-reineke/indent-blankline.nvim",
        main = "ibl",
        ---@module "ibl"
        ---@type ibl.config
        opts = {},
        -- tag = "v3.7.2",
    },

I don’t run this code: require("ibl").setup(), because errors appear even before it. If I turn on setup, the theme I installed crashes and there are more errors.

Errors:

Failed to run `config` for indent-blankline.nvim

...e/nvim/lazy/indent-blankline.nvim/lua/ibl/highlights.lua:95: No highlight group 'IblScope' found                                

# stacktrace:                                                                                                                      
  - /indent-blankline.nvim/lua/ibl/highlights.lua:95 _in_ **setup**                                                                
  - /indent-blankline.nvim/lua/ibl/init.lua:41 _in_ **setup**                                                                      
  - /indent-blankline.nvim/lua/ibl/init.lua:57 _in_ **setup**                                                                      
  - ~/.config/nvim/lua/core/plugins.lua:20                                                                                         
  - ~/.config/nvim/init.lua:4    
  Error executing vim.schedule lua callback: ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:152: Tried to refresh withou
t doing setup                                                                                                                      
stack traceback:                                                                                                                   
        [C]: in function 'assert'                                                                                                  
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:152: in function 'refresh'                                     
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:127: in function 'debounced_refresh'                           
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:143: in function 'debounced_refresh'                           
        .../nvim/lazy/indent-blankline.nvim/lua/ibl/inlay_hints.lua:51: in function 'handler'                                      
        ...im.aWFsfp1/usr/share/nvim/runtime/lua/vim/lsp/client.lua:687: in function ''                                            
        vim/_editor.lua: in function <vim/_editor.lua:0>