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

Module core.summary ignores metadata #1108

Closed
1 of 2 tasks
austinbutler opened this issue Oct 8, 2023 · 7 comments
Closed
1 of 2 tasks

Module core.summary ignores metadata #1108

austinbutler opened this issue Oct 8, 2023 · 7 comments
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@austinbutler
Copy link
Contributor

austinbutler commented Oct 8, 2023

Prerequisites

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

Neovim Version

v0.10.0-dev-6823fdb

Neorg setup

require("neorg").setup({
	load = {
		["core.defaults"] = {},
		["core.concealer"] = {},
		["core.dirman"] = {
			config = {
				workspaces = {
					notes = "~/notes",
				},
			},
		},
		["core.presenter"] = { config = { zen_mode = "truezen" } },
		["core.summary"] = {},
		["core.integrations.telescope"] = {},
	},
})

Actual behavior

Neorg generate-workspace-summary generates a summary where everything is under Uncategorized and it seems to ignore the title field, too.

Expected behavior

Neorg generate-workspace-summary uses the metadata.

Steps to reproduce

Add metadata to a note using inject-metadata.

@document.meta
title: My title
description: My description
authors: austin
categories: Tickets
created: 2023-10-08T13:52:16-0800
updated: 2023-10-08T13:52:16-0800
version: 1.1.1
@end

Run generate-workspace-summary.

Potentially conflicting plugins

No response

Other information

Possibly a different issue with the same module: #1085.

Help

None

Implementation help

No response

@austinbutler austinbutler added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label Oct 8, 2023
@github-project-automation github-project-automation bot moved this to added-updated-reopened in sorting neorg issue tracker Oct 8, 2023
@snomics
Copy link

snomics commented Oct 10, 2023

To add some information, categories are taken into account once a file has been opened. For this file only.

@caprilesport
Copy link

Is the behaviour commented by @snomics supposed to be the default?

I'm also suffering a bit with it, as sometimes new files are added in a workspace and when i re-generate the summary I have to open all files to have the correct indexing.

@aswa2ds
Copy link
Contributor

aswa2ds commented Nov 2, 2023

I met the same situation. I found that Neorg try to find norg_meta in norg:children() to parse *.norg files' metadata. While a file is closed, the norg_meta parser will not be found. So they will be Uncategoried. I solved by modified the get_document_metadata function in "neorg/lua/neorg/modules/core/integrations/treesitter" like this, and sovled your question at the same time @caprilesport :

    get_document_metadata = function(buf, no_trim)
        buf = buf or 0

        local languagetree = vim.treesitter.get_parser(buf, "norg_meta")    <======

        if not languagetree then
            return
        end

        local result = {}

        -- for _, tree in ipairs(languagetree:children()) do   <======
            -- if tree:lang() ~= "norg_meta" then   <======
            --     return   <======
            -- end   <======
            local tree = languagetree   <======

            ...

                    result[key_content] = (
                        node:next_named_sibling() and parse_data(node:next_named_sibling()) or vim.NIL
                    )
                end
            end
        -- end   <======

        return result
    end,

@definitelynotrazu
Copy link

definitelynotrazu commented Nov 2, 2023

I met the same situation. I found that Neorg try to find norg_meta in norg:children() to parse *.norg files' metadata. While a file is closed, the norg_meta parser will not be found. So they will be Uncategoried. I solved by modified the get_document_metadata function in "neorg/lua/neorg/modules/core/integrations/treesitter" like this, and sovled your question at the same time @caprilesport :

    get_document_metadata = function(buf, no_trim)
        buf = buf or 0

        local languagetree = vim.treesitter.get_parser(buf, "norg_meta")    <======

        if not languagetree then
            return
        end

        local result = {}

        -- for _, tree in ipairs(languagetree:children()) do   <======
            -- if tree:lang() ~= "norg_meta" then   <======
            --     return   <======
            -- end   <======
            local tree = languagetree   <======

            ...

                    result[key_content] = (
                        node:next_named_sibling() and parse_data(node:next_named_sibling()) or vim.NIL
                    )
                end
            end
        -- end   <======

        return result
    end,

Having the same issue myself, if your patch fixes it without any side effects, maybe you could make a PR?

@aswa2ds
Copy link
Contributor

aswa2ds commented Nov 3, 2023

I met the same situation. I found that Neorg try to find norg_meta in norg:children() to parse *.norg files' metadata. While a file is closed, the norg_meta parser will not be found. So they will be Uncategoried. I solved by modified the get_document_metadata function in "neorg/lua/neorg/modules/core/integrations/treesitter" like this, and sovled your question at the same time @caprilesport :

    get_document_metadata = function(buf, no_trim)
        buf = buf or 0

        local languagetree = vim.treesitter.get_parser(buf, "norg_meta")    <======

        if not languagetree then
            return
        end

        local result = {}

        -- for _, tree in ipairs(languagetree:children()) do   <======
            -- if tree:lang() ~= "norg_meta" then   <======
            --     return   <======
            -- end   <======
            local tree = languagetree   <======

            ...

                    result[key_content] = (
                        node:next_named_sibling() and parse_data(node:next_named_sibling()) or vim.NIL
                    )
                end
            end
        -- end   <======

        return result
    end,

Having the same issue myself, if your patch fixes it without any side effects, maybe you could make a PR?

Yeah, I'm considering make a PR. But this patch did not solve the problem that summary ignores the title field of metadata. And today I rewrote the get_document_metadata function and taste good. I'll make a PR later.

@pysan3
Copy link
Contributor

pysan3 commented Nov 5, 2023

Can this issue be closed? @aswa2ds @vhyrro

@austinbutler
Copy link
Contributor Author

All seems to be working now, so I'll close this.

@github-project-automation github-project-automation bot moved this from added-updated-reopened to done in sorting neorg issue tracker Dec 22, 2023
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

6 participants