Skip to content
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

[nvim nightly] is_metadata_present fails with attempt to call method 'range' (a nil value) #1579

Open
2 tasks done
mikesmithgh opened this issue Sep 11, 2024 · 5 comments
Open
2 tasks done
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@mikesmithgh
Copy link

mikesmithgh commented Sep 11, 2024

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

NVIM v0.11.0-dev-754+ga30afeeb8

Neorg setup

return {
  {
    'nvim-neorg/neorg',
    enabled = true,
    lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default
    version = '*', -- Pin Neorg to the latest stable release
    config = function()
      require('neorg').setup({
        load = {
          ['core.defaults'] = {}, -- Loads default behaviour
          ['core.dirman'] = { -- Manages Neorg workspaces
            config = {
              default_workspace = 'notes',
              workspaces = {
                notes = '~/neorg/notes',
              },
              index = 'index.norg', -- The name of the main (root) .norg file
              use_popup = true,
            },
          },
          ['core.summary'] = {},
          ['core.concealer'] = {
            -- config = {
            --   icons = {
            --     todo = {
            --       pending = {
            --         icon = 'y',
            --       },
            --     },
            --   },
            -- },
          }, -- Adds pretty icons to your documents
          ['core.itero'] = {}, -- <M-CR> to add header/list items
          ['core.promo'] = {}, -- promotes/demotes headers, etc
          ['core.qol.toc'] = {},
          ['core.qol.todo_items'] = {},
          ['core.export'] = {},
        },
      })
    end,
  },
}

Actual behavior

Saving a norg file results in the following error and norg metadata is not automatically updated (e.g, updated date)

Error detected while processing BufWritePre Autocommands for "*.norg":
Error executing lua callback: ...eorg/lua/neorg/modules/core/esupports/metagen/module.lua:227: attempt to call method 'range' (a nil value)
stack traceback:
	...eorg/lua/neorg/modules/core/esupports/metagen/module.lua:227: in function 'is_metadata_present'
	...eorg/lua/neorg/modules/core/esupports/metagen/module.lua:309: in function 'update_metadata'
	...eorg/lua/neorg/modules/core/esupports/metagen/module.lua:424: in function <...eorg/lua/neorg/modules/core/esupports/metagen/module.lua:423>

Expected behavior

Saving a norg file has no errorr and norg metadata is automatically updated (e.g, updated date)

Steps to reproduce

Open a norg file and save the file (:w)

Example norg metadata:

@document.meta
title: Test
description: test
authors: mike
categories: [
  test1
  test2
]
created: 2024-08-01T10:22:27-0500
updated: 2024-09-03T10:23:24-0500
version: 1.1.1
@end

Potentially conflicting plugins

No response

Other information

I can't reproduce on latest stable version of nvim NVIM v0.10.1
OS: MacOS 14.6.1 (23G93)

Help

None

Implementation help

No response

@mikesmithgh mikesmithgh added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label Sep 11, 2024
@mikesmithgh
Copy link
Author

I'm using neorg v9.1.1 and the error is occurring here

https://github.com/nvim-neorg/neorg/blob/v9.1.1/lua/neorg/modules/core/esupports/metagen/module.lua#L227

@tokisuno
Copy link

image
I'm also having the same problem on nightly.

@olimorris
Copy link

olimorris commented Sep 26, 2024

This has caused a lot of plugin's to fail on nightly.

I resolved it in my plugin recently:

olimorris/codecompanion.nvim#190

Required me to be specific with the tree-sitter range.

@mikesmithgh
Copy link
Author

FYI for a workaround you can disable updating the date on save by setting update_date to false from https://github.com/nvim-neorg/neorg/wiki/Metagen#update_date

Here is my config

return {
  {
    'nvim-neorg/neorg',
    enabled = true,
    lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default
    version = '*', -- Pin Neorg to the latest stable release
    config = function()
      require('neorg').setup({
        load = {
          ['core.defaults'] = {}, -- Loads default behaviour
          ['core.dirman'] = { -- Manages Neorg workspaces
            config = {
              default_workspace = 'notes',
              workspaces = {
                notes = '~/neorg/notes',
              },
              index = 'index.norg', -- The name of the main (root) .norg file
              use_popup = true,
            },
          },
          ['core.summary'] = {},
          ['core.concealer'] = {}, -- Adds pretty icons to your documents
          ['core.itero'] = {}, -- <M-CR> to add header/list items
          ['core.promo'] = {}, -- promotes/demotes headers, etc
          ['core.qol.toc'] = {},
          ['core.qol.todo_items'] = {},
          ['core.export'] = {},
          -- https://github.com/nvim-neorg/neorg/wiki/Metagen
          ['core.esupports.metagen'] = { config = { update_date = false } }, -- do not update date until https://github.com/nvim-neorg/neorg/issues/1579 fixed
        },
      })
    end,
  },
}

@tokisuno
Copy link

FYI for a workaround you can disable updating the date on save by setting update_date to false from https://github.com/nvim-neorg/neorg/wiki/Metagen#update_date

Here is my config

return {
  {
    'nvim-neorg/neorg',
    enabled = true,
    lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default
    version = '*', -- Pin Neorg to the latest stable release
    config = function()
      require('neorg').setup({
        load = {
          ['core.defaults'] = {}, -- Loads default behaviour
          ['core.dirman'] = { -- Manages Neorg workspaces
            config = {
              default_workspace = 'notes',
              workspaces = {
                notes = '~/neorg/notes',
              },
              index = 'index.norg', -- The name of the main (root) .norg file
              use_popup = true,
            },
          },
          ['core.summary'] = {},
          ['core.concealer'] = {}, -- Adds pretty icons to your documents
          ['core.itero'] = {}, -- <M-CR> to add header/list items
          ['core.promo'] = {}, -- promotes/demotes headers, etc
          ['core.qol.toc'] = {},
          ['core.qol.todo_items'] = {},
          ['core.export'] = {},
          -- https://github.com/nvim-neorg/neorg/wiki/Metagen
          ['core.esupports.metagen'] = { config = { update_date = false } }, -- do not update date until https://github.com/nvim-neorg/neorg/issues/1579 fixed
        },
      })
    end,
  },
}

noted. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.
Projects
None yet
Development

No branches or pull requests

3 participants