neorg icon indicating copy to clipboard operation
neorg copied to clipboard

journal module toc update fails if additional folders are present in year folders

Open redongh opened this issue 11 months ago • 2 comments

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.10.2

Neorg setup

require("neorg").setup { load = { ["core.defaults"] = {}, ["core.concealer"] = {}, ["core.dirman"] = { config = { workspaces = { mynotes = "~/docs/neorg/mynotes", }, default_workspace = "mynotes", }, }, }, }

Actual behavior

Updating the TOC (:Neorg journal toc update) fails with
Error executing vim.schedule lua callback: ...vim/lazy/neorg/lua/neorg/modules/core/journal/module.lua:394: attempt to compare number with nil

Expected behavior

Updating the TOC (:Neorg journal toc update) manages to update TOC because it skips over non-parseable folder entries.

Steps to reproduce

  1. create and save at least one journal entry: :Neorg journal today
  2. create subfolder(s) in …/journal/2025/ : mkdir weekly <yourneorgpath>/journal/2025/
  3. update TOC: :Neorg journal toc update

Potentially conflicting plugins

No response

Other information

A word of explanation on why i created additional folders within the year folders: In order to have some sort of higher-level overview of certain actions, I added the subfolders weekly and quarterly into my journal's year folder. in those subfolders, I (currently manually) add 01.norg ... 52.norg as well as q1.norg ... q4.norg. Links to those are provided within daily journal template (which therefore currently needs to be adjusted every week).

Help

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

Implementation help

Could there be any specific reason why folders that cannot be parsed to month-numbers should not be present within the journal's year folder? Also note I'm not at all experienced with Lua coding so probably would struggle with everything beyond a local fix (=within the scope of the update function).

redongh avatar Feb 10 '25 12:02 redongh

PR sent (see mention above), not sure if this is how a more experienced Lua coder would implement this but seems to fix this issue.

redongh avatar Feb 10 '25 13:02 redongh

After upgrade to NVIM 0.11 on Mac, I can no longer update journal TOC. The message that I get is:

Error executing vim.schedule lua callback: .../n  
eovim/0.11.0/share/nvim/runtime/lua/vim/treesitt  
er.lua:104: Buffer 12 must be loaded to create p  
arser  
stack traceback:  
[C]: in function 'error'  
.../neovim/0.11.0/share/nvim/runtime/lua/vim/tr  
eesitter.lua:104: in function 'get_parser'  
...ua/neorg/modules/core/integrations/treesitte  
r/module.lua:922: in function 'get_ts_parser'  
...ua/neorg/modules/core/integrations/treesitte  
r/module.lua:741: in function 'get_document_meta  
data'  
...vim/lazy/neorg/lua/neorg/modules/core/journa  
l/module.lua:257: in function 'get_title'  
...vim/lazy/neorg/lua/neorg/modules/core/journa  
l/module.lua:300: in function <...vim/lazy/neorg  
/lua/neorg/modules/core/journal/module.lua:298> 

This message is repeated for every single journal entry, just with a different buffer number. TOC regeneration worked perfectly on NVIM 0.10.x

saxon1964 avatar Apr 03 '25 21:04 saxon1964