RRethy / vim-illuminate

illuminate.vim - (Neo)Vim plugin for automatically highlighting other uses of the word under the cursor using either LSP, Tree-sitter, or regex matching.
2.18k stars 50 forks source link

editing large files while using treesitter as the main provider causes lag #200

Closed 9qq-qq-qq9 closed 4 months ago

9qq-qq-qq9 commented 4 months ago

Describe the bug vim-illuminate causes lag when navigating and editing larger files if the provider is treesitter.

To Reproduce Steps to reproduce the behavior (include minimal init.vim or .vimrc):

  1. obtain a fresh installation of neovim and place the following config inside your init.lua:

    
    local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
    if not (vim.uv or vim.loop).fs_stat(lazypath) then
    
    vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    
    "--branch=stable", -- latest stable release
    lazypath,
    })
    end
    vim.opt.rtp:prepend(lazypath)

require("lazy").setup({ { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", config = function() local tsconfig = require("nvim-treesitter.configs") tsconfig.setup({ auto_install = true, highlight = { enable = true }, indent = { enable = true }, }) end }, { "RRethy/vim-illuminate", config = function() require("illuminate").configure({ providers = { "treesitter", "lsp", "regex", } }) end } })

2. open any large file, in my case it was dwm.c from git.suckless.org/dwm
3. navigate around the file and observe the input delay.
4. move "treesitter" to the bottom of the providers table in the options for vim-illuminate
5. open the same file and notice the improvement of speed

**Output from `:IlluminateDebug`**

buf_should_illuminate 1 true config { case_insensitive_regex = false, delay = 100, filetype_overrides = {}, filetypes_allowlist = {}, filetypes_denylist = {"dirbuf", "dirvish", "fugitive"}, min_count_to_highlight = 1, modes_allowlist = {}, modes_denylist = {}, providers = {"treesitter","lsp", "regex"}, providers_regex_syntax_allowlist = {}, providers_regex_syntax_denylist = {}, under_cursor = true } started true provider table: 0x7fe495098cb8 treesitter termguicolors true

RRethy commented 4 months ago

You can use the large_file_overrides and large_file_cutoff config options to change how vim-illuminate works for large files.

RRethy commented 4 months ago

Treesitter is known to be slow for large files and there is nothing I can do, regex and LSP are likely faster, or you could disable the plugin at a certain file size.