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

Key Value confusion / misallignment in core.integrations.treesitter.get_document_metadata() #51

Open
2 tasks done
git-girl opened this issue May 28, 2023 · 0 comments
Open
2 tasks done

Comments

@git-girl
Copy link

Prerequisites

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

Neovim Version

NVIM v0.9.0 Build type: Release LuaJIT 2.1.0-beta3

Neorg setup

require('neorg').setup {
  load = { 
    ["core.defaults"] = {}, 
    ["core.dirman"] = { -- Manages Neorg workspaces
    config = {
      workspaces = {
        -- TODO: get a good subfolder structure here that mirrors my actual dirs
        general = "~/Notes/general",
        work =  "~/Notes/work",
        uni =   "~/Notes/uni"
      }
    }
  },
  ["core.journal"] = { 
    config = {
      strategy = "flat"
    }
  },
  ["core.export"] = {}, 
  -- manoeuvre has been depreceated since 1.0.0
  -- ["core.manoeuvre"] = {}, 
  ["core.concealer"] = {}, 
  ["core.summary"] = {
    config = {
      -- switch to headings when ready
      strategy = "metadata"
    }
  }, 
  -- will work in nvim 0.10 
  -- ["core.ui.calendar"] = {}, 
  ["core.presenter"] = {
    config = { 
      zen_mode = "truezen" 
    }
  }, 
  ["core.integrations.telescope"] = {},
  ["external.auto-cats"] = {},
},
}

require('nvim-treesitter.configs').setup {
  ensure_installed = { "norg" --[[ other parsers you would wish to have ]] },
  highlight = { 
    -- Be sure to enable highlights if you haven't!
    enable = true,
  }
}

Actual behavior

I started on a plugin that is supposed to auto inject and update the metadata categories. It also directories from the path relative to the workspace. The full plugin is at https://github.com/git-girl/neorg-auto-cats.
For updating the metadata if it is already there i used the core.integrations.treesitter.get_document_metadata() method. when printing out the returned table i get:

{
  categories = "created: 2023-05-23",
  description = "authors: cherry-cat",
  title = "index",
  updated = "2023-05-28",
  version = "1.1.1"
}

the actual metadata is this though:

@document.meta
title: index
description: 
authors: cherry-cat
categories: 
created: 2023-05-23
updated: 2023-05-28
version: 1.1.1
@end

So the empty attributes are being filled with the key and value of the one below.

I think this is actually an issue in nvim-neorg/tree-sitter-norg as the video shows that the key value pairs are mismatched in treesitter.

Expected behavior

For core.integration.treesitter.get_document_metadata() to return :
{
categories = "",
created: "2023-05-23",
description = ""
authors: cherry-cat,
title = "index",
updated = "2023-05-28",
version = "1.1.1"
}

when the document has this metadata: 
```norg 
@document.meta
title: index
description: 
authors: cherry-cat
categories: 
created: 2023-05-23
updated: 2023-05-28
version: 1.1.1
@end

Steps to reproduce

  1. Open a .norg file
  2. Run :Neorg inject_metadata (that leaves empty metadata attributes)
  3. Run :lua print(vim.inspect(neorg.modules.get_module('core.integrations.treesitter').get_document_metadata()))

Potentially conflicting plugins

This is my packer setup idk if i messed stuff up there:

    use {
      'nvim-neorg/neorg',
      after = { "nvim-treesitter" }, -- You may want to specify Telescope here as well
      requires = { 
        {'nvim-lua/plenary.nvim' },
        {'Pocco81/true-zen.nvim'},
        {'nvim-neorg/neorg-telescope'},
      }, 
      run = ":Neorg sync-parsers",
    } 

Other information

:TSInstallInfo shows:

norg              [✓] installed
norg_meta         [✓] installed

Here is a video showing that there is something wrong with the actual treesitter symbols:
https://asciinema.org/a/X9LbaVZjO1cpIRt3nIdkwPPtA

Help

I dont know i'll try checkig stuff out and if i see an easy fix then id make a pr but i dont know C at even a basic level and am scared of it.

Implementation help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant