Skip to content
Shawon edited this page Jun 8, 2025 · 5 revisions

🔩 YAML options

Tip

You can find the type definitions in definitions/renderers/yaml.lua.

Options that change how YAML blocks are shown are part of this. See default values in here.

---@type markview.config.yaml
yaml = {
    enable = true,

    properties = {
        enable = true,

        data_types = {
            ["text"] = {
                text = "󰗊 ", hl = "MarkviewIcon4"
            },
            ["list"] = {
                text = "󰝖 ", hl = "MarkviewIcon5"
            },
            ["number"] = {
                text = "", hl = "MarkviewIcon6"
            },
            ["checkbox"] = {
                ---@diagnostic disable
                text = function (_, item)
                    return item.value == "true" and "󰄲 " or "󰄱 "
                end,
                ---@diagnostic enable
                hl = "MarkviewIcon6"
            },
            ["date"] = {
                text = "󰃭 ", hl = "MarkviewIcon2"
            },
            ["date_&_time"] = {
                text = "󰥔 ", hl = "MarkviewIcon3"
            }
        },

        default = {
            use_types = true,

            border_top = nil,
            border_middle = nil,
            border_bottom = nil,

            border_hl = nil,
        },

        ["^tags$"] = {
            use_types = false,

            text = "󰓹 ",
            hl = "MarkviewIcon0"
        },
        ["^aliases$"] = {
            match_string = "^aliases$",
            use_types = false,

            text = "󱞫 ",
            hl = "MarkviewIcon2"
        },
        ["^cssclasses$"] = {
            match_string = "^cssclasses$",
            use_types = false,

            text = "",
            hl = "MarkviewIcon3"
        },


        ["^publish$"] = {
            match_string = "^publish$",
            use_types = false,

            text = "󰅧 ",
            hl = "MarkviewIcon5"
        },
        ["^permalink$"] = {
            match_string = "^permalink$",
            use_types = false,

            text = "",
            hl = "MarkviewIcon2"
        },
        ["^description$"] = {
            match_string = "^description$",
            use_types = false,

            text = "󰋼 ",
            hl = "MarkviewIcon0"
        },
        ["^image$"] = {
            match_string = "^image$",
            use_types = false,

            text = "󰋫 ",
            hl = "MarkviewIcon4"
        },
        ["^cover$"] = {
            match_string = "^cover$",
            use_types = false,

            text = "󰹉 ",
            hl = "MarkviewIcon2"
        }
    }
}

enable

  • type: boolean default: true

Allows previewing YAML.

properties

Changes how YAML properties are shown.

---@type markview.config.yaml.properties
properties = {
    enable = true,

    data_types = {
        ["text"] = {
            text = " 󰗊 ", hl = "MarkviewIcon4"
        },
        ["list"] = {
            text = " 󰝖 ", hl = "MarkviewIcon5"
        },
        ["number"] = {
            text = "", hl = "MarkviewIcon6"
        },
        ["checkbox"] = {
            ---@diagnostic disable
            text = function (_, item)
                return item.value == "true" and " 󰄲 " or " 󰄱 "
            end,
            ---@diagnostic enable
            hl = "MarkviewIcon6"
        },
        ["date"] = {
            text = " 󰃭 ", hl = "MarkviewIcon2"
        },
        ["date_&_time"] = {
            text = " 󰥔 ", hl = "MarkviewIcon3"
        }
    },

    default = {
        use_types = true,

        border_top = "",
        border_middle = "",
        border_bottom = " ╰╸",

        border_hl = "MarkviewComment"
    },

    ["^tags$"] = {
        match_string = "^tags$",
        use_types = false,

        text = " 󰓹 ",
        hl = nil
    },
    ["^aliases$"] = {
        match_string = "^aliases$",
        use_types = false,

        text = " 󱞫 ",
        hl = nil
    },
    ["^cssclasses$"] = {
        match_string = "^cssclasses$",
        use_types = false,

        text = "",
        hl = nil
    },


    ["^publish$"] = {
        match_string = "^publish$",
        use_types = false,

        text = "",
        hl = nil
    },
    ["^permalink$"] = {
        match_string = "^permalink$",
        use_types = false,

        text = "",
        hl = nil
    },
    ["^description$"] = {
        match_string = "^description$",
        use_types = false,

        text = " 󰋼 ",
        hl = nil
    },
    ["^image$"] = {
        match_string = "^image$",
        use_types = false,

        text = " 󰋫 ",
        hl = nil
    },
    ["^cover$"] = {
        match_string = "^cover$",
        use_types = false,

        text = " 󰹉 ",
        hl = nil
    }
},

enable

  • type: boolean default: true

Self-explanatory.

data_types

  • type: { [string]: markview.config.yaml.properties.opts } default

Configuration for various data types.

text

Configuration for YAML properties whose value is a text.

---@type markview.config.yaml.properties.opts
["text"] = {
    text = "󰗊 ",
    hl = "MarkviewIcon4"
},
text
  • type: string | fun(bufnr: integer, item: markview.parsed.yaml.properties): string

Text shown before the property name(like an icon).

hl
  • type: string | fun(bufnr: integer, item: markview.parsed.yaml.properties): string

Highlight group for text.

list

Configuration for YAML properties whose value is a list. Same as text.

number

Configuration for YAML properties whose value is a number. Same as text.

checkbox

Configuration for YAML properties whose value is a boolean. Same as text.

date

Also see,

Configuration for YAML properties whose value is a date. Same as text.

date_&_time

Also see,

Configuration for YAML properties whose value is a date & time. Same as text.

default

Default configuration for YAML properties.

use_types

  • type: boolean default: true

Whether to use the data types configuration. See data_types.

text
  • type: string | fun(bufnr: integer, item: markview.parsed.yaml.properties): string

Text shown before the property name(like an icon).

hl
  • type: string | fun(bufnr: integer, item: markview.parsed.yaml.properties): string

Highlight group for text.

[string]

Configuration for YAML properties that match string. Same as default.

Clone this wiki locally