CARVIEW |
Select Language
HTTP/2 200
date: Mon, 28 Jul 2025 03:20:13 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"0682f2156349ab67c335df8926f54489"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=OvO60UblsppWmU2i%2FBIfrLsSVWs%2FBKs%2BI9qGuSDceGwzhHmCukt6GvQY0lBWrDHdmnwg1zZtPisAcvghCy34ziyD5roXmcEN%2BPiVWrcBmHlVgVbCLXy9qRK5djoYYluL3a16PJZa4sIpvr5NjiiuXwArTUusV6g%2BiyQO%2BW%2Fu3qg3iAzRRSi3%2B0QqE69Yb35AUI13vTJfO0cCXOrycAoYYXnBhY0kK5rQA1PnSRhqzIcZAt%2BReUh9REUjpRC8QopQjO9vtRPSva0CA4KOdtD9EQ%3D%3D--ETwm%2F7J27g0%2Bb2RZ--mbmO6mbmclBSWefKTyifMQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.297128224.1753672813; Path=/; Domain=github.com; Expires=Tue, 28 Jul 2026 03:20:13 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Tue, 28 Jul 2026 03:20:13 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 84A8:5FFA9:1317714:195A84C:6886EC6D
Advanced usage · OXY2DEV/markview.nvim Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 63
Advanced usage
Shawon edited this page Jul 15, 2025
·
7 revisions
-
Create a new file
~/.config/nvim/queries/markdown/folds.scm
. -
Add these lines to that file,
; Folds a section of the document
; that starts with a heading.
((section
(atx_heading)) @fold
(#trim! @fold))
; (#trim!) is used to prevent empty
; lines at the end of the section
; from being folded.
- To enable folding using tree-sitter only for markdown, you can use
ftplugin/
. You can do either of these 2 things.
If you don't need anything fancy, you can add this to
~/.config/nvim/ftplugin/markdown.lua
,
--- Removes the ••• part.
vim.o.fillchars = "fold: ";
vim.o.foldmethod = "expr";
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()";
--- Disables fold text.
vim.o.foldtext = "";
If you prefer using a custom
foldtext
then you can use this instead.
---@type integer Current buffer.
local buffer = vim.api.nvim_get_current_buf();
local got_spec, spec = pcall(require, "markview.spec");
local got_util, utils = pcall(require, "markview.utils");
if got_spec == false then
--- Markview most likely not loaded.
--- no point in going forward.
return;
elseif got_util == false then
--- Same as above.
return;
end
--- Fold text creator.
---@return string
_G.heading_foldtext = function ()
--- Start & end of the current fold.
--- Note: These are 1-indexed!
---@type integer, integer
local from, to = vim.v.foldstart, vim.v.foldend;
--- Starting line
---@type string
local line = vim.api.nvim_buf_get_lines(0, from - 1, from, false)[1];
if line:match("^[%s%>]*%#+") == nil then
--- Fold didn't start on a heading.
return vim.fn.foldtext();
end
--- Heading configuration table.
---@type markdown.headings?
local main_config = spec.get({ "markdown", "headings" }, { fallback = nil });
if not main_config then
--- Headings are disabled.
return vim.fn.foldtext();
end
--- Indentation, markers & the content of a heading.
---@type string, string, string
local indent, marker, content = line:match("^([%s%>]*)(%#+)(.*)$");
--- Heading level.
---@type integer
local level = marker:len();
---@type headings.atx
local config = spec.get({ "heading_" .. level }, {
source = main_config,
fallback = nil,
--- This part isn't needed unless the user
--- does something with these parameters.
eval_args = {
buffer,
{
class = "markdown_atx_heading",
marker = marker,
text = { marker .. content },
range = {
row_start = from - 1,
row_end = from,
col_start = #indent,
col_end = #line
}
}
}
});
--- Amount of spaces to add per heading level.
---@type integer
local shift_width = spec.get({ "shift_width" }, { source = main_config, fallback = 0 });
if not config then
--- Config not found.
return vim.fn.foldtext();
elseif config.style == "simple" then
return {
{ marker .. content, utils.set_hl(config.hl) },
{
string.format(" %d", to - from),
utils.set_hl(string.format("Palette%dFg", 7 - level))
}
};
elseif config.style == "label" then
--- We won't implement alignment for the sake
--- of keeping things simple.
local shift = string.rep(" ", level * #shift_width);
return {
{ shift, utils.set_hl(config.hl) },
{ config.corner_left or "", utils.set_hl(config.corner_left_hl or config.hl) },
{ config.padding_left or "", utils.set_hl(config.padding_left_hl or config.hl) },
{ config.icon or "", utils.set_hl(config.padding_left_hl or config.hl) },
{ content:gsub("^%s", ""), utils.set_hl(config.hl) },
{ config.padding_right or "", utils.set_hl(config.padding_right_hl or config.hl) },
{ config.corner_right or "", utils.set_hl(config.corner_right_hl or config.hl) },
{
string.format(" %d", to - from),
utils.set_hl(string.format("Palette%dFg", 7 - level))
}
};
elseif config.style == "icon" then
local shift = string.rep(" ", level * shift_width);
return {
{ shift, utils.set_hl(config.hl) },
{ config.icon or "", utils.set_hl(config.padding_left_hl or config.hl) },
{ content:gsub("^%s", ""), utils.set_hl(config.hl) },
{
string.format(" %d", to - from),
utils.set_hl(string.format("Palette%dFg", 7 - level))
}
};
end
end
vim.o.fillchars = "fold: ";
vim.o.foldmethod = "expr";
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()";
vim.o.foldtext = "v:lua.heading_foldtext()"
This has been taken from #265
Copy this to your plugin's config
option.
---@param group string New highlight group.
---@return { [string]: { hl: string } } New configuration.
local function generic_hl(group)
return {
["github%.com/[%a%d%-%_%.]+%/?$"] = {
hl = group
},
["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/?$"] = {
hl = group
},
["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+/tree/[%a%d%-%_%.]+%/?$"] = {
hl = group
},
["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+/commits/[%a%d%-%_%.]+%/?$"] = {
hl = group
},
["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/releases$"] = {
hl = group
},
["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/tags$"] = {
hl = group
},
["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/issues$"] = {
hl = group
},
["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/pulls$"] = {
hl = group
},
["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/wiki$"] = {
hl = group
}
};
end
require("markview").setup({
markdown = {
reference_definitions = generic_hl("MarkviewPalette4Fg")
},
markdown_inline = {
hyperlinks = generic_hl("MarkviewHyperlink"),
uri_autolinks = generic_hl("MarkviewEmail"),
},
typst = {
url_links = generic_hl("MarkviewEmail")
}
});
This has been taken from #283
Tip
This works the same way for Typst
too!
Copy this to your plugin's config
option.
require("markview").setup({
markdown = {
list_items = {
shift_width = function (buffer, item)
--- Reduces the `indent` by 1 level.
---
--- indent 1
--- ------------------------- = 1 ÷ --------- = new_indent
--- indent * (1 / new_indent) new_indent
---
local parent_indnet = math.max(1, item.indent - vim.bo[buffer].shiftwidth);
return (item.indent) * (1 / (parent_indnet * 2));
end,
marker_minus = {
add_padding = function (_, item)
return item.indent > 1;
end
}
}
}
});
This has been taken from #350
Copy this to your config
option,
local presets = require("markview.presets");
require("markview").setup(presets.no_nerd_fonts);
This has been taken from #371
Copy this to your config
option,
Tip
You can use bb
to toggle the border. Or set the buffer-local variable noborder
to disable borders.
local default = require("markview.spec").default.markdown.tables;
local no_border = require("markview.presets").tables.none;
require("markview").setup({
markdown = {
tables = function (buffer)
if buffer and vim.b[buffer].noborder == true then
-- We merge the tables to avoid issues due to
-- options missing in the presets.
return vim.tbl_deep_extend("force", default, no_border);
else
return default;
end
end
}
});
-- Use `bb` to toggle table border.
vim.api.nvim_set_keymap("n", "bb", "", {
desc = "Switch table [b]order",
callback = function ()
if vim.b.noborder == true then
vim.b.noborder = false;
else
vim.b.noborder = true;
end
require("markview").commands.Render();
end
});
Also available in vimdoc, :h markview.nvim-advanced
Clone this wiki locally
You can’t perform that action at this time.