### Install with vim.pack Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/render-markdown.txt Install the render-markdown.nvim plugin and its dependencies using the vim.pack package manager. The setup function is called if custom options are needed. ```lua vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter', 'https://github.com/nvim-mini/mini.nvim', -- if you use the mini.nvim suite -- 'https://github.com/nvim-mini/mini.icons', -- if you use standalone mini plugins -- 'https://github.com/nvim-tree/nvim-web-devicons', -- if you prefer nvim-web-devicons 'https://github.com/MeanderingProgrammer/render-markdown.nvim', }) require('render-markdown').setup({}) -- only mandatory if you want to set custom options ``` -------------------------------- ### Full Configuration Example Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md A complete configuration example for render-markdown.nvim, demonstrating various settings including inline highlights, indentation, HTML rendering, window options, overrides, and YAML rendering. ```lua return { inline_highlight = { -- Turn on / off inline highlight rendering. enabled = true, -- Additional modes to render inline highlights. render_modes = false, -- Applies to background of surrounded text. highlight = 'RenderMarkdownInlineHighlight', -- Define custom highlights based on text prefix. -- The key is for healthcheck and to allow users to change its values, value type below. -- | prefix | matched against text body, @see :h vim.startswith() | -- | highlight | highlight for text body | custom = {}, }, indent = { -- Mimic org-indent-mode behavior by indenting everything under a heading based on the -- level of the heading. Indenting starts from level 2 headings onward by default. -- Turn on / off org-indent-mode. enabled = false, -- Additional modes to render indents. render_modes = false, -- Amount of additional padding added for each heading level. per_level = 2, -- Heading levels <= this value will not be indented. -- Use 0 to begin indenting from the very first level. skip_level = 1, -- Do not indent heading titles, only the body. skip_heading = false, -- Prefix added when indenting, one per level. icon = '▎', -- Priority to assign to extmarks. priority = 0, -- Applied to icon. highlight = 'RenderMarkdownIndent', }, html = { -- Turn on / off all HTML rendering. enabled = true, -- Additional modes to render HTML. render_modes = false, comment = { -- Useful context to have when evaluating values. -- | text | text value of the comment node | -- Turn on / off HTML comment concealing. conceal = true, -- Text to inline before the concealed comment. -- Output is evaluated depending on the type. -- | function | `value(context)` | -- | string | `value` | -- | nil | nothing | text = nil, -- Highlight for the inlined text. highlight = 'RenderMarkdownHtmlComment', }, -- HTML tags whose start and end will be hidden and icon shown. -- The key is matched against the tag name, value type below. -- | icon | optional icon inlined at start of tag | -- | highlight | optional highlight for the icon | -- | scope_highlight | optional highlight for item associated with tag | tag = {}, }, win_options = { -- Window options to use that change between rendered and raw view. -- @see :h 'conceallevel' conceallevel = { -- Used when not being rendered, get user setting. default = vim.o.conceallevel, -- Used when being rendered, concealed text is completely hidden. rendered = 3, }, -- @see :h 'concealcursor' concealcursor = { -- Used when not being rendered, get user setting. default = vim.o.concealcursor, -- Used when being rendered, show concealed text in all modes. rendered = '', }, }, overrides = { -- More granular configuration mechanism, allows different aspects of buffers to have their own -- behavior. Values default to the top level configuration if no override is provided. Supports -- the following fields: -- enabled, render_modes, debounce, anti_conceal, bullet, callout, checkbox, code, dash, -- document, heading, html, indent, inline_highlight, latex, link, padding, paragraph, -- pipe_table, quote, sign, win_options, yaml -- Override for different buflisted values, @see :h 'buflisted'. buflisted = {}, -- Override for different buftype values, @see :h 'buftype'. buftype = { nofile = { render_modes = true, padding = { highlight = 'NormalFloat' }, sign = { enabled = false }, }, }, -- Override for different filetype values, @see :h 'filetype'. filetype = {}, -- Override for preview buffer. preview = { render_modes = true, }, }, custom_handlers = { -- Mapping from treesitter language to user defined handlers. -- @see [Custom Handlers](doc/custom-handlers.md) }, yaml = { -- Turn on / off all yaml rendering. enabled = true, -- Additional modes to render yaml. render_modes = false, }, } ``` -------------------------------- ### Install with packer.nvim Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md Configure packer.nvim to manage render-markdown.nvim and its optional dependencies. The 'config' function is used for setup. ```lua use({ 'MeanderingProgrammer/render-markdown.nvim', after = { 'nvim-treesitter' }, requires = { 'nvim-mini/mini.nvim', opt = true }, -- if you use the mini.nvim suite -- requires = { 'nvim-mini/mini.icons', opt = true }, -- if you use standalone mini plugins -- requires = { 'nvim-tree/nvim-web-devicons', opt = true }, -- if you prefer nvim-web-devicons config = function() require('render-markdown').setup({}) end, }) ``` -------------------------------- ### Rust Hello World Example Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/CodeBlocks A basic 'Hello, World!' program in Rust. ```rust fn main() { println!("Hello, World!"); } ``` -------------------------------- ### Install with rocks.nvim Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/render-markdown.txt Install the render-markdown.nvim plugin using the rocks.nvim package manager via the command line. ```vim :Rocks install render-markdown.nvim ``` -------------------------------- ### Install with rocks.nvim Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md Install the plugin using the rocks.nvim package manager command. ```vim :Rocks install render-markdown.nvim ``` -------------------------------- ### Python Hello World Example Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/CodeBlocks A simple 'Hello, World!' program in Python. ```python def main() -> None: print("Hello, World!") ``` -------------------------------- ### Install with vim.pack Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md Use vim.pack.add to include the plugin and its dependencies. Call require('render-markdown').setup({}) if custom options are needed. ```lua vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter', 'https://github.com/nvim-mini/mini.nvim', -- if you use the mini.nvim suite -- 'https://github.com/nvim-mini/mini.icons', -- if you use standalone mini plugins -- 'https://github.com/nvim-tree/nvim-web-devicons', -- if you prefer nvim-web-devicons 'https://github.com/MeanderingProgrammer/render-markdown.nvim', }) require('render-markdown').setup({}) -- only mandatory if you want to set custom options ``` -------------------------------- ### Configure filetypes for render-markdown Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/troubleshooting.md Specify which filetypes the plugin should operate on by modifying the 'file_types' setting in the setup configuration. This example shows how to include 'markdown' and another custom filetype. ```lua require('render-markdown').setup({ file_types = { 'markdown', }, }) ``` -------------------------------- ### Install with lazy.nvim Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md Configure lazy.nvim to load render-markdown.nvim and its dependencies. The 'opts' table is for user configuration. ```lua { 'MeanderingProgrammer/render-markdown.nvim', dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.nvim' }, -- if you use the mini.nvim suite -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.icons' }, -- if you use standalone mini plugins -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons ---@module 'render-markdown' ---@type render.md.UserConfig opts = {}, } ``` -------------------------------- ### Enable LSP Completions Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md Enables in-process LSP completions for markdown elements. This is the recommended setup for completions. ```lua require('render-markdown').setup({ completions = { lsp = { enabled = true } }, }) ``` -------------------------------- ### Mounting sda1 Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/tests/data/ft_override.md Example of mounting a FAT32 partition (sda1) to a shared directory. ```bash /dev/sda1 /mnt/shared vfat size=200m ``` -------------------------------- ### Enable Coq.nvim Completions Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md Enables completions specifically for the coq.nvim plugin. Ensure coq.nvim is installed and configured. ```lua require('render-markdown').setup({ completions = { coq = { enabled = true } }, }) ``` -------------------------------- ### Print Hello World in Python Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/demo/_indent A basic Python script to print a string to the console. This is a standard example for demonstrating Python syntax. ```python print("Hello, World!") ``` -------------------------------- ### Mounting tmpfs Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/tests/data/ft_override.md Example of mounting a temporary file system (tmpfs) to a temporary directory. ```bash tmpfs /mnt/tmpfs tmpfs size=100m ``` -------------------------------- ### Setup Default Heading Rendering Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Headings Enables heading rendering with default settings, including signs and icons. This is the most comprehensive configuration for headings. ```lua require('render-markdown').setup({ heading = { enabled = true, render_modes = false, atx = true, setext = true, sign = true, icons = { '󰲡 ', '󰲣 ', '󰲥 ', '󰲧 ', '󰲩 ', '󰲫 ' }, position = 'overlay', signs = { '󰫎 ' }, width = 'full', left_margin = 0, left_pad = 0, right_pad = 0, min_width = 0, border = false, border_virtual = false, border_prefix = false, above = '▄', below = '▀', backgrounds = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg', 'RenderMarkdownH4Bg', 'RenderMarkdownH5Bg', 'RenderMarkdownH6Bg', }, foregrounds = { 'RenderMarkdownH1', 'RenderMarkdownH2', 'RenderMarkdownH3', 'RenderMarkdownH4', 'RenderMarkdownH5', 'RenderMarkdownH6', }, custom = {}, }, }) ``` -------------------------------- ### Lua Tip Example Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/demo/callout.md A standard tip callout using Lua code. Ensure the code is correctly formatted within the fenced code block. ```lua print('Standard tip') ``` -------------------------------- ### Setup Default Block Quote Rendering Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/BlockQuotes Enables block quote rendering with a default icon and specifies highlight groups. Use this for standard block quote display. ```lua require('render-markdown').setup({ quote = { enabled = true, render_modes = false, icon = '▋', repeat_linebreak = false, highlight = { 'RenderMarkdownQuote1', 'RenderMarkdownQuote2', 'RenderMarkdownQuote3', 'RenderMarkdownQuote4', 'RenderMarkdownQuote5', 'RenderMarkdownQuote6', }, }, }) ``` -------------------------------- ### Setup Code Block Rendering Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/render-markdown.txt Configure the rendering of code blocks and inline code, including enabling/disabling, language display, borders, and padding. ```lua require('render-markdown').setup({ code = { -- Turn on / off code block & inline code rendering. enabled = true, -- Additional modes to render code blocks. render_modes = false, -- Turn on / off sign column related rendering. sign = true, -- Whether to conceal nodes at the top and bottom of code blocks. conceal_delimiters = true, -- Turn on / off language heading related rendering. language = true, -- Determines where language icon is rendered. -- | center | center of code block | -- | right | right of code block | -- | left | left of code block | position = 'left', -- Whether to include the language icon above code blocks. language_icon = true, -- Whether to include the language name above code blocks. language_name = true, -- Whether to include the language info above code blocks. language_info = true, -- Amount of padding to add around the language. -- If a float < 1 is provided it is treated as a percentage of available window space. language_pad = 0, -- A list of language names for which rendering will be disabled. disable = {}, -- A list of language names for which background highlighting will be disabled. -- Likely because that language has background highlights itself. -- Use a boolean to make behavior apply to all languages. -- Borders above & below blocks will continue to be rendered. disable_background = { 'diff' }, -- Number of lines from start/end to skip rendering background. background_inset = 1, -- Width of the code block background. -- | block | width of the code block | -- | full | full width of the window | width = 'full', -- Amount of margin to add to the left of code blocks. -- If a float < 1 is provided it is treated as a percentage of available window space. -- Margin available space is computed after accounting for padding. left_margin = 0, -- Amount of padding to add to the left of code blocks. -- If a float < 1 is provided it is treated as a percentage of available window space. left_pad = 0, -- Amount of padding to add to the right of code blocks when width is 'block'. -- If a float < 1 is provided it is treated as a percentage of available window space. right_pad = 0, -- Minimum width to use for code blocks when width is 'block'. min_width = 0, -- Determines how the top / bottom of code block are rendered. -- | none | do not render a border | -- | thick | use the same highlight as the code body | -- | thin | when lines are empty overlay the above & below icons | -- | hide | conceal lines unless language name or icon is added | border = 'hide', -- Used above code blocks to fill remaining space around language. language_border = '█', -- Added to the left of language. language_left = '', -- Added to the right of language. language_right = '', -- Used above code blocks for thin border. above = '▄', -- Used below code blocks for thin border. below = '▀', } }) ``` -------------------------------- ### Configure File Types for Markdown Rendering Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Home Specify which file types should trigger markdown rendering. This example enables rendering for both 'markdown' and 'quarto' files. ```lua require('render-markdown').setup({ file_types = { 'markdown', 'quarto' }, }) ``` -------------------------------- ### Enable Markdown Rendering Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Home Configure whether the plugin should render markdown documents from the start. This option is plugin manager agnostic. ```lua require('render-markdown').setup({ enabled = true, }) ``` -------------------------------- ### Update Plugin Configuration to Use a Different Highlight Group Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Colors This example shows how to change the configuration of a plugin to use a different highlight group, 'Visual', instead of the default 'MyPluginBackground'. This method requires the plugin to expose the highlight group as a configurable option. ```lua { 'PluginAuthor/my-plugin.nvim', config = function() require('my-plugin').setup({ background = 'Visual', }) end, } ``` -------------------------------- ### Setup Block Quote with Naive Line Break Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/BlockQuotes Enables block quote rendering where line breaks are repeated. Note that this might lead to text cutoff in some cases. ```lua require('render-markdown').setup({ quote = { repeat_linebreak = true }, }) ``` -------------------------------- ### Set render-markdown log level to trace Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/troubleshooting.md Modify the plugin's setup configuration to enable 'trace' logging. This will provide more detailed logs for debugging purposes. ```lua require('render-markdown').setup({ log_level = 'trace', }) ``` -------------------------------- ### Highlight Python Function Definitions Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/custom-handlers.md This example demonstrates how to create a custom handler for `python` files to highlight function definitions. It uses a treesitter query to find function definition nodes and applies a `DiffDelete` highlight group. The query is parsed outside the function for efficiency. ```lua -- Parse query outside of the function to avoid doing it for each call local query = vim.treesitter.query.parse('python', '(function_definition) @def') local function parse_python(ctx) local marks = {} ---@type render.md.Mark[] for id, node in query:iter_captures(ctx.root, ctx.buf) do local capture = query.captures[id] local start_row = node:range() if capture == 'def' then marks[#marks + 1] = { conceal = true, start_row = start_row, start_col = 0, opts = { end_row = start_row + 1, end_col = 0, hl_group = 'DiffDelete', hl_eol = true, }, }) end end return marks end require('render-markdown').setup({ file_types = { 'markdown', 'python' }, custom_handlers = { python = { parse = parse_python }, }, }) ``` -------------------------------- ### Configure LaTeX Formula Positioning with nabla.nvim Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/limitations.md Disable render-markdown.nvim's LaTeX rendering and configure conceallevel when using nabla.nvim. Includes setup for nabla's virtual text rendering and clearing. ```lua { { 'jbyuki/nabla.nvim' }, { 'MeanderingProgrammer/render-markdown.nvim', dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.nvim' }, opts = { latex = { enabled = false }, win_options = { conceallevel = { rendered = 2 } }, on = { render = function() require('nabla').enable_virt({ autogen = true }) end, clear = function() require('nabla').disable_virt() end, }, }, }, } ``` -------------------------------- ### Setup Block Quote with Working Line Breaks Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/BlockQuotes Configures block quotes with repeated line breaks and specific window options to ensure proper line breaking and indentation. This is recommended for complex layouts. ```lua require('render-markdown').setup({ quote = { repeat_linebreak = true }, win_options = { showbreak = { default = '', rendered = ' ', }, breakindent = { default = false, rendered = true, }, breakindentopt = { default = '', rendered = '', }, }, }) ``` -------------------------------- ### Get Markdown Rendering State Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/render-markdown.txt Retrieve the current state of markdown rendering using the :RenderMarkdown get command. ```vim :RenderMarkdown get ``` -------------------------------- ### Setup Block Quote with Custom Icon Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/BlockQuotes Configures block quotes to use a custom icon. This is useful for visual distinction. ```lua require('render-markdown').setup({ quote = { icon = '▯' }, }) ``` -------------------------------- ### Get current buffer filetype Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/troubleshooting.md Use this command to retrieve and print the filetype of the current buffer. Ensure this filetype is included in your render-markdown configuration. ```vim :lua vim.print(vim.bo.filetype) ``` -------------------------------- ### Configure Callouts in render-markdown.nvim Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md This snippet shows how to set up callouts in the render-markdown.nvim plugin. It includes definitions for various callout types like 'note', 'tip', 'important', and others, specifying their raw matching text, rendered appearance, highlight colors, and categories. ```lua require('render-markdown').setup({ callout = { -- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link'. -- The key is for healthcheck and to allow users to change its values, value type below. -- | raw | matched against the raw text of a 'shortcut_link', case insensitive | -- | rendered | replaces the 'raw' value when rendering | -- | highlight | highlight for the 'rendered' text and quote markers | -- | quote_icon | optional override for quote.icon value for individual callout | -- | category | optional metadata useful for filtering | note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'RenderMarkdownInfo', category = 'github' }, tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'RenderMarkdownSuccess', category = 'github' }, important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'RenderMarkdownHint', category = 'github' }, warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'RenderMarkdownWarn', category = 'github' }, caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'RenderMarkdownError', category = 'github' }, -- Obsidian: https://help.obsidian.md/Editing+and+formatting/Callouts abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'RenderMarkdownInfo', category = 'obsidian' }, summary = { raw = '[!SUMMARY]', rendered = '󰨸 Summary', highlight = 'RenderMarkdownInfo', category = 'obsidian' }, tldr = { raw = '[!TLDR]', rendered = '󰨸 Tldr', highlight = 'RenderMarkdownInfo', category = 'obsidian' }, info = { raw = '[!INFO]', rendered = '󰋽 Info', highlight = 'RenderMarkdownInfo', category = 'obsidian' }, todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'RenderMarkdownInfo', category = 'obsidian' }, hint = { raw = '[!HINT]', rendered = '󰌶 Hint', highlight = 'RenderMarkdownSuccess', category = 'obsidian' }, success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'RenderMarkdownSuccess', category = 'obsidian' }, check = { raw = '[!CHECK]', rendered = '󰄬 Check', highlight = 'RenderMarkdownSuccess', category = 'obsidian' }, done = { raw = '[!DONE]', rendered = '󰄬 Done', highlight = 'RenderMarkdownSuccess', category = 'obsidian' }, question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'RenderMarkdownWarn', category = 'obsidian' }, help = { raw = '[!HELP]', rendered = '󰘥 Help', highlight = 'RenderMarkdownWarn', category = 'obsidian' }, faq = { raw = '[!FAQ]', rendered = '󰘥 Faq', highlight = 'RenderMarkdownWarn', category = 'obsidian' }, attention = { raw = '[!ATTENTION]', rendered = '󰀪 Attention', highlight = 'RenderMarkdownWarn', category = 'obsidian' }, failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'RenderMarkdownError', category = 'obsidian' }, fail = { raw = '[!FAIL]', rendered = '󰅖 Fail', highlight = 'RenderMarkdownError', category = 'obsidian' }, missing = { raw = '[!MISSING]', rendered = '󰅖 Missing', highlight = 'RenderMarkdownError', category = 'obsidian' }, danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'RenderMarkdownError', category = 'obsidian' }, error = { raw = '[!ERROR]', rendered = '󱐌 Error', highlight = 'RenderMarkdownError', category = 'obsidian' }, bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'RenderMarkdownError', category = 'obsidian' }, example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'RenderMarkdownHint' , category = 'obsidian' }, quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = 'RenderMarkdownQuote', category = 'obsidian' }, cite = { raw = '[!CITE]', rendered = '󱆨 Cite', highlight = 'RenderMarkdownQuote', category = 'obsidian' }, }, }) ``` -------------------------------- ### Set Up Rendering Lifecycle Callbacks Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Home Define custom functions to be executed at different stages of the markdown rendering process, such as 'attach', 'initial', 'render', and 'clear'. ```lua require('render-markdown').setup({ on = { attach = function() end, initial = function() end, render = function() end, clear = function() end, }, }) ``` -------------------------------- ### Configure Custom List Bullet Icons Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/ListBullets Sets custom icons for list bullets. This example uses two specific icons for different bullet levels. ```lua require('render-markdown').setup({ bullet = { icons = { '', '' } }, }) ``` -------------------------------- ### Full Default Configuration Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md The complete default configuration for render-markdown.nvim. Many options can be customized, but some are best left at their defaults. ```lua require('render-markdown').setup({ -- Whether markdown should be rendered by default. enabled = true, -- Vim modes that will show a rendered view of the markdown file, :h mode(), for all enabled -- components. Individual components can be enabled for other modes. Remaining modes will be -- unaffected by this plugin. render_modes = { 'n', 'c', 't' }, -- Milliseconds that must pass before updating marks, updates occur. -- within the context of the visible window, not the entire buffer. debounce = 100, -- Pre configured settings that will attempt to mimic various target user experiences. -- User provided settings will take precedence. -- | obsidian | mimic Obsidian UI | -- | lazy | will attempt to stay up to date with LazyVim configuration | -- | none | does nothing | preset = 'none', -- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'. -- Only intended to be used for plugin development / debugging. log_level = 'error', -- Print runtime of main update method. -- Only intended to be used for plugin development / debugging. log_runtime = false, -- Filetypes this plugin will run on. file_types = { 'markdown' }, -- Maximum file size (in MB) that this plugin will attempt to render. -- File larger than this will effectively be ignored. max_file_size = 10.0, -- Takes buffer as input, if it returns true this plugin will not attach to the buffer. ignore = function() return false end, -- Whether markdown should be rendered when nested inside markdown, i.e. markdown code block -- inside markdown file. nested = true, -- Additional events that will trigger this plugin's render loop. change_events = {}, -- Whether the treesitter highlighter should be restarted after this plugin attaches to its -- first buffer for the first time. May be necessary if this plugin is lazy loaded to clear -- highlights that have been dynamically disabled. restart_highlighter = false, injections = { -- Out of the box language injections for known filetypes that allow markdown to be interpreted -- in specified locations, see :h treesitter-language-injections. -- Set enabled to false in order to disable. gitcommit = { enabled = true, query = "(("message") @injection.content (#set! injection.combined) (#set! injection.include-children) (#set! injection.language "markdown"))", }, }, patterns = { -- Highlight patterns to disable for filetypes, i.e. lines concealed around code blocks ``` -------------------------------- ### Hard Code Highlight Group Background Color Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Colors This Lua snippet demonstrates how to directly set the background color for a highlight group using `vim.api.nvim_set_hl`. You can use either a hex color code (e.g., '#ff0000') or a named color (e.g., 'red'). This approach ensures the color remains constant regardless of the active color scheme. If the plugin sets `default` to true when creating highlight groups, this call should precede the plugin's setup. Otherwise, it should follow the setup. ```lua { 'PluginAuthor/my-plugin.nvim', config = function() vim.api.nvim_set_hl(0, 'MyPluginBackground', { bg = '#ff0000' }) -- Or: vim.api.nvim_set_hl(0, 'MyPluginBackground', { bg = 'red' }) require('my-plugin').setup({}) -- Move here if default is not set end, } ``` -------------------------------- ### Configure Link Rendering Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md Set up global link rendering options and define custom icons and patterns for different URL types. This configuration is applied when the plugin is initialized. ```lua require('render-markdown').setup({ link = { -- Turn on / off inline link icon rendering. enabled = true, -- Additional modes to render links. render_modes = false, -- How to handle footnote links, start with a '^'. footnote = { -- Turn on / off footnote rendering. enabled = true, -- Inlined with content. icon = '󰯔 ', -- Custom processing for footnote body to show. -- Runs before prefix / suffix are added and superscript processing. body = function(ctx) return ctx.text end, -- Replace value with superscript equivalent. superscript = true, -- Added before link content. prefix = '', -- Added after link content. suffix = '', }, -- Inlined with 'image' elements. image = '󰥶 ', -- Check custom for 'image' elements. image_custom = true, -- Inlined with 'email_autolink' elements. email = '󰀓 ', -- Fallback icon for 'inline_link' and 'uri_autolink' elements. hyperlink = '󰌹 ', -- Applies to the inlined icon as a fallback. highlight = 'RenderMarkdownLink', -- Applies to the link title. highlight_title = 'RenderMarkdownLinkTitle', -- Applies to WikiLink elements. wiki = { -- Turn on / off WikiLink rendering. enabled = true, -- Inlined with content. icon = '󱗖 ', -- Hide destination if there is an alias. conceal_destination = true, -- Custom processing for WikiLink body to show. body = function() return nil end, -- Applies to the inlined icon. highlight = 'RenderMarkdownWikiLink', -- Highlight for item associated with the WikiLink. scope_highlight = nil, }, -- Define custom destination patterns so icons can quickly inform you of what a link -- contains. Applies to 'image', 'inline_link', 'uri_autolink', and WikiLink nodes. -- When multiple patterns match a link the one with the longer pattern is used. -- The key is for healthcheck and to allow users to change its values, value type below. -- | icon | gets inlined before the link text | -- | pattern | matched against the destination text | -- | kind | optional determines how pattern is checked | -- | | pattern | @see :h lua-patterns, is the default if not set | -- | | suffix | @see :h vim.endswith() | -- | | url | similar to pattern with additional prefix checks | -- | priority | optional used when multiple match, uses pattern length if empty | -- | highlight | optional highlight for 'icon', uses fallback highlight if empty | -- stylua: ignore custom = { web = { icon = '󰖟 ', pattern = '^http' }, apple = { icon = ' ', pattern = 'apple%.com', kind = 'url' }, discord = { icon = '󰙯 ', pattern = 'discord%.com', kind = 'url' }, github = { icon = '󰊤 ', pattern = 'github%.com', kind = 'url' }, gitlab = { icon = '󰮠 ', pattern = 'gitlab%.com', kind = 'url' }, google = { icon = '󰊭 ', pattern = 'google%.com', kind = 'url' }, hackernews = { icon = ' ', pattern = 'ycombinator%.com', kind = 'url' }, linkedin = { icon = '󰌻 ', pattern = 'linkedin%.com', kind = 'url' }, microsoft = { icon = ' ', pattern = 'microsoft%.com', kind = 'url' }, neovim = { icon = ' ', pattern = 'neovim%.io', kind = 'url' }, reddit = { icon = '󰑍 ', pattern = 'reddit%.com', kind = 'url' }, slack = { icon = '󰒱 ', pattern = 'slack%.com', kind = 'url' }, stackoverflow = { icon = '󰓌 ', pattern = 'stackoverflow%.com', kind = 'url' }, steam = { icon = ' ', pattern = 'steampowered%.com', kind = 'url' }, twitter = { icon = ' ', pattern = 'twitter%.com', kind = 'url' }, wikipedia = { icon = '󰖬 ', pattern = 'wikipedia%.org', kind = 'url' }, x = { icon = ' ', pattern = 'x%.com', kind = 'url' }, youtube = { icon = '󰗃 ', pattern = 'youtube[^.]*%.com', kind = 'url' }, youtube_short = { icon = '󰗃 ', pattern = 'youtu%.be', kind = 'url' }, }, }, }) ``` -------------------------------- ### Configure Preset for render-markdown.nvim Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Home Apply a preset configuration to quickly set multiple non-default options. The default preset is 'none'. ```lua require('render-markdown').setup({ preset = 'none', }) ``` -------------------------------- ### Disable Builtin Latex Handler Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/doc/custom-handlers.md To disable a builtin handler, do not specify the `extends` field and return an empty table from the `parse` function. This example shows how to disable the `latex` handler. ```lua require('render-markdown').setup({ custom_handlers = { latex = { parse = function() return {} end, }, }, }) ``` -------------------------------- ### Configure Heading Rendering Source: https://github.com/meanderingprogrammer/render-markdown.nvim/blob/main/README.md Sets up the heading rendering options for render-markdown.nvim. This includes enabling/disabling features, defining icons, positions, signs, widths, margins, padding, minimum widths, borders, and background/foreground highlights. Custom patterns can also be defined to override properties based on heading text. ```lua require('render-markdown').setup({ heading = { -- Useful context to have when evaluating values. -- | level | the number of '#' in the heading marker | -- | sections | for each level how deeply nested the heading is | -- Turn on / off heading icon & background rendering. enabled = true, -- Additional modes to render headings. render_modes = false, -- Turn on / off atx heading rendering. atx = true, -- Turn on / off setext heading rendering. setext = true, -- Turn on / off sign column related rendering. sign = true, -- Replaces '#+' of 'atx_h._marker'. -- Output is evaluated depending on the type. -- | function | `value(context)` | -- | string[] | `cycle(value, context.level)` | icons = { '󰲡 ', '󰲣 ', '󰲥 ', '󰲧 ', '󰲩 ', '󰲫 ' }, -- Determines how icons fill the available space. -- | eol | '#'s are concealed and icon is placed at right most column | -- | right | '#'s are concealed and icon is appended to right side | -- | inline | '#'s are concealed and icon is inlined on left side | -- | overlay | icon is left padded with spaces and overlayed hiding all '#' | position = 'overlay', -- Added to the sign column if enabled. -- Output is evaluated by `cycle(value, context.level)`. signs = { '󰫎 ' }, -- Width of the heading background. -- | block | width of the heading text | -- | full | full width of the window | -- Can also be a list of the above values evaluated by `clamp(value, context.level)`. width = 'full', -- Amount of margin to add to the left of headings. -- Margin available space is computed after accounting for padding. -- If a float < 1 is provided it is treated as a percentage of available window space. -- Can also be a list of numbers evaluated by `clamp(value, context.level)`. left_margin = 0, -- Amount of padding to add to the left of headings. -- Output is evaluated using the same logic as 'left_margin'. left_pad = 0, -- Amount of padding to add to the right of headings when width is 'block'. -- Output is evaluated using the same logic as 'left_margin'. right_pad = 0, -- Minimum width to use for headings when width is 'block'. -- Can also be a list of integers evaluated by `clamp(value, context.level)`. min_width = 0, -- Determines if a border is added above and below headings. -- Can also be a list of booleans evaluated by `clamp(value, context.level)`. border = false, -- Always use virtual lines for heading borders instead of attempting to use empty lines. border_virtual = false, -- Highlight the start of the border using the foreground highlight. border_prefix = false, -- Used above heading for border. above = '▄', -- Used below heading for border. below = '▀', -- Highlight for the heading icon and extends through the entire line. -- Output is evaluated by `clamp(value, context.level)`. backgrounds = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg', 'RenderMarkdownH4Bg', 'RenderMarkdownH5Bg', 'RenderMarkdownH6Bg', }, -- Highlight for the heading and sign icons. -- Output is evaluated using the same logic as 'backgrounds'. foregrounds = { 'RenderMarkdownH1', 'RenderMarkdownH2', 'RenderMarkdownH3', 'RenderMarkdownH4', 'RenderMarkdownH5', 'RenderMarkdownH6', }, -- Define custom heading patterns which allow you to override various properties based on -- the contents of a heading. -- The key is for healthcheck and to allow users to change its values, value type below. -- | pattern | matched against the heading text @see :h lua-patterns | -- | icon | optional override for the icon | -- | background | optional override for the background | -- | foreground | optional override for the foreground | custom = {}, }, }) ``` -------------------------------- ### Configure Default Table Rendering Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Tables Enables pipe table rendering with default settings. Use this to activate basic table support. ```lua require('render-markdown').setup({ pipe_table = { enabled = true, render_modes = false, preset = 'none', cell = 'padded', cell_offset = function() return 0 end, padding = 1, min_width = 0, border = { '┌', '┬', '┐', '├', '┼', '┤', '└', '┴', '┘', '│', '─', }, border_enabled = true, border_virtual = false, alignment_indicator = '━', head = 'RenderMarkdownTableHead', row = 'RenderMarkdownTableRow', style = 'full', }, }) ``` -------------------------------- ### Configure Anti-Conceal Behavior Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/Home Configure the anti-conceal feature, which hides plugin marks on the cursor row for a smoother editing experience. This example shows the default configuration with specific elements ignored. ```lua require('render-markdown').setup({ anti_conceal = { enabled = true, disabled_modes = false, above = 0, below = 0, ignore = { code_background = true, indent = true, sign = true, virtual_lines = true, }, }, }) ``` -------------------------------- ### Configure Nested List Bullet Icons Source: https://github.com/meanderingprogrammer/render-markdown.nvim/wiki/ListBullets Configures distinct icons for nested lists. This example uses a table of icon strings to define different appearances for deeper nesting levels. ```lua require('render-markdown').setup({ bullet = { icons = { { '󰫶 ', '󱂉 ' } } }, }) ```