Queries Module - nvim-neorg/neorg Wiki

Queries Module

Summary

TS wrapper in order to fetch nodes using a custom table.

Overview

This module uses tree-like tables in order to fetch useful informations from a TS tree.

Usage

How to Apply

Configuration

No configuration provided

Developer Usage

Public API

This segment will detail all of the functions core.queries.native exposes. All of these functions reside in the public table.

Examples

Get the content of all todo_item1 in a norg file

local buf = 1 -- The buffer to query informations

--- @type core.queries.native.tree_node[]
local tree = {
    {
        query = { "first", "document_content" },
        subtree = {
            {
                query = { "all", "generic_list" },
                recursive = true,
                subtree = {
                    {
                        query = { "all", "todo_item1" },
                    },
                },
            },
        },
    },
}

-- Get a list of { node, buf }
local nodes = module.required["core.queries.native"].query_nodes_from_buf(tree, buf)
local extracted_nodes = module.required["core.queries.native"].extract_nodes(nodes)

-- Free the text in memory after reading nodes
module.required["core.queries.native"].delete_content(buf)

print(nodes, extracted_nodes)

Extra Info

Version

This module supports at least version 0.0.9. The current Neorg version is 0.0.9.

Imports

This module does not import any other files.

Requires

Required by