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

💻 Typst options

Tip

You can find type definitions in definitions/renderers/typst.lua.

Options that affect how typst is shown in previews are part of this. You can find the default values here.

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

    code_blocks = {
        enable = true,

        style = "block",
        text_direction = "right",

        min_width = 60,
        pad_amount = 3,
        pad_char = " ",

        text = "󰣖 Code",

        hl = "MarkviewCode",
        text_hl = "MarkviewIcon5"
    },

    code_spans = {
        enable = true,

        padding_left = " ",
        padding_right = " ",

        hl = "MarkviewCode"
    },

    escapes = {
        enable = true
    },

    headings = {
        enable = true,
        shift_width = 1,

        heading_1 = {
            style = "icon",
            sign = "󰌕 ", sign_hl = "MarkviewHeading1Sign",

            icon = "󰼏  ", hl = "MarkviewHeading1",
        },
        heading_2 = {
            style = "icon",
            sign = "󰌖 ", sign_hl = "MarkviewHeading2Sign",

            icon = "󰎨  ", hl = "MarkviewHeading2",
        },
        heading_3 = {
            style = "icon",

            icon = "󰼑  ", hl = "MarkviewHeading3",
        },
        heading_4 = {
            style = "icon",

            icon = "󰎲  ", hl = "MarkviewHeading4",
        },
        heading_5 = {
            style = "icon",

            icon = "󰼓  ", hl = "MarkviewHeading5",
        },
        heading_6 = {
            style = "icon",

            icon = "󰎴  ", hl = "MarkviewHeading6",
        }
    },

    labels = {
        enable = true,

        default = {
            hl = "MarkviewInlineCode",
            padding_left = " ",
            icon = "",
            padding_right = " "
        }
    },

    list_items = {
        enable = true,

        indent_size = function (buffer)
            if type(buffer) ~= "number" then
                return vim.bo.shiftwidth or 4;
            end

            --- Use 'shiftwidth' value.
            return vim.bo[buffer].shiftwidth or 4;
        end,
        shift_width = 4,

        marker_minus = {
            add_padding = true,

            text = "",
            hl = "MarkviewListItemMinus"
        },

        marker_plus = {
            add_padding = true,

            text = "%d)",
            hl = "MarkviewListItemPlus"
        },

        marker_dot = {
            add_padding = true,
        }
    },

    math_blocks = {
        enable = true,

        text = " 󰪚 Math ",
        pad_amount = 3,
        pad_char = " ",

        hl = "MarkviewCode",
        text_hl = "MarkviewCodeInfo"
    },

    math_spans = {
        enable = true,

        padding_left = " ",
        padding_right = " ",

        hl = "MarkviewInlineCode"
    },

    raw_blocks = {
        enable = true,

        style = "block",
        label_direction = "right",

        sign = true,

        min_width = 60,
        pad_amount = 3,
        pad_char = " ",

        border_hl = "MarkviewCode",

        default = {
            block_hl = "MarkviewCode",
            pad_hl = "MarkviewCode"
        },

        ["diff"] = {
            block_hl = function (_, line)
                if line:match("^%+") then
                    return "MarkviewPalette4";
                elseif line:match("^%-") then
                    return "MarkviewPalette1";
                else
                    return "MarkviewCode";
                end
            end,
            pad_hl = "MarkviewCode"
        }
    },

    raw_spans = {
        enable = true,

        padding_left = " ",
        padding_right = " ",

        hl = "MarkviewInlineCode"
    },

    reference_links = {
        enable = true,

        default = {
            icon = "",
            hl = "MarkviewHyperlink"
        },
    },

    subscripts = {
        enable = true,

        hl = "MarkviewSubscript"
    },

    superscripts = {
        enable = true,

        hl = "MarkviewSuperscript"
    },

    symbols = {
        enable = true,

        hl = "Special"
    },

    terms = {
        enable = true,

        default = {
            text = "",
            hl = "MarkviewPalette6Fg"
        },
    },

    url_links = {
        enable = true,

        default = {
            icon = "",
            hl = "MarkviewEmail"
        },

        ["github%.com/[%a%d%-%_%.]+%/?$"] = {
            --- github.com/<user>

            icon = "",
            hl = "MarkviewPalette0Fg"
        },
        ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/?$"] = {
            --- github.com/<user>/<repo>

            icon = "",
            hl = "MarkviewPalette0Fg"
        },
        ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+/tree/[%a%d%-%_%.]+%/?$"] = {
            --- github.com/<user>/<repo>/tree/<branch>

            icon = "",
            hl = "MarkviewPalette0Fg"
        },
        ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+/commits/[%a%d%-%_%.]+%/?$"] = {
            --- github.com/<user>/<repo>/commits/<branch>

            icon = "",
            hl = "MarkviewPalette0Fg"
        },

        ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/releases$"] = {
            --- github.com/<user>/<repo>/releases

            icon = "",
            hl = "MarkviewPalette0Fg"
        },
        ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/tags$"] = {
            --- github.com/<user>/<repo>/tags

            icon = "",
            hl = "MarkviewPalette0Fg"
        },
        ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/issues$"] = {
            --- github.com/<user>/<repo>/issues

            icon = "",
            hl = "MarkviewPalette0Fg"
        },
        ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/pulls$"] = {
            --- github.com/<user>/<repo>/pulls

            icon = "",
            hl = "MarkviewPalette0Fg"
        },

        ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/wiki$"] = {
            --- github.com/<user>/<repo>/wiki

            icon = "",
            hl = "MarkviewPalette0Fg"
        },

        ["developer%.mozilla%.org"] = {
            priority = -9999,

            icon = "󰖟 ",
            hl = "MarkviewPalette5Fg"
        },

        ["w3schools%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette4Fg"
        },

        ["stackoverflow%.com"] = {
            priority = -9999,

            icon = "󰓌 ",
            hl = "MarkviewPalette2Fg"
        },

        ["reddit%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette2Fg"
        },

        ["github%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette6Fg"
        },

        ["gitlab%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette2Fg"
        },

        ["dev%.to"] = {
            priority = -9999,

            icon = "󱁴 ",
            hl = "MarkviewPalette0Fg"
        },

        ["codepen%.io"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette6Fg"
        },

        ["replit%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette2Fg"
        },

        ["jsfiddle%.net"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette5Fg"
        },

        ["npmjs%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette0Fg"
        },

        ["pypi%.org"] = {
            priority = -9999,

            icon = "󰆦 ",
            hl = "MarkviewPalette0Fg"
        },

        ["mvnrepository%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette1Fg"
        },

        ["medium%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette6Fg"
        },

        ["linkedin%.com"] = {
            priority = -9999,

            icon = "󰌻 ",
            hl = "MarkviewPalette5Fg"
        },

        ["news%.ycombinator%.com"] = {
            priority = -9999,

            icon = "",
            hl = "MarkviewPalette2Fg"
        },
    }
},

enable

  • type: boolean default: true

Allows viewing typst in preview.

code_blocks

Changes how code blocks look.

---@type markview.config.typst.code_blocks
code_blocks = {
    enable = true,

    hl = "MarkviewCode",

    min_width = 60,
    pad_amount = 3,
    pad_char = " ",

    style = "block",

    text = "󰣖 Code",
    text_direction = "right",
    text_hl = "MarkviewIcon5"
},

enable

  • type: boolean default: true

Self-explanatory.

hl

  • type: string default: "MarkviewCode"

Highlight group used for the background.

min_width

  • type: integer default: 60

Minimum width of code blocks.

pad_amount

  • type: integer default: 2

Width of the left & right border/padding.

pad_char

  • type: string default: " "

Character used for the borders/paddings.

sign

  • type: string

Text to show in the signcolumn.

sign_hl

  • type: string

Highlight group used for the sign.

style

  • type: "simple" | "block" default: "block"

Changes how code blocks are shown. Supported values are,

  • "simple" Entire line is highlighted. Useful when wrap is enabled.

  • "block" A block is created around the code block and paddings are added before & after each line.

text

  • type: string default: "󰣖 Code"

Text to show on the top-left/top-right side of the code block.

text_direction

  • type: "left" | "right" default: "right"

Changes which side text should be shown on.

text_hl

  • type: string

Highlight group used for text.

code_spans

Changes how code spans look. See how inline elements are configured.

escapes

  • type: { enable: boolean } default: { enable = true }

Allows showing the escaped characters in previews.

enable

  • type: boolean default: true

Self-explanatory.

headings

Changes how different headings look like.

---@type markview.config.typst.headings
headings = {
    enable = true,
    shift_width = 1,

    heading_1 = {
        style = "icon",
        sign = "󰌕 ", sign_hl = "MarkviewHeading1Sign",

        icon = "󰼏  ", hl = "MarkviewHeading1",
    },
    heading_2 = {
        style = "icon",
        sign = "󰌖 ", sign_hl = "MarkviewHeading2Sign",

        icon = "󰎨  ", hl = "MarkviewHeading2",
    },
    heading_3 = {
        style = "icon",

        icon = "󰼑  ", hl = "MarkviewHeading3",
    },
    heading_4 = {
        style = "icon",

        icon = "󰎲  ", hl = "MarkviewHeading4",
    },
    heading_5 = {
        style = "icon",

        icon = "󰼓  ", hl = "MarkviewHeading5",
    },
    heading_6 = {
        style = "icon",

        icon = "󰎴  ", hl = "MarkviewHeading6",
    }
},

enable

  • type: boolean default: true

Self-explanatory.

shift_width

  • type: integer default: 1

Number of spaces to add before the heading per level.

heading_[n]

Configuration for level n headings.

hl

  • type: string

Highlight group for the heading.

icon

Note

This has no effect if style is set to simple.

  • type: string

Text to add as icon before the heading text.

icon_hl

Note

This has no effect if style is set to simple.

  • type: string

Highlight group for icon.

sign

Note

This has no effect if style is set to simple.

  • type: string

Text to show in the signcolumn.

sign_hl

Note

This has no effect if style is set to simple.

  • type: string

Highlight group for sign.

style

  • type: "simple" | "icon"

Heading preview style. Possible values are,

  • "simple", Only Highlight the line.

  • "icon", Icons & signs with highlight.

labels

Changes how labels are shown.

---@type markview.config.typst.labels
labels = {
    enable = true,

    default = {
        hl = "MarkviewInlineCode",
        padding_left = " ",
        icon = "",
        padding_right = " "
    }
},

enable

  • type: boolean default: true

Self-explanatory.

default

Default configuration for labels. See how inline elements are configured.

\[string\]

Configuration for labels whose text matches string. See how inline elements are configured.

Note

The structure for labels is <<text>>.

list_items

Changes how list items are shown.

---@type markview.config.markdown.list_items
list_items = {
    enable = true,

    indent_size = function (buffer)
        if type(buffer) ~= "number" then
            return vim.bo.shiftwidth or 4;
        end

        --- Use 'shiftwidth' value.
        return vim.bo[buffer].shiftwidth or 4;
    end,
    shift_width = 4,

    marker_minus = {
        add_padding = true,

        text = "",
        hl = "MarkviewListItemMinus"
    },

    marker_plus = {
        add_padding = true,

        text = "%d)",
        hl = "MarkviewListItemPlus"
    },

    marker_dot = {
        add_padding = true,
    }
},

enable

  • type: boolean default: true

Self-explanatory.

indent_size

  • type: integer | fun(bufnr: integer): integer

Indentation size in list items.

Important

Using tabs for indentation can cause incorrect indent to show up!

shift_size

  • type: integer | fun(bufnr: integer): integer default: 4

Number of spaces to add per indent level of a list item.

marker_dot

Configuration for N. list items.

---@type markview.config.markdown.list_items.typst
marker_dot = {
    enable = true,
    add_padding = true,

    text = "%d.",
    hl = "MarkviewListItemStar"
}

enable

  • type: boolean default: true

Self-explanatory.

add_padding

  • type: boolean default: true

Enables indentation in preview for this type of list items.

text

  • type: string default: "%d."

Format string used for the preview of list item(should have %d in it).

hl

  • type: string default: "MarkviewListItemMinus"

Highlight group for text.

marker_minus

Configuration for - list items.

---@type markview.config.markdown.list_items.typst
marker_minus = {
    enable = true,
    add_padding = true,

    text = "",
    hl = "MarkviewListItemMinus"
}

enable

  • type: boolean default: true

Self-explanatory.

add_padding

  • type: boolean default: true

Enables indentation in preview for this type of list items.

text

  • type: string default: "●"

Text used as the marker in preview.

hl

  • type: string default: "MarkviewListItemMinus"

Highlight group for text.

marker_plus

Configuration for + list items. Same as marker_minus.

math_blocks

Changes how math block are shown.

---@type markview.config.typst.math_blocks
math_blocks = {
    enable = true,

    text = " 󰪚 Math ",
    pad_amount = 3,
    pad_char = " ",

    hl = "MarkviewCode",
    text_hl = "MarkviewCodeInfo"
},

enable

  • type: boolean default: true

Self-explanatory.

hl

  • type: string default: "MarkviewCode"

Highlight group used for the background.

pad_amount

  • type: integer default: 2

Width of the left & right border/padding.

pad_char

  • type: string default: " "

Character used for the borders/paddings.

text

  • type: string

Text to show in the signcolumn.

text_hl

  • type: string

Highlight group used for the text.

math_spans

Changes how inline maths are shown. See how inline elements are configured.

raw_blocks

See also,

Changes how raw blocks look.

---@type markview.config.typst.raw_blocks
raw_blocks = {
    enable = true,

    style = "block",
    label_direction = "right",

    sign = true,

    min_width = 60,
    pad_amount = 3,
    pad_char = " ",

    border_hl = "MarkviewCode",

    default = {
        block_hl = "MarkviewCode",
        pad_hl = "MarkviewCode"
    },

    ["diff"] = {
        block_hl = function (_, line)
            if line:match("^%+") then
                return "MarkviewPalette4";
            elseif line:match("^%-") then
                return "MarkviewPalette1";
            else
                return "MarkviewCode";
            end
        end,
        pad_hl = "MarkviewCode"
    }
},

enable

  • type: boolean default: true

Self-explanatory.

border_hl

  • type: string default: "MarkviewCode"

Highlight group used for the top & bottom part of the code block.

info_hl

  • type: string default: "MarkviewCodeInfo"

Highlight group used for the info string.

label_direction

  • type: "left" | "right" default: "right"

Which side the language name & icon should be shown on.

label_hl

  • type: string

Highlight group used for the language name & icon.

Tip

This can be used to overwrite the highlight group set by the icon_provider!

min_width

  • type: integer default: 60

Minimum width of code blocks.

pad_amount

  • type: integer default: 2

Width of the left & right border/padding.

pad_char

  • type: string default: " "

Character used for the borders/paddings.

default

Default configuration for highlighting a line of the code block.

---@type markview.config.typst.code_blocks.opts
default = {
    block_hl = "MarkviewCode",
    pad_hl = "MarkviewCode"
},

block_hl

  • type: string default: "MarkviewCode"

Highlight group for the text of a line.

pad_hl

  • type: string default: "MarkviewCode"

Highlight group for the padding around the line.

[string]

Configuration for code blocks whose language is string.

---@type markview.config.typst.code_blocks.opts
["string"] = {
    block_hl = nil,
    pad_hl = nil
},

Tip

You can use this for making stuff like diff prettier!

block_hl

  • type: string | fun(bufnr: integer, line: string): string

Highlight group for the text of a line.

pad_hl

  • type: string | fun(bufnr: integer, line: string): string

Highlight group for the padding around the line.

style

  • type: "simple" | "block" default: "block"

Changes how code blocks are shown. Supported values are,

  • "simple" Entire line is highlighted. Useful when wrap is enabled.

  • "block" A block is created around the code block and paddings are added before & after each line.

sign

  • type: boolean default: true

Enables language icon in the signcolumn.

reference_links

Changes how reference links are shown.

---@type markview.config.types.link_ref
reference_links = {
    enable = true,

    default = {
        icon = "",
        hl = "MarkviewHyperlink"
    },
},

enable

  • type: boolean default: true

Self-explanatory.

default

Default configuration. See how inline elements are configured.

[string]

Configuration for reference links whose destination matches string. See how inline elements are configured.

Note

The structure for reference links is @<destination>.

subscripts

Configuration for subscript texts.

---@type markview.config.typst.subscripts
subscripts = {
    enable = true,

    hl = "MarkviewSubscript",
    marker_left = nil,
    marker_right = nil,
},

enable

  • type: boolean default: true

Self-explanatory.

hl

  • type: string default: "MarkviewSubscript"

Highlight group.

marker_left

  • type: string

Marker to show before subscript text.

Note

This only shows up if the text can't be shown as subscripted text.

marker_right

  • type: string

Marker to show after subscript text.

Note

This only shows up if the text can't be shown as subscripted text.

superscripts

Configuration for superscript texts. Same as subscripts.

---@type markview.config.typst.superscripts
superscripts = {
    enable = true,

    hl = "MarkviewSuperscript",
    marker_left = nil,
    marker_right = nil,
},

symbols

Configuration for symbols.

---@type markview.config.typst.symbols
superscripts = {
    enable = true,

    hl = "Special",
    marker_left = nil,
    marker_right = nil,
},

enable

  • type: boolean default: true

Self-explanatory.

hl

  • type: string default: "Special"

Highlight group.

reference_links

Changes how reference links are shown.

---@type markview.config.types.link_ref
terms = {
    enable = true,

    default = {
        text = "",
        hl = "MarkviewPalette6Fg"
    },
},

enable

  • type: boolean default: true

Self-explanatory.

default

Default configuration. See how inline elements are configured.

[string]

Configuration for terms whose label matches string. See how inline elements are configured.

Note

The structure for terms is / <label>: @<destination>.

url_links

Changes how uri autolinks are shown.

---@type markview.config.typst.url_links
url_links = {
    enable = true,

    default = {
        icon = "󰌷 ",
        hl = "MarkviewHyperlink",
    },

    ["github%.com/[%a%d%-%_%.]+%/?$"] = {
        --- github.com/<user>

        icon = "",
        hl = "MarkviewPalette0Fg"
    },
    ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/?$"] = {
        --- github.com/<user>/<repo>

        icon = "",
        hl = "MarkviewPalette0Fg"
    },
    ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+/tree/[%a%d%-%_%.]+%/?$"] = {
        --- github.com/<user>/<repo>/tree/<branch>

        icon = "",
        hl = "MarkviewPalette0Fg"
    },
    ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+/commits/[%a%d%-%_%.]+%/?$"] = {
        --- github.com/<user>/<repo>/commits/<branch>

        icon = "",
        hl = "MarkviewPalette0Fg"
    },

    ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/releases$"] = {
        --- github.com/<user>/<repo>/releases

        icon = "",
        hl = "MarkviewPalette0Fg"
    },
    ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/tags$"] = {
        --- github.com/<user>/<repo>/tags

        icon = "",
        hl = "MarkviewPalette0Fg"
    },
    ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/issues$"] = {
        --- github.com/<user>/<repo>/issues

        icon = "",
        hl = "MarkviewPalette0Fg"
    },
    ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/pulls$"] = {
        --- github.com/<user>/<repo>/pulls

        icon = "",
        hl = "MarkviewPalette0Fg"
    },

    ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/wiki$"] = {
        --- github.com/<user>/<repo>/wiki

        icon = "",
        hl = "MarkviewPalette0Fg"
    },

    ["developer%.mozilla%.org"] = {
        priority = -9999,

        icon = "󰖟 ",
        hl = "MarkviewPalette5Fg"
    },

    ["w3schools%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette4Fg"
    },

    ["stackoverflow%.com"] = {
        priority = -9999,

        icon = "󰓌 ",
        hl = "MarkviewPalette2Fg"
    },

    ["reddit%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette2Fg"
    },

    ["github%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette6Fg"
    },

    ["gitlab%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette2Fg"
    },

    ["dev%.to"] = {
        priority = -9999,

        icon = "󱁴 ",
        hl = "MarkviewPalette0Fg"
    },

    ["codepen%.io"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette6Fg"
    },

    ["replit%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette2Fg"
    },

    ["jsfiddle%.net"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette5Fg"
    },

    ["npmjs%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette0Fg"
    },

    ["pypi%.org"] = {
        priority = -9999,

        icon = "󰆦 ",
        hl = "MarkviewPalette0Fg"
    },

    ["mvnrepository%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette1Fg"
    },

    ["medium%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette6Fg"
    },

    ["linkedin%.com"] = {
        priority = -9999,

        icon = "󰌻 ",
        hl = "MarkviewPalette5Fg"
    },

    ["news%.ycombinator%.com"] = {
        priority = -9999,

        icon = "",
        hl = "MarkviewPalette2Fg"
    },
},

enable

  • type: boolean default: true

Self-explanatory.

Default configuration for URI autolinks. See how inline elements are configured.

Configuration for URL links whose text matches string. See how inline elements are configured.

Clone this wiki locally