nvim-neorg / neorg

Modernity meets insane extensibility. The future of organizing your life in Neovim.
GNU General Public License v3.0
6.36k stars 209 forks source link

Joining a highlighted line with "J" breaks tree-sitter highlighter #1408

Closed stephenprater closed 2 months ago

stephenprater commented 5 months ago

Prerequisites

Neovim Version

NVIM v0.10.0-dev-3005+gaf8500af6-Homebrew

Neorg setup

  {
    'nvim-neorg/neorg',
    dependencies = { "luarocks.nvim" },
        ft = "norg",
    cond = function()
      return not os.getenv("SPIN")
    end,
    config = function()
      require('neorg').setup({
        load = {
          ["core.defaults"] = {},
          ["core.concealer"] = {
            config = {
              icons = {
                todo = {
                  undone = {
                    icon = " "
                  }
                }
              }
            }
          },
          ["core.export"] = {
            config = {
              export_dir = "~/log/"
            }
          },
          -- ["core.completion"] = {
          --   config = {
          --     engine = "nvim-cmp", name = "[Norg]"
          --   }
          -- },
          ["core.integrations.nvim-cmp"] = {},
          ["core.dirman"] = {
            config = {
              workspaces = {
                log = "~/log"
              },
              index = "prater.norg"
            }
          },
        }
      })

      vim.cmd([[autocmd FileType norg setlocal foldmethod=expr foldexpr=nvim_treesitter#foldexpr() tw=80 sw=2]])
      vim.cmd([[autocmd FileType norg Copilot disable]])

    end
  },

Actual behavior

When joining a highlighted line longer than the softwrap length, this error starts getting thrown. It is is then thrown on every keypress within a Neorg buffer until I restart Neovim.

┊  Error  10:08:02 msg_show.emsg  Noice last Error in decoration provider treesitter/highlighter.line:
Error executing lua: ...84/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:337: Invalid 'end_col': out of range
stack traceback:
  [C]: in function 'nvim_buf_set_extmark'
  ...84/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:337: in function 'fn'
  ...84/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:210: in function 'for_each_highlight_state'
  ...84/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:291: in function 'on_line_impl'
  ...84/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:367: in function <...84/share/nvim/runtime/lua/vim/treesi
  [C]: in function 'nvim_exec2'
  vim/_editor.lua: in function 'cmd'
  .../share/nvim/lazy/nvim-notify/lua/notify/service/init.lua:63: in function 'push'
  ...ocal/share/nvim/lazy/nvim-notify/lua/notify/instance.lua:77: in function <...ocal/share/nvim/lazy/nvim-notify/lua/
  ...e/nvim/lazy/noice.nvim/lua/noice/view/backend/notify.lua:169: in fun

Expected behavior

It should not do that.

Steps to reproduce

In an empty neorg file type a sentence longer than the softwrap like (80 cols) - if it autowraps, press "J" to join with the previous line. There is no error.

Break the line so that it is shorter than the softwrap length.

Press "*" at the beginning of the first line so that it highlights as a headline. Press "J" to join with the next line.

The error will be thrown many times. Breaking the line again will not supress it. (It's possible it does, and I just don't have the patience to hit enter enough to times to get through all of the times it's thrown - but Neovim is effectively unusable until it's restarted.)

Potentially conflicting plugins

nvim-treesitter I guess?

Other information

No response

Help

Yes, but I don't know how to start. I would need guidance (check question below)

Implementation help

No response

benlubas commented 5 months ago

bisected to 52022710d47fd66c73280f7a8d7fe2013d899224

The commit that first loads the introspector module by default.

This bug has been so annoying recently :/

benlubas commented 5 months ago

I'll add, disabling the todo-introspector is a sufficient temp fix for me. Here's the config for that:

["core.defaults"] = {
  config = {
    disable = { "core.todo-introspector" },
  },
},

Minimal Repro

File contents:

*a*
  1. Press o then backspace
benlubas commented 4 months ago

@stephenprater can you still reproduce this on the latest nightly? I no longer see it. I lied. That simple repro doesn't work, but with more complex examples it still happens to me.

benlubas commented 3 months ago

@vhyrro fixed this in https://github.com/nvim-neorg/neorg/commit/cb4f25bca799c49a81e471aeca1d6d95322c87a6

I think this can be closed

stephenprater commented 2 months ago

Seems to be fixed!