Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Takes too much time to open terminal if the buffer is large #610

Open
1 task done
jugarpeupv opened this issue Sep 13, 2024 · 2 comments
Open
1 task done

Comments

@jugarpeupv
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

If i run tree / in a normal :term buffer i can open it instantly, however if i do it with toggleterm then it takes a lot of time to open the terminal

Expected Behavior

It takes the same time than :term command

Steps To Reproduce

Install plugin, run tree / wait for the screen to load a lot of text, then toggleterm and the time it takes to open is very large

Environment

- OS:
- neovim version:
- Shell: zsh

Anything else?

No response

hmgle added a commit to hmgle/nvim that referenced this issue Nov 9, 2024
toggleterm.nvim takes too much time to open terminal if the buffer is large. <akinsho/toggleterm.nvim#610>
@hmgle
Copy link

hmgle commented Nov 10, 2024

I found this issue that seems to be related to the foldexpr. After commenting out the following configuration, the performance returned to normal:

vim.wo.foldmethod = 'expr'
vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'

Related issues:

@jakeschurch
Copy link

Can confirm this indeed fixed my issues with toggleterm

@akinsho - if you would have any interest in me adding a fix for this issue, I would be more than happy to open a PR to add an autocmd here to disable foldexpr for terminal to fix this issue. If not, no worries 👍

I've added this to my config, and would refactor slightly for PR if change wanted.

vim.api.nvim_create_augroup("disable_folding_toggleterm", { clear = true })

vim.api.nvim_create_autocmd("FileType", {
  group = "disable_folding_toggleterm",
  pattern = "toggleterm",
  callback = function(ev)
    local bufnr = ev.buf
    vim.api.nvim_buf_set_option(bufnr, "foldmethod", "manual")
    vim.api.nvim_buf_set_option(bufnr, "foldtext", "foldtext()")
  end,
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants