Cannot install Neorg with LazyVim
Prerequisites
- [x] I am using the latest stable release of Neovim
- [x] I am using the latest version of the plugin
Neovim Version
NVIM v0.11.4 Build type: Release LuaJIT 2.1.1741730670
Neorg setup
return {
"nvim-neorg/neorg",
lazy = false, -- Disable lazy loading as some lazy.nvim distributions set lazy = true by default
version = "*", -- Pin Neorg to the latest stable release
config = true,
}
Actual behavior
I just tried to install neorg but got this installation error with LazyVim:
Failed to run `config` for neorg
...ua/neorg/modules/core/integrations/treesitter/module.lua:63: Unable to load nvim-treesitter.ts_utils :(
# stacktrace:
- /neorg/lua/neorg/modules/core/integrations/treesitter/module.lua:63 _in_ **load**
- /neorg/lua/neorg/core/modules.lua:447 _in_ **load_module**
- /neorg/lua/neorg/core/modules.lua:379 _in_ **load_module**
- /neorg/lua/neorg/core/modules.lua:248 _in_ **load**
- /neorg/lua/neorg/core/modules.lua:447 _in_ **load_module**
- /neorg/lua/neorg/init.lua:100 _in_ **org_file_entered**
- /neorg/lua/neorg/init.lua:45 _in_ **setup**
- lua/config/lazy.lua:17
- init.lua:2
Expected behavior
Neorg should install without any errors when using the suggested default config.
Steps to reproduce
- Add the suggested default config for neorg.
- Run Lazy Install.
Potentially conflicting plugins
No response
Other information
No response
Help
No
Implementation help
No response
I'm having the same issues, even when following the solution in #1715
Thanks, for LazyVim users who don't want to parse this whole ticket, the solution is to:
- pull the tip of 'main' instead of the latest versioned release
return { { "nvim-neorg/neorg", lazy = false, -- version = "*", version = false, -- get latest on branch
- Add the following to
autocmds.luavim.api.nvim_create_autocmd("FileType", { pattern = { "norg", "neorg" }, callback = function() if pcall(vim.treesitter.start) then vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end end, })
Originally posted by @Tylerc230 in #1715
Pretty much sure because LazyVim upgraded its treesitter version to the new one
I'm having the same issues, even when following the solution in 1715
Same, I was part of that thread's discussion so I had tried the solution PR when a contributer requested it, I had it working too when the PR was merged, so by that point my current setup was working, yet now it doesn't anymore.
Something to note is an additionnal error I have due to my config:
Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...rew/Cellar/neovim/0.11.5/share/nvim/runtime/filetype.lua:36: BufReadPost Autocommands for
"*"..FileType Autocommands for "norg"..FileType Autocommands for "*": Vim(append):Error executing lua callback:
.../neovim/0.11.5/share/nvim/runtime/lua/vim/treesitter.lua:111: Parser could not be created for buffer 1 and language "norg"
whats the latest version of treesitter that works with neorg?
Pretty much sure because LazyVim upgraded its treesitter version to the new one
whats the latest version of treesitter that works with neorg?
Both latest commits of the Master and Main branches of nvim-treesitter work with Neorg. For the master version, which is the default but not recommended to stay on branch, you can just :TSInstall the norg parser. For main, you need to configure a bunch, the steps look like this:
- Setup the neorg plugin according to the Neorg docs
- Add the integrations you need
- Add
dependencies = { "nvim-neorg/tree-sitter-norg" }so that it installs locally and Luarocks (or hererocks, which LazyVIm seems to install automatically if your system doesn't have Luarocks installed) builds the parser.
- Add
vim.treesitter.add()to~/.config/nvim/ftplugin/norg.lua - Create a
parser/folder in~/.config/nvim/and create a symlink betweenparser/norg.soand~/.local/share/nvim/lazy-rocks/tree-sitter-norg/lib/lua/5.1/parser/norg.so, neovim'sruntimepathwill take care of adding it as a treesitter parser.
I did want to go the "normal" way and add the custom parser using an autocommand to download tree-sitter-norg on
TSUpdate, as documented in the nvim-treesitter's main branch, but when doingTSInstall norgit'd download, then compile and finally.. error.
Hope it helps!
maybe a workaround
return {
{
"nvim-neorg/neorg",
dependencies = {
{
"nvim-neorg/tree-sitter-norg",
build = {
"rockspec",
function()
local from = vim.fn.stdpath("data") .. "/lazy-rocks/tree-sitter-norg/lib/lua/5.1/parser/norg.so"
local to = vim.fn.stdpath("data") .. "/lazy/nvim-treesitter/parser/norg.so"
vim.fn.mkdir(vim.fn.fnamemodify(to, ":p:h"), "p")
local ok, err, err_name = vim.uv.fs_copyfile(from, to)
if not ok then
vim.notify(
("copy %s to %s failed for %s %s"):format(from, to, err, err_name),
vim.log.levels.ERROR,
{ title = "tree-sitter-norg" }
)
else
vim.notify(
("copy %s to %s success"):format(from, to),
vim.log.levels.INFO,
{ title = "tree-sitter-norg" }
)
end
end,
},
},
},
lazy = false,
opts = {},
},
}
Had no idea we could do that, that's awesome. Thanks allot!
Does this bug rely on an upstream update? I am on Windows, and would love to not have to figure out translating the workaround if the issue is being patched soon...