-
Notifications
You must be signed in to change notification settings - Fork 4
3.Configuration
yousefhadder edited this page Dec 1, 2025
·
1 revision
require("markdown-plus").setup({
-- Global enable/disable
enabled = true, -- default: true
-- Feature toggles (all default: true)
features = {
list_management = true, -- default: true (list auto-continue / indent / renumber / checkboxes)
text_formatting = true, -- default: true (bold/italic/strike/code + clear)
headers_toc = true, -- default: true (headers nav + TOC generation & window)
links = true, -- default: true (insert/edit/convert/reference links)
images = true, -- default: true (insert/edit image links + toggle link/image)
quotes = true, -- default: true (blockquote toggle)
callouts = true, -- default: true (GFM callouts/admonitions)
code_block = true, -- default: true (visual selection -> fenced block)
table = true, -- default: true (table creation & editing)
footnotes = true, -- default: true (footnote insertion/navigation/listing)
},
-- TOC window configuration
toc = {
initial_depth = 2, -- default: 2 (range 1-6) depth shown in :Toc window and generated TOC
},
-- Callouts configuration
callouts = {
default_type = "NOTE", -- default: "NOTE" default callout type when inserting
custom_types = {}, -- default: {} add custom types (e.g., { "DANGER", "SUCCESS" })
},
-- Table configuration
table = {
auto_format = true, -- default: true auto format table after operations
default_alignment = "left", -- default: "left" alignment used for new columns
confirm_destructive = true, -- default: true confirm before transpose/sort operations
keymaps = { -- Table-specific keymaps (prefix based)
enabled = true, -- default: true provide table keymaps
prefix = "<leader>t", -- default: "<leader>t" prefix for table ops
insert_mode_navigation = true, -- default: true Alt+hjkl cell navigation
},
},
-- Footnotes configuration
footnotes = {
section_header = "Footnotes", -- default: "Footnotes" header for footnotes section
confirm_delete = true, -- default: true confirm before deleting footnotes
},
-- Global keymap configuration
keymaps = {
enabled = true, -- default: true set false to disable ALL default maps (use <Plug>)
},
-- Filetypes configuration
filetypes = { "markdown" }, -- default: { "markdown" }
})
-- NOTES:
-- 1. Any field omitted uses its default value shown above.
-- 2. Unknown fields trigger a validation error.
-- 3. vim.g.markdown_plus (table or function) is merged BEFORE this setup() call.
-- 4. setup() options override vim.g values; both override internal defaults.The plugin can be enabled for any filetype, not just markdown. This is useful for:
- Plain text files (
.txt,.text) - Note-taking formats (
.note,.org) - Documentation files
- Any text-based format where you want markdown-style formatting
Example: Enable for markdown and plain text files
require("markdown-plus").setup({
filetypes = { "markdown", "text", "txt" },
})Example: Enable for custom note-taking setup
require("markdown-plus").setup({
filetypes = { "markdown", "note", "org", "wiki" },
})Important: Make sure your plugin manager also loads the plugin for these filetypes:
-- For lazy.nvim
{
"yousefhadder/markdown-plus.nvim",
ft = { "markdown", "text", "txt" }, -- Match your filetypes config
config = function()
require("markdown-plus").setup({
filetypes = { "markdown", "text", "txt" },
})
end,
}If you prefer not to call setup() or need Vimscript compatibility, you can configure the plugin using vim.g.markdown_plus:
-- Set before the plugin loads (e.g., in init.lua)
vim.g.markdown_plus = {
enabled = true,
features = {
list_management = true,
text_formatting = true,
},
keymaps = {
enabled = false, -- Disable default keymaps
},
filetypes = { "markdown", "text" },
}
-- No need to call setup() if you only use vim.g
-- The plugin will automatically use vim.g configuration" Set before the plugin loads (e.g., in init.vim)
let g:markdown_plus = #{
\ enabled: v:true,
\ features: #{
\ list_management: v:true,
\ text_formatting: v:false
\ },
\ keymaps: #{
\ enabled: v:true
\ },
\ filetypes: ['markdown', 'text']
\ }For dynamic configuration based on runtime conditions:
vim.g.markdown_plus = function()
return {
enabled = vim.fn.has("nvim-0.10") == 1, -- Only enable on Neovim 0.10+
features = {
list_management = true,
text_formatting = not vim.g.vscode, -- Disable in VSCode
},
}
endWhen both vim.g.markdown_plus and setup() are used, they are merged with the following priority:
- Lowest: Default configuration
-
Middle:
vim.g.markdown_plusconfiguration -
Highest:
setup(opts)parameter
Example:
-- This vim.g config sets list_management = false
vim.g.markdown_plus = {
features = {
list_management = false,
},
}
-- But setup() overrides it to true
require("markdown-plus").setup({
features = {
list_management = true, -- Takes precedence over vim.g
},
})
-- Result: list_management will be trueThis allows you to:
- Set global defaults with
vim.g - Override specific settings with
setup()for certain filetypes or conditions - Mix both methods for maximum flexibility
require("markdown-plus").setup({
callouts = {
default_type = "TIP", -- Change from NOTE to TIP
},
})require("markdown-plus").setup({
callouts = {
custom_types = { "DANGER", "SUCCESS", "INFO" },
},
})After adding custom types, they will:
- Appear in the type selection menu when inserting callouts
- Be included in the cycling order when using
<leader>mQt - Work with all callout operations (insert, wrap, convert, etc.)
require("markdown-plus").setup({
callouts = {
default_type = "DANGER", -- Must be either standard or custom type
custom_types = { "DANGER", "SUCCESS" },
},
})require("markdown-plus").setup({
features = {
callouts = false, -- Disable callouts entirely
},
})If you only want callouts and blockquotes:
require("markdown-plus").setup({
features = {
list_management = false,
text_formatting = false,
headers_toc = false,
links = false,
quotes = true, -- Keep blockquote toggle
callouts = true, -- Enable callouts
code_block = false,
table = false,
},
})