Skip to content

Metagen

github-actions[bot] edited this page Mar 25, 2024 · 356 revisions

core.esupports.metagen

Manually Writing Metadata? No Thanks

The metagen module automatically places relevant metadata at the top of your .norg files.

Overview

The metagen module exposes two commands - :Neorg inject-metadata and :Neorg update-metadata.

  • The inject-metadata command will remove any existing metadata and overwrite it with fresh information.
  • The update-metadata preserves existing info, updating things like the updated fields (when the file was last edited) as well as a few other non-destructive fields.

Configuration

  • author
    (string)

    Custom author name that overrides default value if not nil or empty Default value is autopopulated by querying the current user's system username.

    ""
  • delimiter
    (string)

    Custom delimiter between tag and value

    ": "
  • tab
    (string)

    How to generate a tabulation inside the @document.meta tag

    ""
  • template
    (nil)

    Custom template to use for generating content inside @document.meta tag

    default_template
  • timezone
    (string)

    Timezone information in the timestamps

    • "utc" the timestamp is in UTC+0
    • "local" the timestamp is in the local timezone
    • "implicit-local" like "local", but the timezone information is omitted from the timestamp
    "local"
  • type
    (string)

    One of "none", "auto" or "empty"

    • "none" generates no metadata
    • "auto" generates metadata if it is not present
    • "empty" generates metadata only for new files/buffers.
    "none"
  • undojoin_updates
    (boolean)

    Whether or not to call :h :undojoin just before changing the timestamp in update_metadata. This will make your undo key undo the last change before writing the file in addition to the timestamp change. This will move your cursor to the top of the file. For users with an autosave plugin, this option must be paired with keybinds for undo/redo to avoid problems with undo tree branching:

    ["core.keybinds"] = {
    config = {
    hook = function(keybinds)
    keybinds.map("norg", "n", "u", function()
    require("neorg.modules.core.esupports.metagen.module").public.skip_next_update()
    local k = vim.api.nvim_replace_termcodes("u<c-o>", true, false, true)
    vim.api.nvim_feedkeys(k, 'n', false)
    end)
    keybinds.map("norg", "n", "<c-r>", function()
    require("neorg.modules.core.esupports.metagen.module").public.skip_next_update()
    local k = vim.api.nvim_replace_termcodes("<c-r><c-o>", true, false, true)
    vim.api.nvim_feedkeys(k, 'n', false)
    end)
    end,
    },
    },
    false
  • update_date
    (boolean)

    Whether updated date field should be automatically updated on save if required

    true

Required Modules