Skip to content

0.11.1 cause no treesitter, if set lazy = true #975

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

Open
2 tasks
cxwx opened this issue May 5, 2025 · 7 comments
Open
2 tasks

0.11.1 cause no treesitter, if set lazy = true #975

cxwx opened this issue May 5, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@cxwx
Copy link

cxwx commented May 5, 2025

Describe the bug

19:40:57 msg_show Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...rew/Cellar/neovim/0.11.1/share/nvim/runtime/filetype.lua:36: BufReadPost Autocommands for "*"..FileType Autocommands for "org": Vim(append):Error executing vim.schedule lua callback: ...m/0.11.1/share/nvim/runtime/lua/vim/treesitter/query.lua:906: No handler for org-set-fold-offset!
stack traceback:
	[C]: in function 'error'
	...m/0.11.1/share/nvim/runtime/lua/vim/treesitter/query.lua:906: in function '_apply_directives'
	...m/0.11.1/share/nvim/runtime/lua/vim/treesitter/query.lua:1106: in function '(for generator)'
	...m/0.11.1/share/nvim/runtime/lua/vim/treesitter/_fold.lua:108: in function 'fn'
	...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:650: in function 'for_each_tree'
	...m/0.11.1/share/nvim/runtime/lua/vim/treesitter/_fold.lua:100: in function 'cb'
	...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:478: in function '_run_async_callbacks'
	...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:534: in function <...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:513>
	[C]: in function 'wait'
	.../nvim/lazy/plugins/orgmode/lua/orgmode/utils/promise.lua:279: in function 'wait'
	...plugins/orgmode/lua/orgmode/utils/treesitter/install.lua:125: in function 'get_installed_version'
	...
	...xu/software/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:395: in function 'config'
	...xu/software/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:362: in function '_load'
	...xu/software/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:197: in function 'load'
	...ware/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:85: in function <...ware/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:72>
	[C]: in function 'nvim_cmd'
	...rew/Cellar/neovim/0.11.1/share/nvim/runtime/filetype.lua:36: in function <...rew/Cellar/neovim/0.11.1/share/nvim/runtime/filetype.lua:35>
	[C]: in function 'pcall'
	vim/shared.lua: in function <vim/shared.lua:0>
	[C]: in function '_with'
	...rew/Cellar/neovim/0.11.1/share/nvim/runtime/filetype.lua:35: in function <...rew/Cellar/neovim/0.11.1/share/nvim/runtime/filetype.lua:10>
stack traceback:
	[C]: in function '_with'
	...rew/Cellar/neovim/0.11.1/share/nvim/runtime/filetype.lua:35: in function <...rew/Cellar/neovim/0.11.1/share/nvim/runtime/filetype.lua:10>

Steps to reproduce

upgrade 0.11.1 nvim
open a org file with fold

  • a
    ** aa
  • a
  • a

Expected behavior

bug fix

Emacs functionality

No response

Minimal init.lua

unknown

Screenshots and recordings

No response

nvim-orgmode version

lastest

OS / Distro

macos 15.4.1

Neovim version/commit

0.11.1

Additional context

No response

@cxwx cxwx added the bug Something isn't working label May 5, 2025
@cxwx
Copy link
Author

cxwx commented May 5, 2025

nvim-treesitter/nvim-treesitter#7634

treesitter drop support for org filetype

@kristijanhusak
Copy link
Member

nvim-orgmode does not have a dependency on nvim-treesitter. If you previously installed the parser using nvim-treesitter, remove it from the nvim-treesitter/parser folder, and restart Neovim. Orgmode should automatically install the parser.

@cxwx
Copy link
Author

cxwx commented May 5, 2025

nvim-treesitter/parser

old version org.so removed.

and the .m/0.11.1/share/nvim/runtime/lua/vim/treesitter/query.lua:906: No handler for org-set-fold-offset! problem is still there

  1. the problem seem to be the fold method using treesitter,
  2. If I remove the orgmode.nvim plugin, the error disappeared

@cxwx
Copy link
Author

cxwx commented May 5, 2025

The Problem may be cause by the order of some plugins

OK if lazy = false, event = "VeryLazy"

  {
    "nvim-orgmode/orgmode",
    event = "VeryLazy",
    lazy = false,
    opts = {
      org_agenda_files = { "~/org/*", "~/orgs/**/*" },
      org_default_notes_file = "~/org/note.org",
    },
  },

errors when lazy = true, ft = "org"

  {
    "nvim-orgmode/orgmode",
   ft = "org",
    lazy = true,
    opts = {
      org_agenda_files = { "~/org/*", "~/orgs/**/*" },
      org_default_notes_file = "~/org/note.org",
    },
  },

I think the errors is cause

treesitter foldmethod loaded -> filetype detected -> orgmode fold (here)

but if lazy = false

orgmode fold worked

@cxwx cxwx changed the title 0.11.1 cause no treesitter 0.11.1 cause no treesitter, if set lazy = true May 5, 2025
@kristijanhusak
Copy link
Member

I can't reproduce it. Does this minimal init work for you ?

--- save this file as minimal_init.lua
--- Run as `nvim -u minimal_init.lua

local tmp_dir = vim.env.TMPDIR or vim.env.TMP or vim.env.TEMP or '/tmp'
local nvim_root = tmp_dir .. '/nvim_orgmode'
local lazy_root = nvim_root .. '/lazy'
local lazypath = lazy_root .. '/lazy.nvim'

for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
  vim.env[('XDG_%s_HOME'):format(name:upper())] = nvim_root .. '/' .. name
end

-- Install lazy.nvim if not already installed
if not vim.uv.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-orgmode/orgmode',
    lazy = true,
    ft = 'org',
    opts = {
      org_agenda_files = { '~/org/*', '~/orgs/**/*' },
      org_default_notes_file = '~/org/note.org',
    },
  },
}, {
  root = lazy_root,
  lockfile = nvim_root .. '/lazy.json',
  install = {
    missing = false,
  },
})

require('lazy').sync({
  wait = true,
  show = false,
})

@cxwx
Copy link
Author

cxwx commented May 18, 2025

I've also set

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

and nvim v0.11 remove org https://github.com/emiasims/tree-sitter-org
it cause this bug.

@kristijanhusak
Copy link
Member

You mean you used nvim_treesitter#foldexpr() ?

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