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

Neovim freezes when adding headings to large org files #625

Closed
oncomouse opened this issue Nov 4, 2023 · 2 comments
Closed

Neovim freezes when adding headings to large org files #625

oncomouse opened this issue Nov 4, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@oncomouse
Copy link
Contributor

Describe the bug

My main org file is 1026 lines (currently) and 11297 words. I noticed that when attempting to add third level headings on a particular task Neovim would completely freeze (it won't accept any terminal input; had to kill the process). Experimenting further with the file, I discovered that if I wait long enough, I get a message about redrawtime being exceeded (I don't have the specific error at hand, sorry). Further typing around the asterisk will produce another freeze.

Steps to reproduce

  1. Open this anonymized version of my todo.org file
  2. The problem specifically occurred at line 520, so 520G
  3. Insert a new line with o
  4. Type an asterisk

Expected behavior

Neovim shouldn't freeze when adding headlines.

Emacs functionality

No response

Minimal init.lua

-- Set Leader:
vim.g.mapleader = " "
local nvim_root = '/tmp/nvim_orgmode'
local lazy_root = nvim_root .. '/lazy'
local lazypath = lazy_root .. '/lazy.nvim'
if not 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({
  root = lazy_root,
  lockfile = nvim_root .. '/lazy.json',
  spec = {
    {
      "nvim-orgmode/orgmode",
      config = function(_, opts)
        require("orgmode").setup_ts_grammar()
        require("nvim-treesitter.configs").setup({
          highlight = {
            enable = true,
            additional_vim_regex_highlighting = { "org" },
          },
          ensure_installed = { "org" },
        })
        require("orgmode").setup(opts)
      end,
      dependencies = {
        {
          "nvim-treesitter/nvim-treesitter",
        },
      },
    },
  },
})
-- # vim:ts=2:sw=2:sts=2:expandtab

Screenshots and recordings

No response

OS / Distro

Arch linux

Neovim version/commit

NVIM v0.10.0-dev-684e930

Additional context

Another thing to note, I tried this project's minimal_init.lua file. Doing so doesn't produce the error, but when I use that file (nvim -u ./minimal_init.lua todo.org), folding is disabled because foldexpr is set to 0 and none of the maps I would expect in orgmode appear to be working (I tried >> on a headline and C-<space on a checkbox, neither work). In the minimal init I supplied, foldexpr is set to nvim_treesitter#foldexpr() as one would expect.

This makes me think there's something going on with treesitter's fold function, but I'm not sure if that's the case or even how to debug it. I've tried disabling foldexpr with my minimal init file, and the problem persists.

@kristijanhusak
Copy link
Member

Hi,

The problem appears because adding a * at that line actually switches ~500 lines to a drawer because some of the lines above and below are not properly parsed. That switch re-parses all the markup again and that causes the freeze.

Thanks for reporting. I'll let you know once this is fixed.

@kristijanhusak
Copy link
Member

This issue should be fixed now. Just pull the latest master and do :TSUpdate org to fetch the latest tree-sitter grammar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants