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

High CPU usage when opening large c files and editing #132

Closed menash134 closed 2 years ago

menash134 commented 2 years ago

Describe the bug High cpu usage when opening and editing big c files

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

  1. open https://elixir.bootlin.com/linux/v4.4.302/source/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c
  2. Edit the file
  3. Scroll down
  4. See CPU usage and neovim stuck with 100% cpu usage.

Note minimal init.vim/init.lua/.vimrc syntax on set ma set mouse=a set cursorline set tabstop=4 set shiftwidth=4 set softtabstop=4 set expandtab set autoread set nobackup set nowritebackup set noswapfile set nu set foldlevelstart=99 set scrolloff=7 set hidden set timeoutlen=500 set relativenumber "set termguicolors "use y and p with the system clipboard set clipboard=unnamedplus

let vim_plug_just_installed = 0 set encoding=UTF-8

if empty(glob('~/.config/nvim/autoload/plug.vim')) silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim "autocmd VimEnter PlugInstall "autocmd VimEnter PlugInstall | source $MYVIMRC let vim_plug_just_installed = 1 endif

call plug#begin('~/.config/nvim/autoload/plugged')

Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'nvim-treesitter/nvim-treesitter' Plug 'RRethy/vim-illuminate'

call plug#end()

" enable tabline

" Always show tabs set showtabline=2

"set noshowmode let g:python3_host_prog='/usr/bin/python3' set encoding=UTF-8 let mapleader = ";" "Coc nvim "highlight Pmenu ctermbg=Black ctermfg=White highlight Normal cterm=NONE ctermbg=Black gui=NONE guibg=Black highlight CocMenuSel ctermbg=Black ctermfg=Green guibg=Black guifg=Green highlight CocSearch ctermfg=Magenta guifg=Magenta inoremap coc#pum#visible() ? coc#pum#confirm() : "\"

map :exec &mouse!=""? "set mouse=" : "set mouse=nv" autocmd CursorHold * silent call CocActionAsync('highlight')

Expected behavior Little cpu usage and neovim should not freeze

menash134 commented 2 years ago

v0.8.0-dev-1117-g7bd4c8e8e - nvim version Linux HPZ2-Siemens 5.15.0-46-generic https://github.com/neovim/neovim/pull/49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux And Iam using appimage

RRethy commented 2 years ago

That's not a minimal config. It's got highlight groups ffs, not only that but it doesn't give me any useful information. According to that config you are not using treesitter (there's no .setup call), you have no lsp servers running, and set expandtab is critical to reproduce the issue somehow. A minimal config is the bare minimum config that can be passed to nvim -u to reproduce the issue, not random snippets from your config your copy pasted with no formatting or codeblocks into an issue.

menash134 commented 2 years ago

That is really impolite that you are closing the issue without giving a second chance to post. Iam really trying to help here but pointing out the issue.

As you mentioned, I have nothing running.. just basic this file is enough to reproduce the issue. I didn't copy this from my file, this was my file to reproduce the issue. I work primarily on C language hence no lsp or sophisticated stuff needed for my daily programming.

sorry that I dont know what is nvim -u means. could you clarify?

Did you ever tried to open that linux file using this nvim config?

menash134 commented 2 years ago

if you want a video of the issue i can record and post.

menash134 commented 2 years ago

healthstatus.txt initvim.txt

I attached the healthstatus using checkhealth. You can see that the treesitter has only c and lua and vim script. initvim.txt is the actual init.vim file which you need to reproduce the issue.

If you want more info, Iam happy to help or do you want me to open one more ticket?

RRethy commented 2 years ago

That is really impolite that you are closing the issue without giving a second chance to post. Iam really trying to help here but pointing out the issue.

The issue can be reopened when/if a minimal config is produced.

It's extremely impolite to create an issue and not follow the issue template, you got the exact same feedback from Justin in the issue you opened in the Neovim repo without giving a minimal config.

As you mentioned, I have nothing running.. just basic this file is enough to reproduce the issue. I didn't copy this from my file, this was my file to reproduce the issue. I work primarily on C language hence no lsp or sophisticated stuff needed for my daily programming.

Then why do you have both LSP and treesitter code included in your minimal config, by definition that makes it not minimal. No only that but your minimal config doesn't ever setup treesitter, so it's either broken or incomplete.

sorry that I dont know what is nvim -u means. could you clarify?

:help -u

-u {vimrc}  The file {vimrc} is read for initializations.  Most other
        initializations are skipped; see |initialization|.

        This can be used to start Vim in a special mode, with special
        mappings and settings.  A shell alias can be used to make
        this easy to use.  For example:  
            alias vimc vim -u ~/.config/nvim/c_init.vim !*
        Also consider using autocommands; see |autocommand|.

        When {vimrc} is "NONE" (all uppercase), all initializations
        from files and environment variables are skipped.  Plugins and
        syntax highlighting are also skipped.

        When {vimrc} is "NORC" (all uppercase), this has the same
        effect as "NONE", but plugins and syntax highlighting are not
        skipped.

if you want a video of the issue i can record and post.

No thank you.

Without a minimal config there's literally nothing I can do because I have zero information pertaining to your config that I can work off of. At this point just disable the plugin for C files with filetypes_denylist or set max_file_lines, I'm not going to continue this thread when I've asked 4 times for a minimal config and have yet to receive one.

menash134 commented 2 years ago

Yeah that gives out that Iam a NOOB. I try to figure out how to generate a minimalist nvim config. could you help me on this? I tried googling it, but i could not find a proper one. can you point a example of how to generate minimalist nvim config?

menash134 commented 2 years ago

Hi, the below config is the minimal config that I used to reproduce the issue. Somehow, the issue is linked with treesitter. Without treesitter I could not able to reproduce.

if empty(glob('~/.config/nvim/autoload/plug.vim')) silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif

call plug#begin('~/.config/nvim/autoload/plugged')

Plug 'nvim-treesitter/nvim-treesitter' Plug 'RRethy/vim-illuminate'

call plug#end()

Steps to reproduce: open https://elixir.bootlin.com/linux/v4.4.302/source/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c in nvim Edit the file by typing "#define" or some random text and save the file Scroll down See CPU usage and neovim stuck with 100% cpu usage.