neorg
neorg copied to clipboard
"assertion failed" when opening code block with magnify code block and another error when closing
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.9.1 Build type: Release LuaJIT 2.1.0-beta3 system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.1/share/nvim" Run :checkhealth for more info
Neorg setup
-- Neorg for note taking
use {
"nvim-neorg/neorg",
run = ":Neorg sync-parsers",
config = function()
require"plugins/neorg"
end,
requires = { "nvim-lua/plenary.nvim", "nvim-neorg/neorg-telescope" , "~/code/vim/neorg-figlet-module"},
}
and
local neorgPath = "~/MEGAsync/norg"
-- Automatically insert file name as header when creating new file
vim.api.nvim_create_autocmd({
"BufNewFile",
}, {
pattern = { "*.norg" },
desc = "Automatically insert header of a new Neorg file",
callback = function()
local fileNameNoExtension = vim.fn.expand("%:t"):gsub("%..*", "")
local putText = "* " .. fileNameNoExtension
vim.api.nvim_put({ putText }, "", false, true)
end,
})
-- When entering a *.norg document, set conceallevel
vim.api.nvim_create_autocmd({
"BufEnter",
}, {
pattern = { "*.norg" },
desc = "Set conceallevel when entering a Neorg file",
callback = function()
vim.o.conceallevel = 3
end,
})
-- Global neorg keybinds
-- Open index
vim.api.nvim_set_keymap("n", "<leader>nn", "<cmd>Neorg index<cr>", { noremap = true, silent = true })
-- Close neorg
vim.api.nvim_set_keymap("n", "<leader>no", "<cmd>Neorg return<cr>", { noremap = true, silent = true })
require('neorg').setup({
load = {
["external.integrations.figlet"] = {
config = {
font = "doom",
wrapInCodeTags = true
}
},
["core.defaults"] = {}, -- Loads default behaviour
["core.concealer"] = {
-- folds = true,
-- icon_preset = "diamond"
}, -- Adds pretty icons to your documents
["core.dirman"] = { -- Manages Neorg workspaces
config = {
workspaces = {
notes = neorgPath .. "/notes",
work = neorgPath .. "/work",
kunst = neorgPath .. "/kunst",
},
default_workspace = "notes",
},
},
["core.completion"] = {
config = {
engine = "nvim-cmp",
}
},
-- ["core.ui.calendar"] = {},
["core.export"] = {},
["core.export.markdown"] = {},
["core.qol.todo_items"] = {
config = {
create_todo_parents = true
}
},
["core.integrations.truezen"] = {},
["core.integrations.telescope"] = {},
["core.presenter"] = {
config = {
zen_mode = "zen-mode",
}
},
["core.keybinds"] = {
config = {
hook = function(keybinds)
-- Prompt for text and insert as figletized
keybinds.map("norg", "n", "<leader>ff",
"<cmd>Neorg keybind norg external.integrations.figlet.figletize<cr>")
-- FzfLua commands for the neorg repo
-- File search
keybinds.map("norg", "n", "<C-p>",
function()
require('fzf-lua').files({ cwd = neorgPath })
end
)
-- Ripgrep
keybinds.map("norg", "n", "<C-g>",
function()
require('fzf-lua').live_grep({ cwd = neorgPath })
end
)
-- Map h1-6 to * to ****** to insert headings
keybinds.map("norg", "n", "<leader>h1", function()
vim.api.nvim_put({ "* " }, "c", false, true)
end)
keybinds.map("norg", "n", "<leader>h2", function()
vim.api.nvim_put({ "** " }, "c", false, true)
end)
keybinds.map("norg", "n", "<leader>h3", function()
vim.api.nvim_put({ "*** " }, "c", false, true)
end)
keybinds.map("norg", "n", "<leader>h4", function()
vim.api.nvim_put({ "**** " }, "c", false, true)
end)
keybinds.map("norg", "n", "<leader>h5", function()
vim.api.nvim_put({ "***** " }, "c", false, true)
end)
keybinds.map("norg", "n", "<leader>h6", function()
vim.api.nvim_put({ "****** " }, "c", false, true)
end)
-- Keybinds to make moving sections up and down easily
keybinds.map("norg", "n", "]s",
"<cmd>Neorg keybind norg core.integrations.treesitter.next.heading<cr>")
keybinds.map("norg", "n", "<tab>",
"<cmd>Neorg keybind norg core.integrations.treesitter.next.heading<cr>")
keybinds.map("norg", "n", "[s",
"<cmd>Neorg keybind norg core.integrations.treesitter.previous.heading<cr>")
keybinds.map("norg", "n", "<s-tab>",
"<cmd>Neorg keybind norg core.integrations.treesitter.previous.heading<cr>")
-- Insert link
keybinds.map("norg", "n", "<leader>li",
"<cmd>Neorg keybind norg core.integrations.telescope.insert_link<cr>")
-- Insert file link
keybinds.map("norg", "n", "<leader>lf",
"<cmd>Neorg keybind norg core.integrations.telescope.insert_file_link<cr>")
-- ( ) Cycle todo item
keybinds.map("norg", "n", "<leader>vx",
"<cmd>Neorg keybind norg core.qol.todo_items.todo.task_cycle<cr>")
-- Switch workplace
keybinds.map("norg", "n", "<leader>ws",
"<cmd>Neorg keybind norg core.integrations.telescope.switch_workspace<CR>")
-- Code magnifying glass
keybinds.map("norg", "n", "<leader>co",
"<cmd>Neorg keybind norg core.looking-glass.magnify-code-block<cr>")
-- Toggle TOC
keybinds.map("norg", "n", "<leader>to",
"<cmd>Neorg toc<cr>")
-- Toggle list
keybinds.map("norg", "n", "<leader>tl",
"<cmd>lua require('neorg').core.pivot.toggle-list-type()<cr>")
end,
}
}
},
dependencies = {
{
dir = "~/code/vim/neorg-figlet-module",
}
}
})
Actual behavior
This issue is twofold. When I am in a Neorg document, move the cursor to a code block ala
@codeblock supercollider
"hej".postln
@end
and then execute the keybinding for code block looking-glass.magnify-code-block
, I get two errors. One when opening it, another when closing the window again.
When opening the code block, I get:
Error executing vim.schedule lua callback: .../start/neorg/lua/neorg/modules/core/concealer/module.lua:1141: assertion failed!
stack traceback:
[C]: in function 'assert'
.../start/neorg/lua/neorg/modules/core/concealer/module.lua:1141: in function 'render_window_buffer'
.../start/neorg/lua/neorg/modules/core/concealer/module.lua:1156: in function <.../start/neorg/lua/neorg/modules/core/concealer/module.
lua:1153>
When closing the code block, I get:
Error detected while processing WinClosed Autocommands for "<buffer=6>":
Error executing lua callback: Vim:E315: ml_get: invalid lnum: 1
stack traceback:
[C]: in function 'bufload'
vim/_editor.lua: in function 'region'
...ar/neovim/0.9.1/share/nvim/runtime/lua/vim/highlight.lua:35: in function 'range'
...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:82: in function 'update_range'
...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:186: in function 'cb'
...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:736: in function '_do_callback'
...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:176: in function 'invalidate'
...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:877: in function '_on_detach'
...r/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:73: in function <...r/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lu
a:69>
[C]: at 0x01028a7f14
[C]: in function 'pcall'
.../packer/start/neorg/lua/neorg/modules/core/ui/module.lua:200: in function <.../packer/start/neorg/lua/neorg/modules/core/ui/module.l
ua:198>
Expected behavior
No errors on either code block open or close
Steps to reproduce
- Move cursor to a code block
-
:Neorg keybind all core.looking-glass.magnify-code-block
- First error happens (see above)
-
:q
- Second error happens (see above)
Potentially conflicting plugins
No response
Other information
No response
Help
None
Implementation help
I would like to help, but the function render_window_buffer
in the concealer-module is hard to decipher currently as it doesn't have any comments.
can't really help with the issue rn but have you considered using snippets for the insertion of headings?
can't really help with the issue rn but have you considered using snippets for the insertion of headings?
Thanks! I know I should, but I do it this way because of an old habit from markdown/vimwiki ^_^
Wow, what a weird issue! I haven't been able to replicate it on my end. I see that nvim-ts-rainbow
is causing the error when exiting the document, so maybe it is also an indirect culprit of the error when entering a looking glass? If you remove that plugin and try again, do you get any new or different errors?
Wow, what a weird issue! I haven't been able to replicate it on my end. I see that
nvim-ts-rainbow
is causing the error when exiting the document, so maybe it is also an indirect culprit of the error when entering a looking glass? If you remove that plugin and try again, do you get any new or different errors?
Yes were right – and nvim-ts-rainbow is deprecated it seems, and so after removing it, I no longer get errors when closing the code block window, but I still get an error when opening the code block window (but only sometimes???)
Error detected while processing TextChanged Autocommands for "<buffer=9>":
Error executing lua callback: ...rt/neorg/lua/neorg/modules/core/looking-glass/module.lua:68: Invalid window id: 1002
stack traceback:
[C]: in function 'nvim_win_get_cursor'
...rt/neorg/lua/neorg/modules/core/looking-glass/module.lua:68: in function <...rt/neorg/lua/neorg/modules/core/looking-glass/module.lua:63>
Thanks a bunch for the help!
oh this error is much more useful than the previous one, i should be able to fix this relatively soon :)
Thank you and sorry for producing weird errors <_>
On 7 Aug 2023, at 18:30, vhyrro @.***> wrote:
oh this error is much more useful than the previous one, i should be able to fix this relatively soon :)
— Reply to this email directly, view it on GitHub https://github.com/nvim-neorg/neorg/issues/993#issuecomment-1668221209, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFLO64DUV3DH7P6Q7QNURWLXUEJ3JANCNFSM6AAAAAA2RGRJ2A. You are receiving this because you authored the thread.