diff --git a/lua/neorg/modules/core/highlights/module.lua b/lua/neorg/modules/core/highlights/module.lua index 732e33840..6c9ee2d8a 100644 --- a/lua/neorg/modules/core/highlights/module.lua +++ b/lua/neorg/modules/core/highlights/module.lua @@ -70,6 +70,7 @@ module.config.public = { document_meta = { key = "+@field", value = "+@string", + number = "+@number", trailing = "+@repeat", title = "+@text.title", description = "+@label", diff --git a/lua/neorg/modules/core/integrations/treesitter/module.lua b/lua/neorg/modules/core/integrations/treesitter/module.lua index f187964c9..d9017aa96 100644 --- a/lua/neorg/modules/core/integrations/treesitter/module.lua +++ b/lua/neorg/modules/core/integrations/treesitter/module.lua @@ -128,7 +128,7 @@ module.config.public = { url = "https://github.com/nvim-neorg/tree-sitter-norg-meta", files = { "src/parser.c" }, branch = "main", - revision = "e93dcbc56a472649547cfc288f10ae4a93ef8795", + revision = "a479d1ca05848d0b51dd25bc9f71a17e0108b240", }, }, } @@ -562,6 +562,7 @@ module.public = { return descendant end, + get_document_metadata = function(buf, no_trim) buf = buf or 0 @@ -601,9 +602,12 @@ module.public = { local function parse_data(node) return neorg.lib.match(node:type())({ - value = function() + string = function() return trim(module.public.get_node_text(node, buf)) end, + number = function() + return tonumber(module.public.get_node_text(node, buf)) + end, array = function() local resulting_array = {} diff --git a/queries/norg_meta/highlights.scm b/queries/norg_meta/highlights.scm index 44c963930..c2af388a3 100644 --- a/queries/norg_meta/highlights.scm +++ b/queries/norg_meta/highlights.scm @@ -1,38 +1,33 @@ ; Regular keys and values (key) @neorg.tags.ranged_verbatim.document_meta.key -(value) @neorg.tags.ranged_verbatim.document_meta.value - -; Values within arrays -(array - (value) @neorg.tags.ranged_verbatim.document_meta.array.value -) +(string) @neorg.tags.ranged_verbatim.document_meta.string +(number) @neorg.tags.ranged_verbatim.document_meta.number ; Literals "{" @neorg.tags.ranged_verbatim.document_meta.object.bracket "}" @neorg.tags.ranged_verbatim.document_meta.object.bracket "[" @neorg.tags.ranged_verbatim.document_meta.array.bracket "]" @neorg.tags.ranged_verbatim.document_meta.array.bracket -"~\n" @neorg.tags.ranged_verbatim.document_meta.trailing ; Special Highlights (pair (key) @_key - (value) @neorg.tags.ranged_verbatim.document_meta.title + (string) @neorg.tags.ranged_verbatim.document_meta.title (#eq? @_key "title") ) (pair (key) @_key - (value) @neorg.tags.ranged_verbatim.document_meta.description + (string) @neorg.tags.ranged_verbatim.document_meta.description (#eq? @_key "description") ) (pair (key) @_key [ - (value) @neorg.tags.ranged_verbatim.document_meta.authors + (string) @neorg.tags.ranged_verbatim.document_meta.authors (array - (value) @neorg.tags.ranged_verbatim.document_meta.authors + (string) @neorg.tags.ranged_verbatim.document_meta.authors ) ] (#eq? @_key "authors") @@ -41,9 +36,9 @@ (pair (key) @_key [ - (value) @neorg.tags.ranged_verbatim.document_meta.categories + (string) @neorg.tags.ranged_verbatim.document_meta.categories (array - (value) @neorg.tags.ranged_verbatim.document_meta.categories + (string) @neorg.tags.ranged_verbatim.document_meta.categories ) ] (#eq? @_key "categories") @@ -51,18 +46,18 @@ (pair (key) @_key - (value) @neorg.tags.ranged_verbatim.document_meta.created + (string) @neorg.tags.ranged_verbatim.document_meta.created (#eq? @_key "created") ) (pair (key) @_key - (value) @neorg.tags.ranged_verbatim.document_meta.updated + (string) @neorg.tags.ranged_verbatim.document_meta.updated (#eq? @_key "updated") ) (pair (key) @_key - (value) @neorg.tags.ranged_verbatim.document_meta.version + (string) @neorg.tags.ranged_verbatim.document_meta.version (#eq? @_key "version") )