From b88a3968337afe58dc6806dc19ba6a6b4618f12a Mon Sep 17 00:00:00 2001 From: Shawon Date: Sat, 25 Jan 2025 08:34:05 +0600 Subject: [PATCH] feat(v25)!: New version release - Completely rewritten `markview.nvim` - Adds typst support - Better rendering logic - Performance optimizations. - More customization And more! --- .github/ISSUE_TEMPLATE/bug_report.yml | 104 +- .github/ISSUE_TEMPLATE/feature_request.yml | 42 +- .github/workflows/stale.yml | 16 +- README.md | 1189 ++-- doc/advanced_usage.txt | 173 + doc/custom_renderers.txt | 107 + doc/dev.txt | 153 + doc/experimental_options.txt | 120 + doc/extra.txt | 136 + doc/home.txt | 467 ++ doc/html_options.txt | 371 ++ doc/latex_options.txt | 954 +++ doc/markdown_inline_options.txt | 1203 ++++ doc/markdown_options.txt | 1448 +++++ doc/markview.txt | 2195 ------- doc/migration.txt | 290 + doc/presets.txt | 107 + doc/preview_options.txt | 803 +++ doc/tags | 122 +- doc/typst_options.txt | 1072 ++++ doc/yaml_options.txt | 186 + lua/cmp-markview.lua | 109 + lua/definitions.lua | 450 -- lua/definitions/common.lua | 274 + lua/definitions/config.lua | 116 + lua/definitions/html.lua | 456 ++ lua/definitions/latex.lua | 609 ++ lua/definitions/markdown.lua | 1032 ++++ lua/definitions/markdown_inline.lua | 754 +++ lua/definitions/preview.lua | 522 ++ lua/definitions/typst.lua | 909 +++ lua/definitions/yaml.lua | 84 + lua/markview.lua | 2286 ++++--- lua/markview/colors.lua | 310 - lua/markview/entities.lua | 1693 ++++++ lua/markview/extras/checkboxes.lua | 929 ++- lua/markview/extras/editor.lua | 1038 ++-- lua/markview/extras/headings.lua | 75 +- lua/markview/filetypes.lua | 766 +++ lua/markview/health.lua | 655 +- lua/markview/highlights.lua | 3071 +++++----- lua/markview/html_renderer.lua | 367 -- lua/markview/keymaps.lua | 81 - lua/markview/languages.lua | 487 -- lua/markview/latex_renderer.lua | 2185 ------- lua/markview/links.lua | 304 + lua/markview/parser.lua | 1390 +---- lua/markview/parsers/html.lua | 208 + lua/markview/parsers/latex.lua | 615 ++ lua/markview/parsers/markdown.lua | 696 +++ lua/markview/parsers/markdown_inline.lua | 677 +++ lua/markview/parsers/typst.lua | 652 ++ lua/markview/parsers/yaml.lua | 206 + lua/markview/presets.lua | 163 +- lua/markview/renderer.lua | 2559 ++------ lua/markview/renderers/html.lua | 233 + lua/markview/renderers/latex.lua | 830 +++ lua/markview/renderers/markdown.lua | 3792 ++++++++++++ lua/markview/renderers/markdown_inline.lua | 1107 ++++ lua/markview/renderers/typst.lua | 1576 +++++ lua/markview/renderers/yaml.lua | 111 + lua/markview/spec.lua | 3486 +++++++++++ lua/markview/symbols.lua | 6266 ++++++++++++++++++++ lua/markview/treesitter.lua | 82 - lua/markview/typst_renderer.lua | 0 lua/markview/utils.lua | 347 ++ markview.nvim.wiki | 2 +- plugin/markview.lua | 1034 +++- queries/markdown/highlights.scm | 121 + queries/markdown_inline/highlights.scm | 98 + showcases/Blocks.md | 25 - showcases/Headings.md | 26 - showcases/Inline.md | 29 - showcases/LaTeX.latex | 54 - showcases/Tables.md | 21 - test/html.md | 27 + test/latex.md | 67 + test/markdown.md | 173 + test/markdown_inline.md | 85 + test/typst.typ | 118 + test/yaml.md | 13 + 81 files changed, 43788 insertions(+), 13921 deletions(-) create mode 100644 doc/advanced_usage.txt create mode 100644 doc/custom_renderers.txt create mode 100644 doc/dev.txt create mode 100644 doc/experimental_options.txt create mode 100644 doc/extra.txt create mode 100644 doc/home.txt create mode 100644 doc/html_options.txt create mode 100644 doc/latex_options.txt create mode 100644 doc/markdown_inline_options.txt create mode 100644 doc/markdown_options.txt delete mode 100644 doc/markview.txt create mode 100644 doc/migration.txt create mode 100644 doc/presets.txt create mode 100644 doc/preview_options.txt create mode 100644 doc/typst_options.txt create mode 100644 doc/yaml_options.txt create mode 100644 lua/cmp-markview.lua delete mode 100644 lua/definitions.lua create mode 100644 lua/definitions/common.lua create mode 100644 lua/definitions/config.lua create mode 100644 lua/definitions/html.lua create mode 100644 lua/definitions/latex.lua create mode 100644 lua/definitions/markdown.lua create mode 100644 lua/definitions/markdown_inline.lua create mode 100644 lua/definitions/preview.lua create mode 100644 lua/definitions/typst.lua create mode 100644 lua/definitions/yaml.lua delete mode 100644 lua/markview/colors.lua create mode 100644 lua/markview/entities.lua create mode 100644 lua/markview/filetypes.lua delete mode 100644 lua/markview/html_renderer.lua delete mode 100644 lua/markview/keymaps.lua delete mode 100644 lua/markview/languages.lua delete mode 100644 lua/markview/latex_renderer.lua create mode 100644 lua/markview/links.lua create mode 100644 lua/markview/parsers/html.lua create mode 100644 lua/markview/parsers/latex.lua create mode 100644 lua/markview/parsers/markdown.lua create mode 100644 lua/markview/parsers/markdown_inline.lua create mode 100644 lua/markview/parsers/typst.lua create mode 100644 lua/markview/parsers/yaml.lua create mode 100644 lua/markview/renderers/html.lua create mode 100644 lua/markview/renderers/latex.lua create mode 100644 lua/markview/renderers/markdown.lua create mode 100644 lua/markview/renderers/markdown_inline.lua create mode 100644 lua/markview/renderers/typst.lua create mode 100644 lua/markview/renderers/yaml.lua create mode 100644 lua/markview/spec.lua create mode 100644 lua/markview/symbols.lua delete mode 100644 lua/markview/treesitter.lua delete mode 100644 lua/markview/typst_renderer.lua create mode 100644 queries/markdown/highlights.scm create mode 100644 queries/markdown_inline/highlights.scm delete mode 100644 showcases/Blocks.md delete mode 100644 showcases/Headings.md delete mode 100644 showcases/Inline.md delete mode 100644 showcases/LaTeX.latex delete mode 100644 showcases/Tables.md create mode 100644 test/html.md create mode 100644 test/latex.md create mode 100644 test/markdown.md create mode 100644 test/markdown_inline.md create mode 100644 test/typst.typ create mode 100644 test/yaml.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 351a41e..c02d80a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,55 +1,91 @@ name: Bug report -description: Report a bug in markview -title: '๐Ÿž Bug: ' +description: "Report a bug in markview." +title: "๐Ÿž Bug: " labels: [ "bug" ] -assignees: - - OXY2DEV body: - type: checkboxes - id: issue-conditions + id: branch attributes: - label: 'Before reporting:' - description: | - These are **requirements** and failing to fulfill them will result the issue to be closed. + labels: "๐Ÿค– Which branch are you using?" options: - - label: Ensure that the issue is reproducable on the main branch. - required: true - - label: Ensure that there isn't an issue on this(either open or closed). - required: true + - label: "dev" + - label: "main" + - type: textarea - id: issue-desc + id: desc attributes: - label: 'Problem:' - description: | - Describe the current behavior(images, gif, videos & logs) may be attached. - placeholder: A description of the issue... + label: "๐Ÿ“œ Issue description:" + description: "Describe the issue in a *clear* and *concise* way. You should also attach `images`/`gifs` if it's a visual bug." + placeholder: "Fenced code blocks don't render when..." validations: required: true + - type: textarea - id: issue-repro + id: repro attributes: - label: 'Steps to reproduce the issue:' + label: "๐Ÿ“‘ Reproduction steps:" + description: "Give step by step instructions on how to recreate the issue using the `minimal init`." + placeholder: "1. Open Neovim." + validations: + required: true + + - type: textarea + id: minit + attributes: + label: "๐Ÿ’ป Minimal init:" description: | - *Things to check before opening an issue:* - - Ensure that you don't have other `markdown` plugins enabled(unless it's a comparability issue with that plugin). - - Ensure that you are using the **latest version** of the plugin. - - Ensure that your `Neovim` version is **>=0.10**. - - Ensure that you have the correct `tree-sitter` parsers - installed(markdown, markdown_inline & html). - placeholder: nvim + The minimal config file to reproduce the issue. + + Put this in a file(e.g. `minit.lua`) and do `nvim -u minit.lua` to run it. + placeholder: | + vim.env.LAZY_STDPATH = ".repro" + load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))() + + require("lazy.minit").repro({ + spec = { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + + ensure_installed = { "html", "latex", "markdown", "markdown_inline", "typst", "yaml" } + }, + { + "OXY2DEV/markview.nvim", + -- branch = "dev", + lazy = false + } + }, + }); validations: required: true + - type: textarea - id: issue-expected + id: repro attributes: - label: 'Expected behavior:' - description: Describe what should've happened. - placeholder: Markview should've... + label: "๐Ÿ“œ Logs:" + description: | + After Reproducing the bug, run `:Markview traceExport`. You will see a new file `trace.log` has been created in your current directory. + + Copy it's contents here. + placeholder: "Logs..." + validations: + required: true + - type: input - id: issue-nvim_v + id: nvim-ver + attributes: + label: "Neovim version:" + description: "Neovim version." + placeholder: "nvim -v" + validations: + required: true + + - type: textarea + id: minit attributes: - label: 'Neovim version:' - description: Neovim version. - placeholder: nvim -v + label: "โœ… Expected behavior:" + description: "The expected behavior." + placeholder: "Markview should..." validations: required: true + diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 7f0b51a..96e64e5 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,28 +1,32 @@ name: Feature Request -description: Request a new feature in markview -title: 'โœจ Feature: ' +description: "Request a new feature." +title: "โœจ Feature: " labels: [ "enhancement" ] -assignees: - - OXY2DEV body: - - type: checkboxes - id: feat-type - attributes: - label: 'The nature of the feature:' - description: | - Select one or more options that describes this feature. - options: - - label: Parser(syntax, conceal etc. related) - - label: Renderer(style, options etc. related) - - label: Support(plugin support, language support etc. related) - - label: Other - type: textarea id: feat-desc attributes: - label: 'Description:' - description: | - Describe the feature(images, videos, referances are welcome). - placeholder: A description of the feature... + label: "๐Ÿ”– Feature description:" + description: "Briefly describe what the feature does." + placeholder: "We should have a way to..." validations: required: true + - type: textarea + id: solutions + attributes: + label: "๐Ÿ“‚ Possible solutions:" + description: "Describe the solutions you have thought of on how to add this." + placeholder: "We should probably add..." + validations: + required: false + + - type: textarea + id: feat-ref + attributes: + label: "๐Ÿงพ Feature reference:" + description: "Reference features similar to what you wanted(if applicable)." + placeholder: "This feature is available in..." + validations: + required: false + diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index aa6caf8..6ee7085 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -6,7 +6,6 @@ on: jobs: stale: - runs-on: ubuntu-latest permissions: issues: write @@ -16,8 +15,17 @@ jobs: - uses: actions/stale@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: '๐Ÿค– Bot: **Issue** has not seen activity in **30** days and will therefore be marked as stale. It will be closed in 7 days if no further response is found.' - stale-pr-message: '๐Ÿค– Bot: **PR** has not seen activity in **30** days and will therefore be marked as stale. It will be closed in 7 days if no further response is found.' + days-before-stale: 30 + days-before-close: 7 + exempt-issue-labels: dev,important + + stale-issue-message: | + ๐Ÿค– Bot: There has been no recent activity in this issue. Without new activity this issue will be closed in **7** days. + stale-pr-message: | + ๐Ÿค– Bot: There has been no recent activity in this PR. Without new activity this PR will be closed in **7** days. + stale-issue-label: 'no-issue-activity' stale-pr-label: 'no-pr-activity' - days-before-stale: 30 + + close-issue-label: 'no-issue-activity' + close-pr-label: 'no-pr-activity' diff --git a/README.md b/README.md index 603b64c..723d960 100644 --- a/README.md +++ b/README.md @@ -1,110 +1,353 @@ -# โœจ markview.nvim - -https://github.com/user-attachments/assets/ae3d2912-65d4-4dd7-a8bb-614c4406c4e3 - - -A highly-customisable & feature rich markdown previewer inside Neovim. +

โ˜„๏ธ Markview.nvim

- ๐Ÿ“– Wiki page | - ๐ŸŽฎ Usage examples + A hackable Markdown, HTML, LaTeX, Typst & YAML previewer for Neovim.

-

- ๐Ÿ”‹ Extras | - ๐Ÿงฉ Presets -

+ + +
+ ๐Ÿ“š Wiki | ๐Ÿงฉ Extras | ๐Ÿ“ฆ Presets +
+ +## ๐Ÿ“– Table of contents + +- [โœจ Features](#-features) +- [๐Ÿ“š Requirements](#-requirements) +- [๐Ÿ“ Installation](#-installation) +- [๐Ÿงญ Configuration](#-configuration) + +- [๐ŸŽ‡ Commands](#-commands) +- [๐Ÿ“ž Autocmds](#-autocmds) +- [๐ŸŽจ Highlight groups](#-highlight-groups) + +- [๐ŸŽ Extra modules](#-extra-modules) + +## โœจ Features + +Core features, + ++ Supports HTML, LaTeX, Markdown, Typst & YAML. ++ Highly customisable! Everything is done via the *configuration table* to ensure maximum customisability. ++ Hybrid editing mode! Allows editing & *previewing* files at the same time. ++ Split view! Allows previewing files on a separate window that updates in real-time! ++ Partial *text wrap* support(only for markdown at the moment). ++ Dynamic config that allows **any** option to be a function. ++ Dynamic `highlight groups` that automatically updates with the colorscheme. + +
+ Expand to see complete feature list + +HTML features, + + + ++ Allows customising how various container & void elements are shown. ++ Supports *heading* elements out of the box. ++ Supports the following container elements out of the box, + + `` + + `` + + `` + + `` + + `` + + `` + + `` + + `` + + `` + ++ Supports the following void elements out of the box, + + `
` + + `
` + +LaTeX features, + + + ++ Supports the following items, + + Math blocks(typically `$$...$$`) & inline math(typically `$...$`). + + LaTeX commands. + + Escaped characters. + + Math fonts + + Subscript. + + Superscript. + + Math symbols. + + `\text{}`. + ++ Supports commonly used math commands out of the box, + + `\frac{}` + + `\sin{}` + + `\cos{}` + + `\tan{}` + + `\sinh{}` + + `\cosh{}` + + `\tanh{}` + + `\csc{}` + + `\sec{}` + + `\cot{}` + + `\csch{}` + + `\sech{}` + + `\coth{}` + + `\arcsin{}` + + `\arccos{}` + + `\arctan{}` + + `\arg{}` + + `\deg{}` + + `\drt{}` + + `\dim{}` + + `\exp{}` + + `\gcd{}` + + `\hom{}` + + `\inf{}` + + `\ker{}` + + `\lg{}` + + `\lim{}` + + `\liminf{}` + + `\limsup{}` + + `\ln{}` + + `\log{}` + + `\min{}` + + `\max{}` + + `\Pr{}` + + `\sup{}` + + `\sqrt{}` + + `\lvert{}` + + `\lVert{}` + + `\boxed{}` + ++ Supports the following fonts(requires any *modern* Unicode font), + + `default`(Default math font). + + `\mathbb{}` + + `\mathbf{}` + + `\mathbffrak{}` + + `\mathbfit{}` + + `\nathbfscr{}` + + `\mathcal{}` + + `\mathfrak{}` + + `\mathsf{}` + + `\mathsfbf{}` + + `\mathsfbfit{}` + + `\mathsfit{}` + + `\mathtt{}` + ++ Supports Unicode based *subscript* & *superscript* texts. ++ Supports **2056** different math symbol definitions. + +Markdown features, + + + ++ Supports the following items, + + Block quotes(with support for `callouts` & titles). + + Fenced code blocks. + + Headings(setext & atx). + + Horizontal rules. + + List items(`+`, `-`, `*`, `n.` & `n)`). + + Minus & plus metadata. + + Reference link definitions. + + Tables. + ++ `wrap` option support for the following items, + + Block quotes. + + Headings(when `org_indent` is used). + + List items(when `add_padding` is true). + ++ Org-mode like indentation for headings. + +Markdown inline features, + + + ++ Supports the following items, + + Checkboxes(supports *minimal-style* checkboxes). + + Email links. + + Entities. + + Escaped characters. + + Footnotes. + + Hyperlinks. + + Images. + + Inline codes/Code spans. + + URI autolinks. + ++ Obsidian/PKM extended item support, + + Block reference links. + + Embed file links. + + Internal links(supports *aliases*). + ++ Wide variety of HTML entity names & codes support. + + Supported named entities: **786**. + + Supported entity codes: **853**. + ++ Github emoji shorthands support. Supports **1920** shorthands. + ++ Custom configuration based on link patterns. + +Typst features, + + + ++ Supports the following items, + + Code blocks. + + Code spans. + + Escaped characters. + + Headings. + + Labels. + + List items(`-`, `+` & `n.`). + + Math blocks. + + Math spans. + + Raw blocks. + + Raw spans. + + Reference links. + + Subscripts. + + Superscripts. + + Symbols. + + Terms. + + URL links. -

- Headings -    -    - Inline - Block -    -    - Tables - LaTeX -    -    -

++ Supports a variety of typst symbols, + + Symbol entries: **932** + + Symbol shorthands: **40** + ++ Supports Unicode based *subscript* & *superscript* texts. + +YAML features, + + + +- Custom property icons. +- Custom property scope decorations. +- Custom icons(/decorations) based on property type & value(e.g. `booleans`). + +- Supports the following properties out of the box, + + tags. + + aliases. + + cssclasses. + + publish. + + permalink. + + description. + + images. + + cover. + +--- + +Hybrid mode features, + + +| Normal hybrid mode | Linewise hybrid mode | +|--------------------|----------------------| +| ![hybrid_mode](https://github.com/OXY2DEV/markview.nvim/blob/images/v25/wiki/hybrid_mode.png) | ![linewise_hybrid_mode](https://github.com/OXY2DEV/markview.nvim/blob/images/v25/wiki/linewise_hybrid_mode.png) | -## ๐Ÿชท Features -Markdown renderer, ++ *Node-based* edit range. + Clears the current nodes range of lines. Useful when editing lists, block quotes, code blocks, tables etc. -- Block quote support with custom `callouts/alertd`. Supports **callout titles** too. -- Checkbox with custom `states`. -- Code blocks. Also supports **info strings** added before the code blocks. -- Footnotes. -- Headings(both atx & setext). -- Horizontal rules. -- Inline codes. -- Links(hyperlinks, image links & email). -- List items(`+`, `-`, `*`, `n.` & `n)`) -- Tables. Supports content alignment, pre-defined column widths and rendering other markdown & html syntaxes inside of table cells. ++ *Range-based* edit range. + Clears the selected number of lines above & below the cursor. -HTML renderer, ++ Supports multiple cursors to. -- HTML elements(only inline ones). Also supports defining styles for custom tags. -- HTML entities. Supports 242 entities(as of last edit). +Internal Icon provider features, -LaTeX renderer, ++ **708** different filetype configuration. ++ Dynamic highlight groups for matching the colorscheme. -- Inline LaTeX support. -- LaTeX block supoort. -- LaTeX symbols support. supports 1000+ symbol names. -- Font commamd support. Currently supports: `\mathbfit`, `\mathcal`, `\mathfrak`, `\mathbb`, `\mathsfbf`, `\mathsfit`, `\mathsfbfit`, `\mathtt`. -- Subscripts & superscripts +Tracing features, -Others, + -- Hybrid mode, for previewing & editing. -- Split view, for showing preview in a split. -- Presets, for easy customisation. -- Tree-sitter injections, supports overwrites too! ++ You can use `:Markview traceShow` to see what the plugin has been doing(including how long some of them took). +- You can also use `:Markview traceExport` to export these logs. -Extras, + +
-- Heading level cycler. -- Checkbox toggler & cycler. +## ๐Ÿ“š Requirements -## ๐Ÿ“ฆ Requirements +System, -- Neovim version `>=0.10.1`. -- Tree-sitter parsers: `markdown`, `markdown_inline`, `html`. -- Nerd font. +- **Neovim:** 0.10.3 -Optional, +>[!NOTE] +> It is recommended to use `nowrap`(though there is wrap support in the plugin) & `expandtab`. + +--- -- Tree-sitter parsers: `latex`. -- `nvim-tree/nvim-web-deviconso`. -- Any modern unicode font. -- A tree-sitter supported colorscheme. +Colorscheme, -## ๐Ÿงญ Installation +- Any *tree-sitter* based colorscheme is recommended. -`markview.nvim` can be installed via your favourite plugin manager! +External icon providers, >[!NOTE] -> If you have manually installed the parsers then you don't need `nvim-treesitter`. Just make sure the parsers are loaded before this plugin. +> You need to change the config to use the desired icon provider. +> +> ```lua +> { +> preview = { +> icon_provider = "internal", -- "mini" or "devicons" +> } +> } +> ``` + +- [mini.icons](https://github.com/echasnovski/mini.icons) +- [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) + +Parsers, + +>[!TIP] +> You can use `nvim-treesitter` to easily install parsers. You can install all the parsers with the following command, +> +> ```vim +> :TSInstall markdown markdown_inline html latex typst yaml +> ``` + +- `markdown` +- `markdown_inline` +- `html`(optional) +- `latex`(optional) +- `typst`(optional) +- `yaml`(optional) + +Fonts, + +- Any *modern* Unicode font is required for math symbols. +- *Nerd fonts* are recommended. + +>[!TIP] +> It is recommended to run `:checkhealth markview` after installing the plugin to check if any potential issues exist. + +## ๐Ÿ“ Installation + +### ๐Ÿงฉ Vim-plug + +Add this to your plugin list. + +```vim +Plug "OXY2DEV/markview.nvim" +``` ### ๐Ÿ’ค Lazy.nvim ->[!CAUTION] -> It is not recommended to **lazy load** this plugin. +>[!WARNING] +> Do *not* lazy load this plugin as it is already lazy-loaded. +> +> Lazy-loading will cause **more time** for the previews to load when starting Neovim. + +The plugin should be loaded *after* your colorscheme to ensure the correct highlight groups are used. ```lua -{ +-- For `plugins/markview.lua` users. +return { "OXY2DEV/markview.nvim", - lazy = false, -- Recommended - -- ft = "markdown" -- If you decide to lazy-load anyway + lazy = false +}; +``` - dependencies = { - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons" - } -} +```lua +-- For `plugins.lua` users. +{ + "OXY2DEV/markview.nvim", + lazy = false +}, ``` ### ๐Ÿฆ  Mini.deps @@ -113,119 +356,320 @@ Optional, local MiniDeps = require("mini.deps"); MiniDeps.add({ - source = "OXY2DEV/markview.nvim", - - depends = { - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons" - } + source = "OXY2DEV/markview.nvim" }); ``` ### ๐ŸŒ’ Rocks.nvim ->[!NOTE] -> `Luarocks` may receive updates a bit later as the release is done after fixing any potential bug(s). +>[!WARNING] +> `luarocks package` may sometimes be a bit behind `main`. ```vim :Rocks install markview.nvim ``` -### ๐Ÿ‘พ GitHub releases +### ๐Ÿ“ฅ GitHub release + +Tagged releases can be found in the [release page](https://github.com/OXY2DEV/markview.nvim/releases). >[!NOTE] -> Releases may be slow to update as they are done after fixing potential bug(s). +> `Github releases` may sometimes be slightly behind `main`. -[Current version: v24.0.0]() +### ๐Ÿšจ Development version -### ๐ŸŒƒ Dev branch +You can use the [dev](https://github.com/OXY2DEV/markview.nvim/tree/dev) branch to use test features. >[!WARNING] -> `dev` branch may remain out-dated for an indefinite period of time. It is NOT meant for general use. +> Development releases can contain *breaking changes* and **experimental changes**. +> Use at your own risk! + +```lua +return { + "OXY2DEV/markview.nvim", + branch = "dev", + lazy = false +}; +``` -New features are usually done on the [dev branch]() first. +## ๐Ÿชฒ Known bugs -So, If you are curious about them, try this branch out! +- `code span`s don't get recognized when on the line after a `code block`(if the line after the `code span` is empty). + This is most likely due to some bug in either the `markdown` or the `markdown_inline` parser. -## ๐Ÿ’ก Configuration options +## ๐Ÿงญ Configuration -The configuration table is too large to fit here. +Check the [wiki](https://github.com/OXY2DEV/markview.nvim/wiki) for the entire configuration table. A simplified version is given below. -Go check the [wiki page]() or see `:h markview.nvim-configuration`. +
+ Click for config jump-scare -Here's all the main options, ```lua -{ - -- Buffer types to ignore - buf_ignore = { "nofile" }, - -- Delay, in miliseconds - -- to wait before a redraw occurs(after an event is triggered) - debounce = 50, - -- Filetypes where the plugin is enabled - filetypes = { "markdown", "quarto", "rmd" }, - -- Highlight groups to use - -- "dynamic" | "light" | "dark" - highlight_groups = "dynamic", - -- Modes where hybrid mode is enabled - hybrid_modes = nil, - -- Tree-sitter query injections - injections = {}, - -- Initial plugin state, - -- true = show preview - -- falss = don't show preview - initial_state = true, - -- Max file size that is rendered entirely - max_file_length = 1000, - -- Modes where preview is shown - modes = { "n", "no", "c" }, - -- Lines from the cursor to draw when the - -- file is too big - render_distance = 100, - -- Window configuration for split view - split_conf = {}, - - -- Rendering related configuration - block_quotes = {}, - callbacks = {}, - checkboxes = {}, - code_blocks = {}, - escaped = {}, - footnotes = {}, - headings = {}, - horizontal_rules = {}, - html = {}, - inline_codes = {}, - latex = {}, - links = {}, - list_items = {}, - tables = {} +--- Configuration table for `markview.nvim`. +---@class mkv.config +--- +---@field experimental config.experimental | fun(): config.experimental +---@field highlight_groups { [string]: config.hl } | fun(): { [string]: config.hl } +---@field html config.html | fun(): config.html +---@field latex config.latex | fun(): config.latex +---@field markdown config.markdown | fun(): config.markdown +---@field markdown_inline config.markdown_inline | fun(): config.markdown_inline +---@field preview config.preview | fun(): config.preview +---@field renderers config.renderer[] | fun(): config.renderer[] +---@field typst config.typst | fun(): config.typst +---@field yaml config.yaml | fun(): config.yaml +mkv.config = { + experimental = { + date_formats = {}, + date_time_formats = {}, + + text_filetypes = {}, + read_chunk_size = 1000, + link_open_alerts = false, + file_open_command = "tabnew", + + list_empty_line_tolerance = 3 + }, + highlight_groups = {}, + preview = { + enable = true, + filetypes = { "md", "rmd", "quarto" }, + ignore_buftypes = { "nofile" }, + ignore_previews = {}, + + modes = { "n", "no", "c" }, + hybrid_modes = {}, + debounce = 50, + draw_range = { vim.o.lines, vim.o.lines }, + edit_range = { 1, 0 }, + + callbacks = {}, + + splitview_winopts = { split = "left" } + }, + renderers = {}, + + html = { + enable = true, + + container_elements = {}, + headings = {}, + void_elements = {}, + }, + latex = { + enable = true, + + blocks = {}, + commands = {}, + escapes = {}, + fonts = {}, + inlines = {}, + parenthesis = {}, + subscripts = {}, + superscripts = {}, + symbols = {}, + texts = {} + }, + markdown = { + enable = true, + + block_quotes = {}, + code_blocks = {}, + headings = {}, + horizontal_rules = {}, + list_items = {}, + metadata_plus = {}, + metadata_minus = {}, + tables = {} + }, + markdown_inline = { + enable = true, + + block_references = {}, + checkboxes = {}, + emails = {}, + embed_files = {}, + entities = {}, + escapes = {}, + footnotes = {}, + highlights = {}, + hyperlinks = {}, + images = {}, + inline_codes = {}, + internal_links = {}, + uri_autolinks = {} + }, + typst = { + enable = true, + + codes = {}, + escapes = {}, + headings = {}, + labels = {}, + list_items = {}, + math_blocks = {}, + math_spans = {}, + raw_blocks = {}, + raw_spans = {}, + reference_links = {}, + subscripts = {}, + superscript = {}, + symbols = {}, + terms = {}, + url_links = {} + }, + yaml = { + enable = true, + + properties = {} + } } ``` + +
-## ๐Ÿ‘€ Commands +## ๐ŸŽ‡ Commands -`markview.nvim` has a single command `:Markview`. +This plugin follows the *sub-commands* approach for creating commands. There is only a single `:Markview` command. -> When used without any `subcommands`, it toggles the plugin. +It comes with the following sub-commands, -Available subcommands, +>[!NOTE] +> When no sub-command name is provided(or an invalid sub-command is used) `:Markview` will run `:Markview Toggle`. + + +| Sub-command | Arguments | Description | +|--------------|---------------------|------------------------------------------| +| `Start` | none | Allows attaching to new buffers. | +| `Stop` | none | Prevents attaching to new buffers. | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| `attach` | **buffer**, integer | Attaches to **buffer**. | +| `detach` | **buffer**, integer | Detaches from **buffer**. | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| `Enable` | none | Enables preview *globally*. | +| `Disable` | none | Disables preview *globally*. | +| `Toggle` | none | Toggles preview *globally*. | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| `enable` | **buffer**, integer | Enables preview for **buffer**. | +| `disable` | **buffer**, integer | Disables preview for **buffer**. | +| `toggle` | **buffer**, integer | Toggles preview for **buffer**. | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| `splitOpen` | **buffer**, integer | Opens *splitview* for **buffer**. | +| `splitClose` | none | Closes any open *splitview*. | +| `splitToggle`| none | Toggles *splitview*. | +| `splitRedraw`| none | Updates *splitview* contents. | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| `Render` | none | Updates preview of all *active* buffers. | +| `Clear` | none | Clears preview of all **active** buffer. | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| `render` | **buffer**, integer | Renders preview for **buffer**. | +| `clear` | **buffer**, integer | Clears preview for **buffer**. | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| `toggleAll` | none | **Deprecated** version of `Toggle`. | +| `enableAll` | none | **Deprecated** version of `Enable`. | +| `disableAll` | none | **Deprecated** version of `Disable`. | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| `traceExport`| none | Exports trace logs to `trace.txt`. | +| `traceShow` | none | Shows trace logs in a window. | + +>[!TIP] +> **buffer** defaults to the current buffer. So, you can run commands on the current buffer without providing the buffer. +> ```vim +> :Markview toggle "Toggles preview of the current buffer. +> ``` + +## ๐Ÿ“ž Autocmds + +`markview.nvim` emits various *autocmd events* during different parts of the rendering allowing users to extend the plugin's functionality. -- toggleAll -- enableAll -- disableAll -- toggle {n} -- enable {n} -- disable {n} -- hybridToggle -- hybridEnable -- hybridDisable -- splitToggle {n} -- splitEnable {n} -- splitDisable {n} +```lua +vim.api.nvim_create_autocmd("User", { + pattern = "MarkviewAttach", + callback = function (event) + --- This will have all the data you need. + local data = event.data; + + vim.print(data); + end +}) +``` >[!NOTE] -> Subcommands that end with `{n}` can also take a buffer id. If a buffer id isn't provided then the current buffer's id is used. -> Completion for buffer id is also provided by the plugin. +> Autocmds are executed **after** callbacks! + +Currently emitted autocmds are, + +- **MarkviewAttach** + Called when attaching to a buffer. + + Arguments, + + + `buffer`, integer + The buffer that's being attached to. + + + `windows`, integer[] + List of windows attached to `buffer`. + +- **MarkviewDetach** + Called when detaching from a buffer. + + Arguments, + + + `buffer`, integer + The buffer that's being detached from. + + + `windows`, integer[] + List of windows attached to `buffer`. + +- **MarkviewDisable** + Called when disabling previews in a buffer. + + Arguments, + + + `buffer`, integer + The buffer whose the preview was disabled. + + + `windows`, integer[] + List of windows attached to `buffer`. + +- **MarkviewEnable** + Called when enabling previews in a buffer. + + Arguments, + + + `buffer`, integer + The buffer whose the preview was enabled. + + + `windows`, integer[] + List of windows attached to `buffer`. + +- **MarkviewSplitviewClose** + Called when the splitview window is closed. Called *before* splitview is closed. + + Arguments, + + + `source`, integer + The buffer whose contents are being shown. + + + `preview_buffer`, integer + The buffer that's showing the preview. + + + `preview_window`, integer + The window where the `preview_buffer` is being shown. + +- **MarkviewSplitviewOpen** + Called when the splitview window is opened. + + Arguments, + + + `source`, integer + The buffer whose contents are being shown. + + + `preview_buffer`, integer + The buffer that's showing the preview. + + + `preview_window`, integer + The window where the `preview_buffer` is being shown. Additional command(s), @@ -233,223 +677,266 @@ Additional command(s), ## ๐ŸŽจ Highlight groups -

- Light -    -    - Dark -

+`markview.nvim` creates a number of *primary highlight groups* that are used by most of the decorations. + +>[!IMPORTANT] +> These groups are all **generated** during runtime and as such their colors may look different. + +If you want to create your own *dynamic* highlight groups or modify existing ones, see the [custom highlight groups](placeholder) section. + + +| Highlight group | Generated from | Default | +|----------------------|------------------------------------------|-----------------------------| +| MarkviewPalette0 | Normal(bg) + Comment(fg) | fg: `#9399b2` bg: `#35374a` | +| MarkviewPalette0Fg | Comment(fg) | fg: `#9399b2` | +| MarkviewPalette0Bg | Normal(bg) + Comment(fg) | bg: `#35374a` | +| MarkviewPalette0Sign | Normal(bg) + Comment(fg), LineNr(bg) | fg: `#9399b2` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewPalette1 | Normal(bg) + markdownH1(fg) | fg: `#f38ba8` bg: `#4d3649` | +| MarkviewPalette1Fg | markdownH1(fg) | fg: `#f38ba8` | +| MarkviewPalette1Bg | Normal(bg) + markdownH1(fg) | bg: `#4d3649` | +| MarkviewPalette1Sign | Normal(bg) + markdownH1(fg), LineNr(bg) | fg: `#f38ba8` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewPalette2 | Normal(bg) + markdownH2(fg) | fg: `#f9b387` bg: `#4d3d43` | +| MarkviewPalette2Fg | markdownH2(fg) | fg: `#f9b387` | +| MarkviewPalette2Bg | Normal(bg) + markdownH2(fg) | bg: `#4d3d43` | +| MarkviewPalette2Sign | Normal(bg) + markdownH2(fg), LineNr(bg) | fg: `#f9b387` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewPalette3 | Normal(bg) + markdownH3(fg) | fg: `#f9e2af` bg: `#4c474b` | +| MarkviewPalette3Fg | markdownH3(fg) | fg: `#f9e2af` | +| MarkviewPalette3Bg | Normal(bg) + markdownH3(fg) | bg: `#4c474b` | +| MarkviewPalette3Sign | Normal(bg) + markdownH3(fg), LineNr(bg) | fg: `#f9e2af` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewPalette4 | Normal(bg) + markdownH4(fg) | fg: `#a6e3a1` bg: `#3c4948` | +| MarkviewPalette4Fg | markdownH4(fg) | fg: `#a6e3a1` | +| MarkviewPalette4Bg | Normal(bg) + markdownH4(fg) | bg: `#3c4948` | +| MarkviewPalette4Sign | Normal(bg) + markdownH4(fg), LineNr(bg) | fg: `#a6e3a1` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewPalette5 | Normal(bg) + markdownH5(fg) | fg: `#74c7ec` bg: `#314358` | +| MarkviewPalette5Fg | markdownH5(fg) | fg: `#74c7ec` | +| MarkviewPalette5Bg | Normal(bg) + markdownH5(fg) | bg: `#314358` | +| MarkviewPalette5Sign | Normal(bg) + markdownH5(fg), LineNr(bg) | fg: `#74c7ec` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewPalette6 | Normal(bg) + markdownH6(fg) | fg: `#b4befe` bg: `#3c405b` | +| MarkviewPalette6Fg | markdownH6(fg) | fg: `#b4befe` | +| MarkviewPalette6Bg | Normal(bg) + markdownH6(fg) | bg: `#3c405b` | +| MarkviewPalette6Sign | Normal(bg) + markdownH6(fg), LineNr(bg) | fg: `#b4befe` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewPalette7 | Normal(bg) + @conditional(fg) | fg: `#cba6f7` bg: `#403b5a` | +| MarkviewPalette7Fg | @conditional(fg) | fg: `#cba6f7` | +| MarkviewPalette7Bg | Normal(bg) + @conditional(fg) | bg: `#403b5a` | +| MarkviewPalette7Sign | Normal(bg) + @conditional(fg), LineNr(bg)| fg: `#cba6f7` | + + +> The source highlight group's values are turned into `Lab` color-space and then mixed to reduce unwanted results. + +These groups are then used as links by other groups responsible for various preview elements, -Highlight groups defined by the plugin are given below. - -+ Block quotes - - `MarkviewBlockQuoteWarn` - - `MarkviewBlockQuoteSpecial` - - `MarkviewBlockQuoteNote` - - `MarkviewBlockQuoteDefault` - - `MarkviewBlockQuoteOk` - - `MarkviewBlockQuoteError` - -+ Checkboxes - - `MarkviewCheckboxCancelled` - - `MarkviewCheckboxChecked` - - `MarkviewCheckboxPending` - - `MarkviewCheckboxProgress` - - `MarkviewCheckboxUnchecked` - - `MarkviewCheckboxStriked` - -+ Code blocks & Inline codes - - `MarkviewInlineCode` - - `MarkviewCodeInfo` - - `MarkviewCode` - -+ Code block icons(Internal icon provider) - - `MarkviewIcon1` - - `MarkviewIcon1Sign` - - `MarkviewIcon1Fg` - - `MarkviewIcon2` - - `MarkviewIcon2Sign` - - `MarkviewIcon2Fg` - - `MarkviewIcon3` - - `MarkviewIcon3Sign` - - `MarkviewIcon3Fg` - - `MarkviewIcon4` - - `MarkviewIcon4Sign` - - `MarkviewIcon4Fg` - - `MarkviewIcon5` - - `MarkviewIcon5Sign` - - `MarkviewIcon5Fg` - - `MarkviewIcon6` - - `MarkviewIcon6Sign` - - `MarkviewIcon6Fg` - -+ Headings - - `MarkviewHeading1Sign` - - `MarkviewHeading1` - - `MarkviewHeading2Sign` - - `MarkviewHeading2` - - `MarkviewHeading3Sign` - - `MarkviewHeading3` - - `MarkviewHeading4Sign` - - `MarkviewHeading4` - - `MarkviewHeading5Sign` - - `MarkviewHeading5` - - `MarkviewHeading6Sign` - - `MarkviewHeading6` - -+ Horizontal rules - - `MarkviewGradient1` - - `MarkviewGradient2` - - `MarkviewGradient3` - - `MarkviewGradient4` - - `MarkviewGradient5` - - `MarkviewGradient6` - - `MarkviewGradient7` - - `MarkviewGradient8` - - `MarkviewGradient9` - - `MarkviewGradient10` - -+ LaTeX - - `MarkviewLatexSubscript` - - `MarkviewLatexSuperscript` - -+ List items - - `MarkviewListItemStar` - - `MarkviewListItemPlus` - - `MarkviewListItemMinus` - -+ Links - - `MarkviewEmail` - - `MarkviewImageLink` - - `MarkviewHyperlink` - -+ Tables - - `MarkviewTableHeader` - - `MarkviewTableBorder` - - `MarkviewTableAlignCenter` - - `MarkviewTableAlignLeft` - - `MarkviewTableAlignRight` - -## ๐ŸŽฎ Usage examples - -Don't forget to check out the [wiki](https://github.com/OXY2DEV/markview.nvim/wiki)! - -### ๐ŸŒŸ Hybrid mode - -Hybrid mode can be used by just modifying the `hybrid_modes` option. +>[!NOTE] +> These groups exist for the sake of *backwards compatibility* and *ease of use*. +> +> You will see something like `fg: Normal`, it means the *fg* of Normal was used as the *fg* of that group. + + +| Highlight group | value | +|---------------------------|--------------------------------------------| +| MarkviewBlockQuoteDefault | link: `MarkviewPalette0Fg` | +| MarkviewBlockQuoteError | link: `MarkviewPalette1Fg` | +| MarkviewBlockQuoteNote | link: `MarkviewPalette5Fg` | +| MarkviewBlockQuoteOk | link: `MarkviewPalette4Fg` | +| MarkviewBlockQuoteSpecial | link: `MarkviewPalette3Fg` | +| MarkviewBlockQuoteWarn | link: `MarkviewPalette2Fg` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewCheckboxCancelled | link: `MarkviewPalette0Fg` | +| MarkviewCheckboxChecked | link: `MarkviewPalette4Fg` | +| MarkviewCheckboxPending | link: `MarkviewPalette2Fg` | +| MarkviewCheckboxProgress | link: `MarkviewPalette6Fg` | +| MarkviewCheckboxUncheked | link: `MarkviewPalette1Fg` | +| MarkviewCheckboxStriked | link\*: `MarkviewPalette0Fg` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewCode | bg\*\*: `normal` ยฑ 5%(L) | +| MarkviewCodeInfo | bg\*\*: `normal` ยฑ 5%(L), fg: `comment` | +| MarkviewCodeFg | fg\*\*: `normal` ยฑ 5%(L) | +| MarkviewInlineCode | fg\*\*: `normal` ยฑ 10%(L) | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewIcon0 | link\*\*\*: `MarkviewPalette0Fg` | +| MarkviewIcon1 | link\*\*\*: `MarkviewPalette1Fg` | +| MarkviewIcon2 | link\*\*\*: `MarkviewPalette5Fg` | +| MarkviewIcon3 | link\*\*\*: `MarkviewPalette4Fg` | +| MarkviewIcon4 | link\*\*\*: `MarkviewPalette3Fg` | +| MarkviewIcon5 | link\*\*\*: `MarkviewPalette2Fg` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewGradient0 | fg: `Normal` | +| MarkviewGradient1 | fg\*\*\*\*: `lerp(Normal, Title, 1/9)` | +| MarkviewGradient2 | fg\*\*\*\*: `lerp(Normal, Title, 2/9)` | +| MarkviewGradient3 | fg\*\*\*\*: `lerp(Normal, Title, 3/9)` | +| MarkviewGradient4 | fg\*\*\*\*: `lerp(Normal, Title, 4/9)` | +| MarkviewGradient5 | fg\*\*\*\*: `lerp(Normal, Title, 5/9)` | +| MarkviewGradient6 | fg\*\*\*\*: `lerp(Normal, Title, 6/9)` | +| MarkviewGradient7 | fg\*\*\*\*: `lerp(Normal, Title, 7/9)` | +| MarkviewGradient8 | fg\*\*\*\*: `lerp(Normal, Title, 8/9)` | +| MarkviewGradient9 | fg: `Title` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewHeading1 | link: `MarkviewPalette1` | +| MarkviewHeading2 | link: `MarkviewPalette2` | +| MarkviewHeading3 | link: `MarkviewPalette3` | +| MarkviewHeading4 | link: `MarkviewPalette4` | +| MarkviewHeading5 | link: `MarkviewPalette5` | +| MarkviewHeading6 | link: `MarkviewPalette6` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewEmail | link: `@markup.link.url.markdown_inline` | +| MarkviewHyperlink | link: `@markup.link.label.markdown_inline` | +| MarkviewImage | link: `@markup.link.label.markdown_inline` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewSubscript | link: `MarkviewPalette3Fg` | +| MarkviewSuperscript | link: `MarkviewPalette6Fg` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewListItemMinus | link: `MarkviewPalette2Fg` | +| MarkviewListItemPlus | link: `MarkviewPalette4Fg` | +| MarkviewListItemStar | link: `MarkviewPalette6Fg` | +| โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” | +| MarkviewTableHeader | link: `@markup.heading.markdown` | +| MarkviewTableBorder | link: `MarkviewPalette5Fg` | +| MarkviewTableAlignCenter | link: `MarkviewPalette5Fg` | +| MarkviewTableAlignLeft | link: `MarkviewPalette5Fg` | +| MarkviewTableAlignRight | link: `MarkviewPalette5Fg` | + + +> \* = Only the foreground color is used. Strikeout is added. +> +> \*\* = The color is converted to HSL and it's luminosity(L) is increased/decreased by the specified amount. +> +> \*\*\* = The background color of `MarkviewCode` is added to the groups. +> +> \*\*\*\* = Linearly interpolated value between 2 highlight groups `fg`. + +## ๐ŸŒŸ Presets + +>[!IMPORTANT] +> Presets are looking for contributors! +> +> If you have any custom configuration that you would like to have as a preset you can open a `pull request` for that. + +Check the [wiki page](https://github.com/OXY2DEV/markview.nvim/wiki) for more information. + +### ๐Ÿ“š Usage ```lua +local presets = require("markview.presets"); + require("markview").setup({ - hybrid_modes = { "n" } + markdown = { + headings = presets.headings.slanted + } }); ``` ->[!Tip] -> You can toggle `hybrid mode` via `:Markview hybridToggle`! +Currently available presets are, -### ๐ŸŒŸ Split view +### headings -You can show previews in a split! +Accessed using `require("markview.presets").headings`. -```vim -:Markview splitToggle -``` +- `glow` + Like the headings in the `Glow` CLI app. -### ๐ŸŒŸ Foldable headings +- `glow_center` + Centered version of `glow`. -You can use `tree-sitter` injections for folding text! +- `slanted` + Heading level + slanted tail. -You first need to modify the fold method and the expression used for folding text. +- `arrowed` + Heading level + arrowed tail. -```lua -vim.o.foldmethod = "expr"; -vim.o.foldexpr= "nvim_treesitter#foldexpr()"; -``` +- `simple` + Headings similar to headings in some books. + +- `marker` + Simple marker for heading level. ->[!Note] -> You might want to set this using the `on_enable` callback of the plugin, if you don't want this in other filetypes. +### horizontal_rules -Now, we create a query to fold the headings. +Accessed using `require("markview.presets").horizontal_rules`. + +- `thin` + Simple line. + +- `thick` + Slightly thicker line. + +- `double` + Double lines. + +- `dahsed` + Dashed line. + +- `dotted` + Dotted line. + +- `solid` + Very thick line. + +- `arrowed` + Arrowed line. + +### tables + +Accessed using `require("markview.presets").tables`. + +- `none` + Border-less table(kinda like the ones used in some help files). + +- `single` + Single border table. + +- `double` + Double border table. + +- `rounded` + Single border with rounded edges(default). + +- `solid` + Solid border table. + +## ๐ŸŽ Extra modules + +`markview.nvim` comes with a few *extra* things for added functionality. Currently available modules are, + +- [checkboxes.lua](https://github.com/OXY2DEV/markview.nvim/blob/main/lua/markview/extras/checkboxes.lua) + Checkbox toggle, state change & more! Supports visual mode too with checkbox state caching! + [Wiki section](https://github.com/OXY2DEV/markview.nvim/wiki/Extra-modules#-checkboxes) + +- [editor.lua](https://github.com/OXY2DEV/markview.nvim/blob/main/lua/markview/extras/editor.lua) + A simple `code block` creator & editor with support for nested elements! + [Wiki section](https://github.com/OXY2DEV/markview.nvim/wiki/Extra-modules#-editor) + +- [headings.lua](https://github.com/OXY2DEV/markview.nvim/blob/main/lua/markview/extras/headings.lua) + Simple heading level changer with support for `setext` headings. + [Wiki section](https://github.com/OXY2DEV/markview.nvim/wiki/Extra-modules#-heading) + +Example usage, ```lua -require("markview").setup({ - injections = { - languages = { - markdown = { - --- This disables other - --- injected queries! - overwrite = true, - query = [[ - (section - (atx_headng) @injections.mkv.fold - (#set! @fold)) - ]] - } - } - } -}); +-- Load the checkboxes module. +require("markview.extras.checkboxes").setup(); ``` -Here's a bit of explanation on what the text does. +Go over a line with a checkbox and run, -```query -; Matches any section of text that starts with -; a heading. -(section - (atx_headng) @injections.mkv.fold - ; This folds the section! - (#set! fold)) +```vim +:Checkbox interactive ``` +Now use `h`, `j`, `k`, `l` to change the checkbox state. -Optionally, you can use a foldtext plugin tp change what is shown! For example, I can use [foldtext.nvim](https://www.github.com/OXY2DEV/foldtext.nvim) for this. +## โœ… Contributing to the projects -```lua -local def = require("foldtext").configuration; -local handler = function (_, buf) - local ln = table.concat(vim.fn.getbufline(buf, vim.v.foldstart)); - local markers = ln:match("^%s*([#]+)"); - local heading_txt = ln:match("^%s*[#]+(.+)$"); - - local icons = { - "๓ฐŽค", "๓ฐŽฉ", "๓ฐŽช", "๓ฐŽฎ", "๓ฐŽฑ", "๓ฐŽต" - } +If you have time and want to make this project better, consider helping me fix any of these issues, - return { - icons[vim.fn.strchars(markers or "")] .. heading_txt, - "MarkviewHeading" .. vim.fn.strchars(markers or ""); - } -end -local spaces = function (_, buf) - local ln = table.concat(vim.fn.getbufline(buf, vim.v.foldstart)); - local markers = ln:match("^%s*([#]+)"); - local heading_txt = ln:match("^%s*[#]+(.+)$"); - - return { - string.rep(" ", vim.o.columns - vim.fn.strchars(heading_txt) - 1), - "MarkviewHeading" .. vim.fn.strchars(markers or ""); - } -end - -require("foldtext").setup({ - custom = vim.list_extend(def, { - { - ft = { "markdown" }, - config = { - { type = "indent" }, - { - type = "custom", - handler = handler - }, - { - type = "custom", - handler = spaces - } - } - } - }); -}); -``` +- [ ] Add support for more filetypes in the internal icon provider. +- [ ] Optimization of `require("markview.renderers.markdown").output()`. +- [ ] Optimization of the table renderer. +- [ ] Stricter logic to reduce preview redraws. +- [ ] Make `splitview` update as little content as possible. +- [ ] Make the help files/wiki more beginner friendly. - diff --git a/doc/advanced_usage.txt b/doc/advanced_usage.txt new file mode 100644 index 0000000..d37e9c2 --- /dev/null +++ b/doc/advanced_usage.txt @@ -0,0 +1,173 @@ +*markview.nvim-advanced* Advanced usage guide for markview + +------------------------------------------------------------------------------ +๐Ÿ“‚ Header folding *markview.nvim-advanced.header_folding* + + 1. Create a new file `~/.config/nvim/queries/markdown/folds.scm`. + + 2. Add these lines to that file, +>query + ; 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. +< + 3. 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`, +>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. +>lua + ---@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()" +< + +------------------------------------------------------------------------------ +vim:ft=help:colorcolumn=78:virtualedit=all: diff --git a/doc/custom_renderers.txt b/doc/custom_renderers.txt new file mode 100644 index 0000000..c3e1ffe --- /dev/null +++ b/doc/custom_renderers.txt @@ -0,0 +1,107 @@ +*markview.nvim-renderers* Custom renderers for markview + +You can create your own renderers if you don't like the default ones. +>lua + require("markview").setup({ + renderers = { + --- Custom renderer for YAML properties. + ---@param ns integer Namespace to use for extmarks. + ---@param buffer integer Buffer where + ---@param item table The parsed version of a node. + yaml_property = function (ns, buffer, item) + --- Do custom stuff. + end + } + }); +< +โ–‹ โš ๏ธ Warning +โ–‹ A lot of items don't match their option names. E.g. `inline_link_hyperlink` +โ–‹ & `inline_link_shortcut` are both configured via `hyperlinks`. + +The structure and data of an `item` can be found in their option's wiki +section. +For example, to see the one for `markdown_block_quote` head over to +`Markdown options.md` in the wiki and go to the `block_quotes` section. +You will find the definition of item in the second drop-down. + +โ–‹ ๐Ÿ’ก Tip: +โ–‹ I highly recommend checking out the default renderers in +โ–‹ `lua/markview/renderers` first. + +Currently supported syntax items are, + + - `html` + + `html_container_element` + + `html_heading` + + `html_void_element` + + - `latex` + + `latex_block` + + `latex_command` + + `latex_escaped` + + `latex_font` + + `latex_inline` + + `latex_parenthesis` + + `latex_subscript` + + `latex_superscript` + + `latex_symbol` + + `latex_text` + + `latex_word`(used for applying text styles to a word) + + - `markdown` + + `markdown_atx_heading` + + `markdown_block_quote` + + `markdown_checkbox`(for `[x]`, `[X]`, `[ ]`) + + `markdown_code_block` + + `markdown_hr`(horizontal rule) + + `markdown_link_ref_definition` + + `markdown_list_item` + + `markdown_metadata_minus` + + `markdown_metadata_plus` + + `markdown_section`(for Org-mode like heading indentation) + + `markdown_setext_heading` + + `markdown_table` + + - `markdown_inline` + + `inline_checkbox` + + `inline_code_span`(inline codes) + + `inline_entity`(HTML entity reference) + + `inline_escaped` + + `inline_footnote` + + `inline_highlight`(PKM-like highlighted text) + + `inline_emoji`(emoji shorthands) + + `inline_link_block_ref`(obsidian's block reference link) + + `inline_link_embed_file`(obsidian's embed file link) + + `inline_link_email` + + `inline_link_hyperlink` + + `inline_link_image` + + `inline_link_internal`(obsidian's internal links) + + `inline_link_shortcut`(shortcut link) + + `inline_link_uri_autolink` + + - `typst` + + `typst_code_block` + + `typst_code_span` + + `typst_emphasis`(used internally) + + `typst_escaped` + + `typst_heading` + + `typst_label` + + `typst_list_item` + + `typst_link_ref`(reference link) + + `typst_link_url`(URL links) + + `typst_math_block` + + `typst_math_span` + + `typst_raw_block` + + `typst_raw_span` + + `typst_strong`(used internally) + + `typst_subscript` + + `typst_superscript` + + `typst_symbol` + + `typst_term` + + `typst_text`(used for applying text styles to a word) + + - `yaml` + + `yaml_property` + +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/dev.txt b/doc/dev.txt new file mode 100644 index 0000000..8fa83eb --- /dev/null +++ b/doc/dev.txt @@ -0,0 +1,153 @@ +*markview.nvim-dev* Developer documentations + + Mostly for extending plugin functionalities. + +------------------------------------------------------------------------------ +๐Ÿ“š Table of contents *markview.nvim-dev.toc* + + ๐Ÿ“‘ States ...................................... |markview.nvim-dev.states| + ๐Ÿš€ Internal functions ....................... |markview.nvim-dev.functions| + โœจ Manual previews .................... |markview.nvim-dev.manual_previews| + +------------------------------------------------------------------------------ +๐Ÿ“‘ States *markview.nvim-dev.states* + +Plugin states are stored in `require("markview").states`. +>lua + --- Table containing various plugin states. + ---@class mkv.state + --- + --- List of attached buffers. + ---@field attached_buffers integer[] + --- + --- Buffer local states. + ---@field buffer_states { [integer]: { enable: boolean, hybrid_mode: boolean? } } + --- + --- Source buffer for hybrid mode. + ---@field splitview_source? integer + --- Preview buffer for hybrid mode. + ---@field splitview_buffer? integer + --- Preview window for hybrid mode. + ---@field splitview_window? integer + markview.state = { + attached_buffers = {}, + buffer_states = {}, + + splitview_buffer = nil, + splitview_source = nil, + splitview_window = nil + }; +< +โ–‹ โš ๏ธ Warning +โ–‹ `splitview_buffer` might not be `nil` even after closing splitview as +โ–‹ there's no point in creating a new buffer every time. + +------------------------------------------------------------------------------ +๐Ÿš€ Internal functions *markview.nvim-dev.functions* + +โ–‹ ๐Ÿ’ก Tip: +โ–‹ The sub-command implementation can be found in +โ–‹ `require("markview").commands`. + +Commonly used functions can be found inside `require("markview").actions`. +These are, + + - `__exec_callback`, + Safely executes a given callback. + + Usage: `markview.actions.__exec_callback(callback, ...)` + + `callback`, callback name. + + `...` arguments. + + - `__is_attached`, + Checks if `markview` is attached to a buffer or not. + + Usage: `markview.actions.__is_attached(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + + Return: `boolean` + + - `__is_enabled`, + Checks if `markview` is enabled on a buffer or not. + + Usage: `markview.actions.__is_enabled(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + + Return: `boolean` + + - `__splitview_setup` + Sets up the buffer & window for `splitview`. + + Usage: `markview.actions.__splitview_setup()` + +------------------------------------------------------------------------------ + + - `attach` + Attaches `markview` to a buffer. + + Usage: `markview.actions.attach(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + + - `detach` + Detaches `markview` to a buffer. + + Usage: `markview.actions.detach(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + +------------------------------------------------------------------------------ + + - `enable` + Enables previews for the given buffer. + + Usage: `markview.actions.enable(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + + - `disable` + Disables previews for the given buffer. + + Usage: `markview.actions.disable(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + +------------------------------------------------------------------------------ + + - `hybridEnable` + Enables *hybrid mode* for the given buffer. + + Usage: `markview.actions.hybridEnable(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + + - `hybridDisable` + Disables *hybrid mode* for the given buffer. + + Usage: `markview.actions.hybridDisable(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + +------------------------------------------------------------------------------ + + - `splitOpen` + Opens splitview for the given buffer. + + Usage: `markview.actions.splitOpen(buffer)` + + `buffer`, buffer ID(defaults to current buffer). + + - `splitClose` + Closes any open splitview window. + +------------------------------------------------------------------------------ +โœจ Manual previews *markview.nvim-dev.manual_previews* + +You can manually show previews via these functions, + + - `markview.render(buffer)` + Renders preview on `buffer`(defaults to current buffer). + + - `markview.clear(buffer)` + Clears previews of `buffer`(defaults to current buffer). + +------------------------------------------------------------------------------ + + - `markview.clean()` + Detaches `markview` from any invalid buffer. + +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/experimental_options.txt b/doc/experimental_options.txt new file mode 100644 index 0000000..91fac84 --- /dev/null +++ b/doc/experimental_options.txt @@ -0,0 +1,120 @@ +*markview.nvim-experimental* Experimental options for markview + + Options that are still under development or don't affect core + functionalities of `markview`. +>lua + -- [ Markview | Experimental options ] ---------------------------------------------------- + + --- Configuration for experimental options. + ---@class config.experimental + --- + --- Command used to open files inside Neovim. + ---@field file_open_command? string + --- Number of `bytes` to check before opening a link. Used for detecting when to open files inside Neovim. + ---@field read_chunk_size? integer + --- + --- Maximum number of empty lines that can stay between text of a list item. + ---@field list_empty_line_tolerance? integer + --- + --- String formats for detecting date in YAML. + ---@field date_formats? string[] + --- String formats for detecting date & time in YAML. + ---@field date_time_formats? string[] + experimental = { + read_chunk_size = 1024, + + file_open_command = "tabnew", + list_empty_line_tolerance = 3, + + date_formats = { + "^%d%d%d%d%-%d%d%-%d%d$", --- YYYY-MM-DD + "^%d%d%-%d%d%-%d%d%d%d$", --- DD-MM-YYYY, MM-DD-YYYY + "^%d%d%-%d%d%-%d%d$", --- DD-MM-YY, MM-DD-YY, YY-MM-DD + + "^%d%d%d%d%/%d%d%/%d%d$", --- YYYY/MM/DD + "^%d%d%/%d%d%/%d%d%d%d$", --- DD/MM/YYYY, MM/DD/YYYY + + "^%d%d%d%d%.%d%d%.%d%d$", --- YYYY.MM.DD + "^%d%d%.%d%d%.%d%d%d%d$", --- DD.MM.YYYY, MM.DD.YYYY + + "^%d%d %a+ %d%d%d%d$", --- DD Month YYYY + "^%a+ %d%d %d%d%d%d$", --- Month DD, YYYY + "^%d%d%d%d %a+ %d%d$", --- YYYY Month DD + + "^%a+%, %a+ %d%d%, %d%d%d%d$", --- Day, Month DD, YYYY + }, + + date_time_formats = { + "^%a%a%a %a%a%a %d%d %d%d%:%d%d%:%d%d ... %d%d%d%d$", --- UNIX date time + "^%d%d%d%d%-%d%d%-%d%dT%d%d%:%d%d%:%d%dZ$", --- ISO 8601 + } + }; +< + *markview.nvim-experimental.file_open_command* +file_open_command ~ + + - Type: `string` + - Dynamic: true + - Default: "tabnew" + +Command used for opening links inside Neovim. + + *markview.nvim-experimental.read_chunk_size* +read_chunk_size ~ + + - Type: `integer` + - Dynamic: true + - Default: 1000 + +โ–‹ ๐Ÿšจ Important +โ–‹ This isn't used if `text_filetypes` is set. + +Number of bytes to check to determine if a file is a text file or not when +opening links. + +If the file is a text file, it will be opened inside `Neovim`. + + *markview.nvim-experimental.list_empty_line_tolerance* +list_empty_line_tolerance ~ + + - Type: `integer` + - Dynamic: true + - Default: 3 + +Number of empty lines a list item can have between it's lines. Useful when +adding text directly under a list. + +>txt + TSNode โ”‚ Indentation โ”ƒ List โ”ƒ + range โ”‚ range โ”ƒ Item โ”ƒ + + โ•Ž โ•‘ - This is a list item. + โ•Ž โ•‘ It has some text inside it. + โ•Ž โ•‘ + โ•Ž โ•‘ + โ•Ž โ•‘ This line will be considered + โ•Ž โ•‘ part of the list. + โ•Ž + โ•Ž + โ•Ž + โ•Ž This line won't be considered + โ•Ž part of the list. +< + *markview.nvim-experimental.date_formats* +date_formats ~ + + - Type: `string[]` + - Dynamic: false + +List of `lua patterns` for detecting dates in YAML. + + *markview.nvim-experimental.date_time_formats* +date_time_formats ~ + + - Type: `string[]` + - Dynamic: false + +List of `lua patterns` for detecting date & time in YAML. + +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/extra.txt b/doc/extra.txt new file mode 100644 index 0000000..ef4721f --- /dev/null +++ b/doc/extra.txt @@ -0,0 +1,136 @@ +*markview.nvim-extra* Extra modules for markview + +------------------------------------------------------------------------------ +โœ… Checkboxes *markview.nvim-extra.checkboxes* + +๐Ÿ“œ Overview ~ + +A simple `state-aware` checkbox toggle for markdown. + +Features, + + - Simple checkbox state cache. + This module can remember previous checkbox states(even after they are + removed) so that you can simply toggle them without needing to manually + change the state. + + - Interactive mode. + Allows changing checkbox state(on the current line) via `hjkl` + interactively. + + - Fine grained checkbox toggle. + Allows toggling checkboxes in various ways such as, + + + disable, only removes the state(e.g. `+ [X] Text โ†’ + [ ] Text`). + + checkbox, removes the checkbox itself(e.g. `+ [X] Text โ†’ + Text`). + + list_item, removes the list item too(e.g. `+ [X] Text โ†’ Text`). + + - Better visual checkbox toggle. + Allows toggling checkboxes based on list item markers & lines. + +๐Ÿ“š Usage ~ + +Load the module first, +>lua + require("markview.extras.checkboxes").setup({ + --- Default checkbox state(used when adding checkboxes). + ---@type string + default = "X", + + --- Changes how checkboxes are removed. + ---@type + ---| "disable" Disables the checkbox. + ---| "checkbox" Removes the checkbox. + ---| "list_item" Removes the list item markers too. + remove_style = "disable", + + --- Various checkbox states. + --- + --- States are in sets to quickly change between them + --- when there are a lot of states. + ---@type string[][] + states = { + { " ", "/", "X" }, + { "<", ">" }, + { "?", "!", "*" }, + { '"' }, + { "l", "b", "i" }, + { "S", "I" }, + { "p", "c" }, + { "f", "k", "w" }, + { "u", "d" } + } + }); +< +You should now have access to the `:Checkbox` command. It has the following +sub-commands, + + - `toggle` + Toggles checkbox state. Supports visual mode too! + + - `change` + Changes the state of the checkbox. + Parameters, + + `x`, offset in the X-axis. + + `y`, offset in the Y-axis. + +>txt + + If the current state is [/], you can visualise + the states on the X & Y axis like so. + + โ†‘ { [u], [d] }, + โ† O โ†’ X { [ ], [/], [X] }, + โ†“ { [<], [>] } + Y + + If you did `:Checkbox change -1 -1` you will get [u] + as the items support negative index. +< + - `Interactive` + Open up the Interactive checkbox state changer. + You can move between states in the current set via `h`, `l`. + You can also switch between sets via `j`, `k`. + +------------------------------------------------------------------------------ +๐Ÿ”– Headings *markview.nvim-extra.headings* + +๐Ÿ“œ Overview ~ + +A tree-sitter based heading level changer. + +โ–‹ ๐Ÿ“œ Note +โ–‹ As this is `tree-sitter` based it doesn't support `visual mode`. + +๐Ÿ“š Usage ~ +>lua + require("markview.extras.headings").setup(); +< +You will get access to the `:Headings` command. It has the following sub-commands, + + - `increase` + Increases heading level by 1. + + - `decrease` + Decreases heading level by 1. + +------------------------------------------------------------------------------ +๐Ÿ’ป Editor *markview.nvim-extra.editor* + +๐Ÿ“œ Overview ~ + +A simple `syntax-aware` code block editor/creator. + +๐Ÿ“š Usage ~ +>lua + require("markview.extras.editor").setup(); +< +You will get access to the `:Code` command. It has the following sub-commands, + + - `create` + Create a code block under the cursor. + + - `edit` + Edits the code block under the cursor. + +vim:ft=help:tw=78:colorcolumn=78: diff --git a/doc/home.txt b/doc/home.txt new file mode 100644 index 0000000..79453ef --- /dev/null +++ b/doc/home.txt @@ -0,0 +1,467 @@ + *markview.nvim* A hackable previewer for Neovim + + A hackable `markdown`, HTML, LaTeX, `Typst` & {YAML} previewer + for Neovim. + +โ–‹ ๐Ÿ“œ Note +โ–‹ This wiki assumes you have basic understanding of `LuaCATS` annotations. +โ–‹ If you donโ€™t, check out (this section)ยน. + +------------------------------------------------------------------------------ +โš ๏ธ Important *markview.nvim-wiki-guide* + +Make sure you read this to understand how the type definitions in the wiki +are written. + +>lua + -- โ”Œ Main option name + -- [ Markdown | Block quotes ] -------------------------------------------------------------- + -- โ”” Sub option name + + --- This is the type used in the configuration table. + ---@class markdown.block_quotes + --- + ---@field enable boolean A normal option. + --- + --- A dynamic option that can have a function as value. It receives these parameters, + --- buffer: Buffer number + --- item: the item that will is being rendered. + --- It returns a `string`. + ---@field default block_quotes.opts | fun(buf: integer, item: __markdown.block_quotes): block_quotes.opts + + -- [ Markdown | Block quotes โ€ข Static ] ----------------------------------------------------- + -- โ•พโ”€โ”€โ”€โ”€โ•ด This is the resulting configuration + -- table that will be used by the plugin + + -- โ•พโ”€โ”€โ”€โ”€โ•ด Static configuration clasess end with `static` + ---@class markdown.block_quotes.static + --- + ---@field enable boolean Option description. + ---@field default block_quotes.opts Another option description. + + -- Type definition for any + -- โ•พโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ด options that are inside `block_quotes`. + -- [ Markdown | Block quotes > Type definitions ] ------------------------------------------- + + ---@class block_quotes.opts + --- + ---@field border string | fun(buffer: integer, item: __markdown.block_quotes): string + ---@field border_hl string? | fun(buffer: integer, item: __markdown.block_quotes): string? + + -- โ•พโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ด Definitions for the parameters. + -- [ Markdown | Block quotes > Parameters ] ------------------------------------------------- + + ---@class __markdown.block_quotes + --- + ---@field class "markdown_block_quote" + --- + ---@field text string[] + ---@field range nrde.range +< +------------------------------------------------------------------------------ +๐Ÿ“š Wiki files *markview.nvim-toc* + + ๐Ÿ”„ Migration guide .............................. |markview.nvim-migration| + ๐Ÿ’ป Developer docs ..................................... |markview.nvim-dev| + + ๐ŸŒŸ Custom renderers ............................. |markview.nvim-renderers| + + ๐Ÿ”ญ Preview options ................................ |markview.nvim-preview| + ๐Ÿšจ Experimental options ...................... |markview.nvim-experimental| + + ๐Ÿงพ Markdown options .............................. |markview.nvim-markdown| + ๐ŸŒ HTML options ...................................... |markview.nvim-html| + ๐Ÿ”– Inline markdown options ......................... |markview.nvim-inline| + ๐Ÿ”ข LaTeX option ..................................... |markview.nvim-latex| + ๐Ÿ“‘ Typst options..................................... |markview.nvim-typst| + ๐Ÿ”ฉ YAML options ...................................... |markview.nvim-yaml| + + ๐Ÿงฉ Presets ........................................ |markview.nvim-presets| + ๐ŸŽ Extra modules .................................... |markview.nvim-extra| + ๐Ÿ”ฅ Advanced usage ................................ |markview.nvim-advanced| + +------------------------------------------------------------------------------ +๐Ÿงญ Configuration *markview.nvim-config* + +A simplified configuration is given below, + +>lua + --- Configuration table for `markview.nvim`. + ---@class mkv.config + --- + ---@field experimental config.experimental | fun(): config.experimental + ---@field highlight_groups { [string]: config.hl } | fun(): { [string]: config.hl } + ---@field html config.html | fun(): config.html + ---@field latex config.latex | fun(): config.latex + ---@field markdown config.markdown | fun(): config.markdown + ---@field markdown_inline config.markdown_inline | fun(): config.markdown_inline + ---@field preview config.preview | fun(): config.preview + ---@field renderers config.renderer[] | fun(): config.renderer[] + ---@field typst config.typst | fun(): config.typst + ---@field yaml config.yaml | fun(): config.yaml + mkv.config = { + experimental = { + date_formats = {}, + date_time_formats = {}, + + text_filetypes = {}, + read_chunk_size = 1000, + link_open_alerts = false, + file_open_command = "tabnew", + + list_empty_line_tolerance = 3 + }, + highlight_groups = {}, + preview = { + enable = true, + filetypes = { "md", "rmd", "quarto" }, + ignore_buftypes = { "nofile" }, + ignore_previews = {}, + + modes = { "n", "no", "c" }, + hybrid_modes = {}, + debounce = 50, + draw_range = { vim.o.lines, vim.o.lines }, + edit_range = { 1, 0 }, + + callbacks = {}, + + splitview_winopts = { split = "left" } + }, + renderers = {}, + + html = { + enable = true, + + container_elements = {}, + headings = {}, + void_elements = {}, + }, + latex = { + enable = true, + + blocks = {}, + commands = {}, + escapes = {}, + fonts = {}, + inlines = {}, + parenthesis = {}, + subscripts = {}, + superscripts = {}, + symbols = {}, + texts = {} + }, + markdown = { + enable = true, + + block_quotes = {}, + code_blocks = {}, + headings = {}, + horizontal_rules = {}, + list_items = {}, + metadata_plus = {}, + metadata_minus = {}, + tables = {} + }, + markdown_inline = { + enable = true, + + block_references = {}, + checkboxes = {}, + emails = {}, + embed_files = {}, + emoji_shorthands = {}, + entities = {}, + escapes = {}, + footnotes = {}, + highlights = {}, + hyperlinks = {}, + images = {}, + inline_codes = {}, + internal_links = {}, + uri_autolinks = {} + }, + typst = { + enable = true, + + codes = {}, + escapes = {}, + headings = {}, + labels = {}, + list_items = {}, + math_blocks = {}, + math_spans = {}, + raw_blocks = {}, + raw_spans = {}, + reference_links = {}, + subscripts = {}, + superscript = {}, + symbols = {}, + terms = {}, + url_links = {} + }, + yaml = { + enable = true, + + properties = {} + } + } +< +------------------------------------------------------------------------------ +๐ŸŽ‡ Commands *markview.nvim-commands* + +This plugin follows the โŒฉsub-commandsโŒช approach for creating commands. There +is only a single `:Markview` command. + +It comes with the following sub-commands, + +โ–‹ ๐Ÿ“œ Note +โ–‹ When no sub-command name is provided(or an invalid sub-command is used) +โ–‹ `:Markview` will run `:Markview Toggle`. + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ +โ”ƒ Sub-command โ”ƒ Arguments โ”ƒ Description โ”ƒ +โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ +โ”‚ `Start` โ”‚ none โ”‚ Allows attaching to new โ”‚ +โ”‚ โ”‚ โ”‚ buffers. โ”‚ +โ”‚ `Stop` โ”‚ none โ”‚ Prevents attaching to new โ”‚ +โ”‚ โ”‚ โ”‚ buffers. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `attach` โ”‚ `buffer`, integer โ”‚ Attaches to {buffer}. โ”‚ +โ”‚ `detach` โ”‚ `buffer`, integer โ”‚ Detaches from {buffer}. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `Enable` โ”‚ none โ”‚ Enables preview globally. โ”‚ +โ”‚ `Disable` โ”‚ none โ”‚ Disables preview globally. โ”‚ +โ”‚ `Toggle` โ”‚ none โ”‚ Toggles preview globally. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `enable` โ”‚ `buffer`, integer โ”‚ Enables preview for โ”‚ +โ”‚ โ”‚ โ”‚ {buffer}. โ”‚ +โ”‚ `disable` โ”‚ `buffer`, integer โ”‚ Disables preview for โ”‚ +โ”‚ โ”‚ โ”‚ {buffer}. โ”‚ +โ”‚ `toggle` โ”‚ `buffer`, integer โ”‚ Toggles preview for โ”‚ +โ”‚ โ”‚ โ”‚ {buffer}. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `splitOpen` โ”‚ `buffer`, integer โ”‚ Opens `splitview` โ”‚ +โ”‚ โ”‚ โ”‚ for {buffer}. โ”‚ +โ”‚ `splitClose` โ”‚ none โ”‚ Closes any open โ”‚ +โ”‚ โ”‚ โ”‚ `splitview` window. โ”‚ +โ”‚ `splitToggle` โ”‚ none โ”‚ Toggles `splitview`. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `splitRedraw` โ”‚ none โ”‚ Updates `splitview` window.โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `Render` โ”‚ none โ”‚ Updates preview of โ”‚ +โ”‚ โ”‚ โ”‚ all `active` โ”‚ +โ”‚ โ”‚ โ”‚ buffers. โ”‚ +โ”‚ `Clear` โ”‚ none โ”‚ Clears preview of โ”‚ +โ”‚ โ”‚ โ”‚ all `active` buffer. โ”‚ +โ”‚ `render` โ”‚ `buffer`, integer โ”‚ Renders preview for โ”‚ +โ”‚ โ”‚ โ”‚ `buffer`. โ”‚ +โ”‚ `clear` โ”‚ `buffer`, integer โ”‚ Clears preview for โ”‚ +โ”‚ โ”‚ โ”‚ `buffer`. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `toggleAll` โ”‚ none โ”‚ `Deprecated` version โ”‚ +โ”‚ โ”‚ โ”‚ of `Toggle`. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `enableAll` โ”‚ none โ”‚ `Deprecated` version โ”‚ +โ”‚ โ”‚ โ”‚ of `Enable`. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `disableAll` โ”‚ none โ”‚ `Deprecated` version โ”‚ +โ”‚ โ”‚ โ”‚ of `Disable`. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `traceExport` โ”‚ none โ”‚ Exports trace logs โ”‚ +โ”‚ โ”‚ โ”‚ to `trace.txt`. โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ `traceShow` โ”‚ none โ”‚ Shows trace logs in โ”‚ +โ”‚ โ”‚ โ”‚ a window. โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + +โ–‹ ๐Ÿ’ก Tip: +โ–‹ {buffer} defaults to the current buffer. So, you can run commands on the +โ–‹ current buffer without providing the buffer. +โ–˜ >vim + :Markview toggle "Toggles preview of the current buffer. +< +------------------------------------------------------------------------------ +๐Ÿ“ž Autocmds *markview.nvim-autocmds* + +`markview.nvim` emits various โŒฉautocmd eventsโŒช during different parts of the +rendering allowing users to extend the pluginโ€™s functionality. + +>lua + vim.api.nvim_create_autocmd("User", { + pattern = "MarkviewAttach", + callback = function (event) + --- This will have all the data you need. + local data = event.data; + + vim.print(data); + end + }) +< +โ–‹๐Ÿ“œ Note: +โ–‹ Autocmds are executed `after` callbacks! + +Currently emitted autocmds are, + + โ€ข `MarkviewAttach` + Called when attaching to a buffer. + + Arguments, + + โ€ข `buffer`, integer + The buffer thatโ€™s being attached to. + + โ€ข `windows`, integer[] + List of windows attached to `buffer`. + + โ€ข `MarkviewDetach` + Called when detaching from a buffer. + + Arguments, + + โ€ข `buffer`, integer + The buffer thatโ€™s being detached from. + + โ€ข `windows`, integer[] + List of windows attached to `buffer`. + + โ€ข `MarkviewDisable` + Called when disabling previews in a buffer. + + Arguments, + + โ€ข `buffer`, integer + The buffer whose the preview was disabled. + + โ€ข `windows`, integer[] + List of windows attached to `buffer`. + + โ€ข `MarkviewEnable` + Called when enabling previews in a buffer. + + Arguments, + + โ€ข `buffer`, integer + The buffer whose the preview was enabled. + + โ€ข `windows`, integer[] + List of windows attached to `buffer`. + + โ€ข `MarkviewSplitviewClose` + Called when the splitview window is closed. Called before splitview + is closed. + + Arguments, + + โ€ข `source`, integer + The buffer whose contents are being shown. + + โ€ข `preview_buffer`, integer + The buffer thatโ€™s showing the preview. + + โ€ข `preview_window`, integer + The window where the `preview_buffer` is being shown. + + โ€ข `MarkviewSplitviewOpen` + Called when the splitview window is opened. + + Arguments, + + โ€ข `source`, integer + The buffer whose contents are being shown. + + โ€ข `preview_buffer`, integer + The buffer thatโ€™s showing the preview. + + โ€ข `preview_window`, integer + The window where the `preview_buffer` is being shown. + +------------------------------------------------------------------------------ +๐ŸŽจ Highlight groups *markview.nvim-hl* + +`markview.nvim` creates a number of *primary highlight groups* that are used +by most of the decorations. + +โ–‹ ๐Ÿšจ Important +โ–‹ These groups are all generated during runtime and as such their color +โ–‹ may look different. + +If you want to create your own [dynamic] highlight groups or modify existing +ones, see the `LNK[custom highlight groups](placeholder)` section. + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ +โ”ƒ Highlight group โ”ƒ value โ”ƒ +โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ +โ”‚ MarkviewBlockQuoteDefault โ”‚ link: `MarkviewPalette0Fg` โ”‚ +โ”‚ MarkviewBlockQuoteError โ”‚ link: `MarkviewPalette1Fg` โ”‚ +โ”‚ MarkviewBlockQuoteNote โ”‚ link: `MarkviewPalette5Fg` โ”‚ +โ”‚ MarkviewBlockQuoteOk โ”‚ link: `MarkviewPalette4Fg` โ”‚ +โ”‚ MarkviewBlockQuoteSpecial โ”‚ link: `MarkviewPalette3Fg` โ”‚ +โ”‚ MarkviewBlockQuoteWarn โ”‚ link: `MarkviewPalette2Fg` โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewCheckboxCancelled โ”‚ link: `MarkviewPalette0Fg` โ”‚ +โ”‚ MarkviewCheckboxChecked โ”‚ link: `MarkviewPalette4Fg` โ”‚ +โ”‚ MarkviewCheckboxPending โ”‚ link: `MarkviewPalette2Fg` โ”‚ +โ”‚ MarkviewCheckboxProgress โ”‚ link: `MarkviewPalette6Fg` โ”‚ +โ”‚ MarkviewCheckboxUncheked โ”‚ link: `MarkviewPalette1Fg` โ”‚ +โ”‚ MarkviewCheckboxStriked โ”‚ link\*: `MarkviewPalette0Fg` โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewCode โ”‚ bg\*\*: `normal` ยฑ 5%(L) โ”‚ +โ”‚ MarkviewCodeInfo โ”‚ bg\*\*: `normal` ยฑ 5%(L), fg: `comment` โ”‚ +โ”‚ MarkviewCodeFg โ”‚ fg\*\*: `normal` ยฑ 5%(L) โ”‚ +โ”‚ MarkviewInlineCode โ”‚ fg\*\*: `normal` ยฑ 10%(L) โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewIcon0 โ”‚ link\*\*\*: `MarkviewPalette0Fg` โ”‚ +โ”‚ MarkviewIcon1 โ”‚ link\*\*\*: `MarkviewPalette1Fg` โ”‚ +โ”‚ MarkviewIcon2 โ”‚ link\*\*\*: `MarkviewPalette5Fg` โ”‚ +โ”‚ MarkviewIcon3 โ”‚ link\*\*\*: `MarkviewPalette4Fg` โ”‚ +โ”‚ MarkviewIcon4 โ”‚ link\*\*\*: `MarkviewPalette3Fg` โ”‚ +โ”‚ MarkviewIcon5 โ”‚ link\*\*\*: `MarkviewPalette2Fg` โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewGradient0 โ”‚ fg: `Normal` โ”‚ +โ”‚ MarkviewGradient1 โ”‚ fg\*\*\*\*: `lerp(Normal, Title, 1/9)` โ”‚ +โ”‚ MarkviewGradient2 โ”‚ fg\*\*\*\*: `lerp(Normal, Title, 2/9)` โ”‚ +โ”‚ MarkviewGradient3 โ”‚ fg\*\*\*\*: `lerp(Normal, Title, 3/9)` โ”‚ +โ”‚ MarkviewGradient4 โ”‚ fg\*\*\*\*: `lerp(Normal, Title, 4/9)` โ”‚ +โ”‚ MarkviewGradient5 โ”‚ fg\*\*\*\*: `lerp(Normal, Title, 5/9)` โ”‚ +โ”‚ MarkviewGradient6 โ”‚ fg\*\*\*\*: `lerp(Normal, Title, 6/9)` โ”‚ +โ”‚ MarkviewGradient7 โ”‚ fg\*\*\*\*: `lerp(Normal, Title, 7/9)` โ”‚ +โ”‚ MarkviewGradient8 โ”‚ fg\*\*\*\*: `lerp(Normal, Title, 8/9)` โ”‚ +โ”‚ MarkviewGradient9 โ”‚ fg: `Title` โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewHeading1 โ”‚ link: `MarkviewPalette1` โ”‚ +โ”‚ MarkviewHeading2 โ”‚ link: `MarkviewPalette2` โ”‚ +โ”‚ MarkviewHeading3 โ”‚ link: `MarkviewPalette3` โ”‚ +โ”‚ MarkviewHeading4 โ”‚ link: `MarkviewPalette4` โ”‚ +โ”‚ MarkviewHeading5 โ”‚ link: `MarkviewPalette5` โ”‚ +โ”‚ MarkviewHeading6 โ”‚ link: `MarkviewPalette6` โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewEmail โ”‚ link: `@markup.link.url.markdown_inline` โ”‚ +โ”‚ MarkviewHyperlink โ”‚ link: `@markup.link.label.markdown_inline` โ”‚ +โ”‚ MarkviewImage โ”‚ link: `@markup.link.label.markdown_inline` โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewSubscript โ”‚ link: `MarkviewPalette3Fg` โ”‚ +โ”‚ MarkviewSuperscript โ”‚ link: `MarkviewPalette6Fg` โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewListItemMinus โ”‚ link: `MarkviewPalette2Fg` โ”‚ +โ”‚ MarkviewListItemPlus โ”‚ link: `MarkviewPalette4Fg` โ”‚ +โ”‚ MarkviewListItemStar โ”‚ link: `MarkviewPalette6Fg` โ”‚ +โ”œโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ผโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ”ค +โ”‚ MarkviewTableHeader โ”‚ link: `@markup.heading.markdown` โ”‚ +โ”‚ MarkviewTableBorder โ”‚ link: `MarkviewPalette5Fg` โ”‚ +โ”‚ MarkviewTableAlignCenter โ”‚ link: `MarkviewPalette5Fg` โ”‚ +โ”‚ MarkviewTableAlignLeft โ”‚ link: `MarkviewPalette5Fg` โ”‚ +โ”‚ MarkviewTableAlignRight โ”‚ link: `MarkviewPalette5Fg` โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + +โ–‹ * = Only the foreground color is used. Strikeout is added. +โ–‹ +โ–‹ ** = The color is converted to HSL and it's luminosity(L) is increased/ +โ–‹ decreased by the specified amount. +โ–‹ +โ–‹ *** = The background color of `MarkviewCode` is added to the groups. +โ–‹ +โ–‹ **** = Linearly interpolated value between 2 highlight groups `fg`. + +-------------------------------------------------------------------------- +vim:ft=help:tw=78: diff --git a/doc/html_options.txt b/doc/html_options.txt new file mode 100644 index 0000000..2f164d5 --- /dev/null +++ b/doc/html_options.txt @@ -0,0 +1,371 @@ +*markview.nvim-html* HTML preview options for markview + + Options that affect how HTML is shown in preview. +>lua + -- [ Markview | HTML ] -------------------------------------------------------------------- + + --- Configuration table for HTML preview. + ---@class config.html + --- + ---@field enable boolean + --- + ---@field container_elements html.container_elements | fun(): html.container_elements + ---@field headings html.headings | fun(): html.headings + ---@field void_elements html.void_elements | fun(): html.void_elements + html = { + enable = true, + + container_elements = {}, + headings = {}, + void_elements = {} + }; + + -- [ Markview | HTML โ€ข Static ] ----------------------------------------------------------- + + --- Static configuration table for HTML preview. + ---@class config.html_static + --- + ---@field enable boolean + --- + --- Configuration for container elements. + ---@field container_elements html.container_elements + --- Configuration for headings(e.g. `

`). + ---@field headings html.headings + --- Configuration for void elements. + ---@field void_elements html.void_elements +< + + *markview.nvim-html.container_elements* +container_elements ~ + + - Type: `html.container_elements` + - Dynamic: true + +Configuration table for container type elements. + +โ–‹ ๐Ÿ“œ Note: +โ–‹ Tags such as `` aren't detected by this as they use a different node. + +>lua + -- [ HTML | Container elements ] ---------------------------------------------------------- + + --- HTML element config. + ---@class html.container_elements + --- + ---@field enable boolean + ---@field [string] container_elements.opts | fun(buffer: integer, item: __html.container_elements): container_elements.opts + container_elements = { + enable = true, + + ["^b$"] = { + on_opening_tag = { conceal = "" }, + on_node = { hl_group = "Bold" }, + on_closing_tag = { conceal = "" }, + }, + ["^code$"] = { + on_opening_tag = { conceal = "", hl_mode = "combine", virt_text_pos = "inline", virt_text = { { " ", "MarkviewInlineCode" } } }, + on_node = { hl_group = "MarkviewInlineCode" }, + on_closing_tag = { conceal = "", hl_mode = "combine", virt_text_pos = "inline", virt_text = { { " ", "MarkviewInlineCode" } } }, + }, + ["^em$"] = { + on_opening_tag = { conceal = "" }, + on_node = { hl_group = "@text.emphasis" }, + on_closing_tag = { conceal = "" }, + }, + ["^i$"] = { + on_opening_tag = { conceal = "" }, + on_node = { hl_group = "Italic" }, + on_closing_tag = { conceal = "" }, + }, + ["^mark$"] = { + on_opening_tag = { conceal = "" }, + on_node = { hl_group = "MarkviewPalette1" }, + on_closing_tag = { conceal = "" }, + }, + ["^strong$"] = { + on_opening_tag = { conceal = "" }, + on_node = { hl_group = "@text.strong" }, + on_closing_tag = { conceal = "" }, + }, + ["^sub$"] = { + on_opening_tag = { conceal = "", hl_mode = "combine", virt_text_pos = "inline", virt_text = { { "โ†“[", "MarkviewSubscript" } } }, + on_node = { hl_group = "MarkviewSubscript" }, + on_closing_tag = { conceal = "", hl_mode = "combine", virt_text_pos = "inline", virt_text = { { "]", "MarkviewSubscript" } } }, + }, + ["^sup$"] = { + on_opening_tag = { conceal = "", hl_mode = "combine", virt_text_pos = "inline", virt_text = { { "โ†‘[", "MarkviewSuperscript" } } }, + on_node = { hl_group = "MarkviewSuperscript" }, + on_closing_tag = { conceal = "", hl_mode = "combine", virt_text_pos = "inline", virt_text = { { "]", "MarkviewSuperscript" } } }, + }, + ["^u$"] = { + on_opening_tag = { conceal = "" }, + on_node = { hl_group = "Underlined" }, + on_closing_tag = { conceal = "" }, + }, + }; + + -- [ HTML | Container elements โ€ข Static ] ---------------------------------------------------------- + + --- Static configuration for container elements. + ---@class html.container_elements_static + --- + ---@field enable boolean Enables container element rendering. + ---@field [string] container_elements.opts Configuration for . +< +>lua + --- Configuration table for a specific container element. + ---@class container_elements.opts + --- + ---@field closing_tag_offset? fun(range: integer[]): integer[] Modifies the closing 's range(`{ row_start, col_start, row_end, col_end }`). + ---@field node_offset? fun(range: integer[]): integer[] Modifies the element's range(`{ row_start, col_start, row_end, col_end }`). + ---@field opening_tag_offset? fun(range: integer[]): integer[] Modifies the opening 's range(`{ row_start, col_start, row_end, col_end }`). + --- + ---@field on_closing_tag? config.extmark | fun(tag: __container.data): config.extmark Extmark configuration to use on the closing . + ---@field on_node? config.extmark | fun(item: __html.container_elements): config.extmark Extmark configuration to use on the element. + ---@field on_opening_tag? config.extmark | fun(tag: __container.data): config.extmark Extmark configuration to use on the opening . + ["^b$"] = { + on_opening_tag = { conceal = "" }, + on_node = { hl_group = "Bold" }, + on_closing_tag = { conceal = "" }, + }; + + -- [ HTML | Container elements > Parameters ] --------------------------------------------- + + --- Parsed version of an HTML container element. + ---@class __html.container_elements + --- + ---@field class "html_container_element" + --- + ---@field opening_tag __container.data Table containing information regarding the opening tag. + ---@field closing_tag __container.data Table containing information regarding the closing tag. + --- + ---@field name string Tag name(in lowercase). + --- + ---@field text string[] Text of this node. + ---@field range node.range Range of this node. + M.__html_container_elements = { + class = "html_container_element", + name = "p", + text = { + "

", + "text

" + }, + + opening_tag = { + text = "

", + range = { 0, 0, 0, 3 } + }, + closing_tag = { + text = "

", + range = { 1, 5, 1, 8 } + }, + + range = { + row_start = 0, + row_end = 1, + col_start = 0, + col_end = 8 + } + }; + + --- Container element segment data. + ---@class __container.data + --- + ---@field text string Text inside this segment. + ---@field range integer[] Range of this segment(Result of `{ TSNode:range() }`). + M.__conteiner_segment_opts = { + text = "

", + range = { 0, 0, 0, 3 } + }; +< + *markview.nvim-html.headings* +headings ~ + + - Type: `html.headings` + - Dynamic: true + +Configuration for HTML headings(e.g. `

`). + +โ–‹ ๐Ÿ“œ Note: +โ–‹ This option exists for *parity reasons*. + +>lua + -- [ HTML | Headings ] -------------------------------------------------------------------- + + --- HTML heading config. + ---@class html.headings + --- + ---@field enable boolean Enables heading rendering. + ---@field [string] config.extmark Configuration for . + M.html_headings = { + enable = true, + + heading_1 = { + hl_group = "MarkviewPalette1Bg" + }, + heading_2 = { + hl_group = "MarkviewPalette2Bg" + }, + heading_3 = { + hl_group = "MarkviewPalette3Bg" + }, + heading_4 = { + hl_group = "MarkviewPalette4Bg" + }, + heading_5 = { + hl_group = "MarkviewPalette5Bg" + }, + heading_6 = { + hl_group = "MarkviewPalette6Bg" + }, + }; +< +>lua + -- [ HTML | Headings > Type definitions ] ------------------------------------------------- + + --- HTML heading config. + ---@class html.headings + --- + ---@field enable boolean Enables heading rendering. + ---@field [string] config.extmark | fun(buffer: integer, item: __html.headings): config.extmark Configuration for . + heading_1 = function (buffer, item) + --- These options are automatically + --- applied to the range of the node. + return { + hl_group = "MarkviewPalette5Fg" + }; + end + + -- [ HTML | Headings > Parameters ] -------------------------------------------------------- + + ---@class __html.headings + --- + ---@field class "html_heading" + ---@field level integer Heading level. + ---@field range node.range + ---@field text string[] + M.__html_headings = { + class = "html_heading", + level = 1, + + text = { + "

", + "heading text", + "

" + }, + range = { + row_start = 0, + col_start = 0, + row_end = 2, + col_end = 5 + } + }; +< + *markview.nvim-html.void_elements* +void_elements ~ + + - Type: `html.void_elements` + - Dynamic: true + +Configuration for void type elements. + +โ–‹ ๐Ÿ“œ Note: +โ–‹ Lines containing *only tags* may not be recognized(this is a `tree-sitter` +โ–‹ bug). + +>lua + -- [ HTML | Void elements ] --------------------------------------------------------------- + + --- HTML element config. + ---@class html.void_elements + --- + ---@field enable boolean + ---@field [string] void_elements.opts | fun(buffer: integer, item: __html.void_elements): void_elements.opts + void_elements = { + enable = true, + + ["^hr$"] = { + on_node = { + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { "โ”€", "MarkviewGradient2" }, + { "โ”€", "MarkviewGradient3" }, + { "โ”€", "MarkviewGradient4" }, + { "โ”€", "MarkviewGradient5" }, + { " โ—‰ ", "MarkviewGradient9" }, + { "โ”€", "MarkviewGradient5" }, + { "โ”€", "MarkviewGradient4" }, + { "โ”€", "MarkviewGradient3" }, + { "โ”€", "MarkviewGradient2" }, + } + } + }, + ["^br$"] = { + on_node = { + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { "๓ฑžฆ", "Comment" }, + } + } + }, + }; + + -- [ HTML | Void elements โ€ข Static ] ------------------------------------------------------ + + --- Static configuration for void elements.. + ---@class html.void_elements + --- + ---@field enable boolean Enables void element rendering. + ---@field [string] void_elements.opts Configuration for . +< +>lua + --- Configuration table for a specific void element. + ---@class void_elements.opts + --- + ---@field node_offset? fun(range: integer[]): table Modifies the element's range(`{ row_start, col_start, row_end, col_end }`). + ---@field on_node config.extmark | fun(tag: table): config.extmark Extmark configuration to use on the element. + ["^img$"] = { + on_node = function (item) + local joined = table.concat(item.text, ""); + local src = string.match(joined, [[src%s*=%s*[%'%"]([^%'%"]+)]]) or ""; + + --- Replaces image tags with an icon & the `src` link. + return { + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { string.format("๓ฐ‹ฉ %s", src), "@tag.html" } + } + }; + end + }; + + -- [ HTML | Void elements > Parameters ] -------------------------------------------------- + + ---@class __html.void_elements + --- + ---@field class "html_void_element" + ---@field name string + ---@field text string[] + ---@field range node.range + M.__html_void_elements = { + class = "html_void_element", + name = "img", + text = { + "" + }, + range = { + row_start = 0, + row_end = 0, + col_start = 0, + col_end = 27 + } + }; +< +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/latex_options.txt b/doc/latex_options.txt new file mode 100644 index 0000000..bd4f445 --- /dev/null +++ b/doc/latex_options.txt @@ -0,0 +1,954 @@ +*markview.nvim-latex* LaTeX preview options for markview. + + Options that affect how LaTeX is shown in preview. +>lua + -- [ Markview | LaTeX ] ------------------------------------------------------------------- + + --- Configuration for LaTeX. + ---@class config.latex + --- + ---@field enable boolean + --- + ---@field blocks? latex.blocks | fun(): latex.blocks + ---@field commands? latex.commands | fun(): latex.commands + ---@field escapes? latex.escapes | fun(): latex.escapes + ---@field fonts? latex.fonts | fun(): latex.fonts + ---@field inlines? latex.inlines | fun(): latex.inlines + ---@field parenthesis? latex.parenthesis | fun(): latex.parenthesis + ---@field subscripts? latex.subscripts | fun(): latex.subscripts + ---@field superscripts? latex.superscripts | fun(): latex.superscripts + ---@field symbols? latex.symbols | fun(): latex.symbols + ---@field texts? latex.texts | fun(): latex.texts + M.latex = { + enable = true, + + commands = {}, + texts = {}, + symbols = {}, + subscripts = {}, + superscripts = {}, + parenthesis = {}, + escapes = {}, + inlines = {}, + blocks = {}, + fonts = {} + }; + + -- [ Markview | LaTeX โ€ข Static ] ---------------------------------------------------------- + + --- Static configuration for LaTeX. + ---@class config.latex_static + --- + ---@field enable boolean + --- + --- LaTeX blocks configuration(typically made with `$$...$$`). + ---@field blocks? latex.blocks + --- LaTeX commands configuration(e.g. `\frac{x}{y}`). + ---@field commands? latex.commands + --- LaTeX escaped characters configuration. + ---@field escapes? latex.escapes + --- LaTeX fonts configuration(e.g. `\mathtt{}`). + ---@field fonts? latex.fonts + --- Inline LaTeX configuration(typically made with `$...$`). + ---@field inlines? latex.inlines + --- Configuration for hiding `{}`. + ---@field parenthesis? latex.parenthesis + --- LaTeX subscript configuration(`_{}`, `_x`). + ---@field subscripts? latex.subscripts + --- LaTeX superscript configuration(`^{}`, `^x`). + ---@field superscripts? latex.superscripts + --- TeX math symbols configuration(e.g. `\alpha`). + ---@field symbols? latex.symbols + --- Text block configuration(`\text{}`). + ---@field texts? latex.texts +< + *markview.nvim-latex.blocks* +blocks ~ + + - Type: `latex.blocks` + - Dynamic: true + +Configuration for LaTeX blocks. +>lua + -- [ LaTeX | LaTeX blocks ] --------------------------------------------------------------- + + --- Configuration table for latex math blocks. + ---@class latex.blocks + --- + ---@field enable boolean + --- + ---@field hl? string | fun(buffer: integer, item: __latex.blocks): string? + ---@field pad_amount integer | fun(buffer: integer, item: __latex.blocks): integer + ---@field pad_char string | fun(buffer: integer, item: __latex.blocks): string + --- + ---@field text string | fun(buffer: integer, item: __latex.blocks): string + ---@field text_hl? string | fun(buffer: integer, item: __latex.blocks): string? + blocks = { + enable = true, + + hl = "MarkviewCode", + pad_char = " ", + pad_amount = 3, + + text = " ๎ญค LaTeX ", + text_hl = "MarkviewCodeInfo" + }; + + -- [ LaTeX | LaTeX blocks โ€ข Static ] ------------------------------------------------------ + + --- Configuration table for latex math blocks. + ---@class latex.blocks_static + --- + ---@field enable boolean Enables rendering of LaTeX blocks. + --- + ---@field hl? string Primary highlight group for the LaTeX block. + ---@field pad_amount integer Number of `pad_char` to add before & after the text. + ---@field pad_char string Character to use for padding. + --- + ---@field text string Text to show on the top left. + ---@field text_hl? string Highlight group for the `text`. +< +>lua + -- [ LaTeX | LaTeX blocks > Parameters ] -------------------------------------------------- + + --- Parsed version of a LaTeX block. + ---@class __latex.blocks + --- + ---@field class "latex_block" + ---@field marker string + --- + ---@field text string[] + ---@field range node.range + M.__latex_blocks = { + class = "latex_block", + marker = "$" + + text = { "$$1 + 2 = 3$$" }, + range = { + row_start = 0, + row_end = 0, + col_start = 0, + col_end = 13 + } + }; + + --- [ Advanced Usage ] --------------------------------------------------------------------- + + --- Colors math blocks differently based on + --- if their start row is even or odd. + blocks = { + hl = function (_, item) + local range = item.range; + + if range.row_start % 2 == 0 then + return "MarkviewCode"; + else + return "MarkviewPalette1Bg" + end + end + }; +< + *markview.nvim-latex.commands* +commands ~ + + - Type: `latex.commands` + - Dynamic: true + +Configuration for LaTeX commands. +>lua + -- [ LaTeX | LaTeX commands ] ------------------------------------------------------------- + + --- Configuration for LaTeX commands. + ---@class latex.commands + --- + ---@field enable boolean + ---@field [string] commands.opts | fun(buffer: integer, item: __latex.commands): commands.opts + commands = { + ---+${lua} + + enable = true, + + ---+${lua, Various commonly used LaTeX math commands} + + ["frac"] = { + condition = function (item) + return #item.args == 2; + end, + on_command = { + conceal = "" + }, + + on_args = { + { + on_before = function (item) + return { + end_col = item.range[2] + 1, + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { "(", "@punctuation.bracket" } + }, + + hl_mode = "combine" + } + end, + + after_offset = function (range) + return { range[1], range[2], range[3], range[4] - 1 }; + end, + on_after = function (item) + return { + end_col = item.range[4], + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { ")", "@punctuation.bracket" }, + { " รท ", "@keyword.function" } + }, + + hl_mode = "combine" + } + end + }, + { + on_before = function (item) + return { + end_col = item.range[2] + 1, + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { "(", "@punctuation.bracket" } + }, + + hl_mode = "combine" + } + end, + + after_offset = function (range) + return { range[1], range[2], range[3], range[4] - 1 }; + end, + on_after = function (item) + return { + end_col = item.range[4], + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { ")", "@punctuation.bracket" }, + }, + + hl_mode = "combine" + } + end + }, + } + }, + + ["sin"] = operator("sin"), + ["cos"] = operator("cos"), + ["tan"] = operator("tan"), + + ["sinh"] = operator("sinh"), + ["cosh"] = operator("cosh"), + ["tanh"] = operator("tanh"), + + ["csc"] = operator("csc"), + ["sec"] = operator("sec"), + ["cot"] = operator("cot"), + + ["csch"] = operator("csch"), + ["sech"] = operator("sech"), + ["coth"] = operator("coth"), + + ["arcsin"] = operator("arcsin"), + ["arccos"] = operator("arccos"), + ["arctan"] = operator("arctan"), + + ["arg"] = operator("arg"), + ["deg"] = operator("deg"), + ["det"] = operator("det"), + ["dim"] = operator("dim"), + ["exp"] = operator("exp"), + ["gcd"] = operator("gcd"), + ["hom"] = operator("hom"), + ["inf"] = operator("inf"), + ["ker"] = operator("ker"), + ["lg"] = operator("lg"), + + ["lim"] = operator("lim"), + ["liminf"] = operator("lim inf", "inline", 7), + ["limsup"] = operator("lim sup", "inline", 7), + + ["ln"] = operator("ln"), + ["log"] = operator("log"), + ["min"] = operator("min"), + ["max"] = operator("max"), + ["Pr"] = operator("Pr"), + ["sup"] = operator("sup"), + ["sqrt"] = operator(symbols.entries.sqrt, "inline", 5), + ["lvert"] = operator(symbols.entries.vert, "inline", 6), + ["lVert"] = operator(symbols.entries.Vert, "inline", 6), + + ---_ + + ---_ + }; + + -- [ LaTeX | LaTeX commands โ€ข Static ] ---------------------------------------------------- + + --- Static configuration for LaTeX commands. + ---@class latex.commands_static + --- + ---@field enable boolean Enables latex command preview. + ---@field [string] commands.opts Configuration table for {string}. + + --- [ Helper functions ] ------------------------------------------------------------------- + + --- Creates a configuration table for a LaTeX command. + ---@param name string Command name(Text to show). + ---@param text_pos? "overlay" | "inline" `virt_text_pos` extmark options. + ---@param cmd_conceal? integer Characters to conceal. + ---@param cmd_hl? string Highlight group for the command. + ---@return commands.opts + local operator = function (name, text_pos, cmd_conceal, cmd_hl) + ---+${func} + return { + condition = function (item) + return #item.args == 1; + end, + + + on_command = function (item) + return { + end_col = item.range[2] + (cmd_conceal or 1), + conceal = "", + + virt_text_pos = text_pos or "overlay", + virt_text = { + { symbols.tostring("default", name), cmd_hl or "@keyword.function" } + }, + + hl_mode = "combine" + } + end, + + on_args = { + { + on_before = function (item) + return { + end_col = item.range[2] + 1, + + virt_text_pos = "overlay", + virt_text = { + { "(", "@punctuation.bracket" } + }, + + hl_mode = "combine" + } + end, + + after_offset = function (range) + return { range[1], range[2], range[3], range[4] - 1 }; + end, + + on_after = function (item) + return { + end_col = item.range[4], + + virt_text_pos = "overlay", + virt_text = { + { ")", "@punctuation.bracket" } + }, + + hl_mode = "combine" + } + end + } + } + }; + ---_ + end +< +>lua + -- [ LaTeX | LaTeX commands > Type definitions ] ------------------------------------------- + + ---@class commands.opts + --- + ---@field condition? fun(item: __latex.commands): boolean Condition used to determine if a command is valid. + --- + ---@field command_offset? fun(range: integer[]): integer[] Modifies the command's range(`{ row_start, col_start, row_end, col_end }`). + ---@field on_command? config.extmark | fun(tag: table): config.extmark Extmark configuration to use on the command. + ---@field on_args? commands.arg_opts[]? Configuration table for each argument. + M.latex_commands_opts = { + condition = function (item) + --- The item must have 2 arguments. + --- \frac{1}{2} + return #item.args == 2; + end, + + --- Hide the `\frac` part. + on_command = { + conceal = "" + }, + + --- Add decorations to each of the arguments. + --- Note: Making it use `x รท y` should be possible but + --- making this more complicated is not worth the + --- effort(at the moment). + on_args = { + { + --- Replace the `{` with a `(`. + --- An overlay virtual text would have worked too + --- but it has issues with horizontal scrolling. + on_before = function (item) + return { + end_col = item.range[2] + 1, + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { "(", "@punctuation.bracket" } + }, + + hl_mode = "combine" + } + end, + + --- We need to modify the after extmarks range to + --- hide the `}`. + --- {arg1} + --- โ”‚ โ”” Original `range[4]` + -- โ”” New `range[4]` + after_offset = function (range) + return { range[1], range[2], range[3], range[4] - 1 }; + end, + + --- Replace `}` with a `)`. + --- Also add ` รท ` to "fake" the operator. + on_after = function (item) + return { + end_col = item.range[4], + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { ")", "@punctuation.bracket" }, + { " รท ", "@keyword.function" } + }, + + hl_mode = "combine" + } + end + }, + { + on_before = function (item) + return { + end_col = item.range[2] + 1, + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { "(", "@punctuation.bracket" } + }, + + hl_mode = "combine" + } + end, + + after_offset = function (range) + return { range[1], range[2], range[3], range[4] - 1 }; + end, + + on_after = function (item) + return { + end_col = item.range[4], + conceal = "", + + virt_text_pos = "inline", + virt_text = { + { ")", "@punctuation.bracket" }, + }, + + hl_mode = "combine" + } + end + }, + } + }; + + ---@class commands.arg_opts + --- + ---@field after_offset? fun(range: integer[]): integer[] Modifies the range of the argument(only for `on_after`). + ---@field before_offset? fun(range: integer[]): integer[] Modifies the range of the argument(only for `on_before`). + ---@field condition? fun(item: table): boolean Can be used to change when the command preview is shown. + ---@field content_offset? fun(range: integer[]): table Modifies the argument's range(only for `on_content`). + ---@field on_after? config.extmark | fun(tag: table): config.extmark Extmark configuration to use at the end of the argument. + ---@field on_before? config.extmark | fun(tag: table): config.extmark Extmark configuration to use at the start of the argument. + ---@field on_content? config.extmark | fun(tag: table): config.extmark Extmark configuration to use on the argument. + M.latex_commands_arg_opts = { + on_after = { virt_text = { { ")", "Comment" } }, virt_text_pos = "overlay" }, + on_before = { virt_text = { { ")", "Comment" } }, virt_text_pos = "overlay" } + }; + + -- [ LaTeX | LaTeX commands > Parameters ] ------------------------------------------------- + + --- LaTeX commands(must have at least 1 argument). + ---@class __latex.commands + --- + ---@field class "latex_command" + --- + ---@field command { name: string, range: integer[] } Command name(without `\`) and it's range. + ---@field args { text: string, range: integer[] }[] List of arguments(inside `{...}`) with their text & range. + --- + ---@field text string[] + ---@field range node.range + M.__latex_commands = { + class = "latex_command", + + command = { + name = "frac", + range = { 0, 0, 0, 5 } + }, + args = { + { + text = "{1}", + range = { 0, 5, 0, 8 } + }, + { + text = "{2}", + range = { 0, 8, 0, 11 } + } + }, + text = { "\\frac{1}{2}" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 11 + } + }; + + --- [ Advanced Usage ] --------------------------------------------------------------------- + + --- TODO, Add advanced usage. +< + *markview.nvim-latex.escapes* +escapes ~ + + - Type: `latex.escapes` + - Dynamic: true + +Configuration for escaped LaTeX characters. +>lua + -- [ LaTeX | LaTeX escapes ] -------------------------------------------------------------- + + --- Configuration table for latex escaped characters. + ---@class latex.escapes_static + --- + ---@field enable boolean Enables escaped character preview. + ---@field hl? string | fun(item: __latex.escapes): string? Highlight group for the escaped character. + escapes = { + enable = true + }; + + -- [ LaTeX | LaTeX escapes โ€ข Static ] ----------------------------------------------------- + + --- Static configuration table for latex escaped characters. + ---@class latex.escapes + --- + ---@field enable boolean Enables escaped character preview. + ---@field hl? string | fun(item: __latex.escapes): string? Highlight group for the escaped character. +< +>lua + -- [ LaTeX | LaTeX escapes > Parameters ] ------------------------------------------------- + + --- Escaped characters. + ---@class __latex.escapes + --- + ---@field class "latex_escaped" + --- + ---@field text string[] + ---@field range node.range + M.__latex_escapes = { + class = "latex_escaped", + + text = { "\\|" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 2 + } + }; + + -- [ Advanced usage ] ---------------------------------------------------------------------- +< + *markview.nvim-latex.fonts* +fonts ~ + + - Type: `latex.fonts` + - Dynamic: true + +Configuration for escaped LaTeX characters. +>lua + -- [ LaTeX | LaTeX fonts ] ---------------------------------------------------------------- + + --- Configuration table for latex math fonts. + ---@class latex.fonts_static + --- + ---@field enable boolean + --- + ---@field default fonts.opts | fun(buffer: integer, item: __latex.fonts): fonts.opts + ---@field [string] fonts.opts | fun(buffer: integer, item: __latex.fonts): fonts.opts + fonts = { + ---+${lua} + + enable = true, + + default = { + enable = true + hl = "MarkviewSpecial" + }, + -- ["^mathtt$"] = { hl = "MarkviewPalette1" } + ---_ + }; + + -- [ LaTeX | LaTeX fonts โ€ข Static ] ------------------------------------------------------- + + --- Static configuration table for latex math fonts. + ---@class latex.fonts_static + --- + ---@field enable boolean + --- + ---@field default fonts.opts Default configuration for fonts + ---@field [string] fonts.opts Configuration for `\string{}` font. +< +>lua + -- [ LaTeX | LaTeX fonts > Type definitions ] ---------------------------------------------- + + --- Configuration for a specific fonts. + ---@class fonts.opts + --- + ---@field enable? boolean Whether to enable this font. + ---@field hl? string | fun(buffer: integer, item: __latex.fonts): string? Highlight group for this font. + M.fonts_opts = { + enable = true, + hl = "Conditional" + }; + + -- [ LaTeX | LaTeX fonts > Parameters ] ---------------------------------------------------- + + --- Math fonts + ---@class __latex.fonts + --- + ---@field class "latex_font" + --- + ---@field name string Font name. + --- + ---@field text string[] + ---@field range node.range + M.__latex_fonts = { + class = "latex_font", + + name = "mathtt", + + text = { "\\mathtt{abcd}" }, + range = { + font = { 0, 0, 0, 7 }, + row_start = 0, + row_end = 0, + col_start = 0, + col_end = 13 + } + }; + + --- [ Advanced Usage ] --------------------------------------------------------------------- + + fonts = { + enable = true, + default = { hl = "Special" }, + + --- Dynamic highlight group based on + --- font name. + ["bf$"] = { + hl = function (_, item) + if item.name == "mathbf" then + return "Comment"; + else + return "Conditional"; + end + end + } + }; +< + *markview.nvim-latex.inlines* +inlines ~ + + - Type: `latex.inlines` + - Dynamic: true + +Configuration for inline LaTeX. +>lua + --- Configuration table for inline latex math. + ---@class latex.inlines + --- + ---@field enable boolean Enables preview of inline latex maths. + --- + ---@field corner_left? string | fun(buffer: integer, item: __latex.inlines): string? Left corner. + ---@field corner_left_hl? string | fun(buffer: integer, item: __latex.inlines): string? Highlight group for left corner. + ---@field corner_right? string | fun(buffer: integer, item: __latex.inlines): string? Right corner. + ---@field corner_right_hl? string | fun(buffer: integer, item: __latex.inlines): string? Highlight group for right corner. + ---@field hl? string | fun(buffer: integer, item: __latex.inlines): string? Base Highlight group. + ---@field padding_left? string | fun(buffer: integer, item: __latex.inlines): string? Left padding. + ---@field padding_left_hl? string | fun(buffer: integer, item: __latex.inlines): string? Highlight group for left padding. + ---@field padding_right? string | fun(buffer: integer, item: __latex.inlines): string? Right padding. + ---@field padding_right_hl? string | fun(buffer: integer, item: __latex.inlines): string? Highlight group for right padding. + inlines = { + enable = true, + + padding_left = " ", + padding_right = " ", + + hl = "MarkviewInlineCode" + }; +< +>lua + -- [ LaTeX | Inline LaTeX > Parameters ] -------------------------------------------------- + + --- Inline LaTeX(typically made using `$...$`). + ---@class __latex.inlines + --- + ---@field class "latex_inlines" + ---@field marker string + --- + ---@field text string[] + ---@field range node.range + M.__latex_inlines = { + class = "latex_inlines", + marker = "$", + + text = { "$1 + 1 = 2$" }, + range = { + row_start = 0, + col_start = 0, + + row_end = 0, + col_end = 11 + } + }; +< + *markview.nvim-latex.parenthesis* +parenthesis ~ + + - Type: `latex.parenthesis` + - Dynamic: false + +Hides {}. +>lua + --- Configuration for {}. + ---@class latex.parenthesis + --- + ---@field enable boolean + parenthesis = { + enable = true + }; +< +>lua + -- [ LaTeX | Parenthesis > Parameters ] ---------------------------------------------------------------- + + --- {} in LaTeX. + ---@class __latex.parenthesis + --- + ---@field class "latex_parenthesis" + ---@field text string[] + ---@field range node.range + M.__latex_parenthesis = { + class = "latex_parenthesis", + text = { "{1+2}" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 5 + } + }; +< + *markview.nvim-latex.subscripts* +subscripts ~ + + - Type: `latex.subscripts` + - Dynamic: true + +Configuration for subscripts(`_{}`). +>lua + -- [ LaTeX | Subscripts ] ---------------------------------------------------------------- + + --- Configuration for subscripts. + ---@class latex.subscripts + --- + ---@field enable boolean Enables preview of subscript text. + ---@field hl? string | string[] Highlight group for the subscript text. Can be a list to use different hl for nested subscripts. + subscripts = { + enable = true, + hl = "MarkviewSubscript" + }; +< +>lua + -- [ LaTeX | Subscripts > Parameters ] ----------------------------------------------------- + + --- Subscript text(e.g. _h, _{hi}, _{+} etc.). + ---@class __latex.subscripts + --- + ---@field class "latex_subscript" + --- + ---@field parenthesis boolean Is the text within `{...}`? + ---@field level integer Level of the subscript text. Used for handling nested subscript text. + ---@field preview boolean Can the text be previewed? + --- + ---@field text string[] + ---@field range node.range + M.__latex_subscripts = { + class = "latex_subscript", + parenthesis = true, + preview = true, + level = 1, + + text = { "_{hi}" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 5 + } + }; +< + *markview.nvim-latex.superscripts* +superscripts ~ + + - Type: `latex.superscripts` + - Dynamic: true + +Configuration for superscripts(`^{}`). +>lua + -- [ LaTeX | Superscripts ] --------------------------------------------------------------- + + --- Configuration for superscripts. + ---@class latex.superscripts + --- + ---@field enable boolean Enables preview of superscript text. + ---@field hl? string | string[] Highlight group for the superscript text. Can be a list to use different hl for nested superscripts. + subscripts = { + enable = true, + hl = "MarkviewSuperscript" + }; +< +>lua + -- [ LaTeX | Superscripts > Parameters ] -------------------------------------------------- + + --- Superscript text(e.g. ^h, ^{hi}, ^{+} etc.). + ---@class __latex.superscripts + --- + ---@field class "latex_superscript" + --- + ---@field parenthesis boolean Is the text within `{...}`? + ---@field level integer Level of the superscript text. Used for handling nested superscript text. + ---@field preview boolean Can the text be previewed? + --- + ---@field text string[] + ---@field range node.range + M.__latex_superscripts = { + class = "latex_superscript", + parenthesis = true, + preview = true, + level = 1, + + text = { "^{hi}" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 5 + } + }; +< + *markview.nvim-latex.symbols* +symbols ~ + + - Type: `latex.symbols` + - Dynamic: true + +Configuration for TeX math symbols. +>lua + -- [ LaTeX | Symbols ] -------------------------------------------------------------------- + + --- Configuration table for TeX math symbols. + ---@class latex.symbols + --- + ---@field enable boolean + ---@field hl? string | fun(buffer: integer, item: __latex.symbols): string? + symbols = { + enable = true, + hl = "MarkviewSuperscript" + }; + + -- [ LaTeX | Symbols โ€ข Static ] ----------------------------------------------------------- + + --- Configuration table for TeX math symbols. + ---@class latex.symbols_static + --- + ---@field enable boolean Enables preview of latex math symbols. + ---@field hl? string Highlight group for the symbols. +< +>lua + -- [ LaTeX | Symbols > Parameters ] ------------------------------------------------------- + + --- Math symbols in LaTeX(e.g. \Alpha). + ---@class __latex.symbols + --- + ---@field class "latex_symbols" + ---@field name string Symbol name(without the `\`). + ---@field style "superscripts" | "subscripts" | nil Text styles to apply(if possible). + --- + ---@field text string[] + ---@field range node.range + M.__latex_symbols = { + class = "latex_symbols", + name = "pi", + style = nil, + + text = { "\\pi" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 3 + } + }; +< + *markview.nvim-latex.texts* +texts ~ + + - Type: `latex.texts` + - Dynamic: true + +Configuration for `\text{}`. +>lua + --- Configuration table for `\text{}. + ---@class latex.texts + --- + ---@field enable boolean + texts = { + enable = true + }; +< +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/markdown_inline_options.txt b/doc/markdown_inline_options.txt new file mode 100644 index 0000000..78b2ced --- /dev/null +++ b/doc/markdown_inline_options.txt @@ -0,0 +1,1203 @@ +*markview.nvim-inline* Preview options for inline markdown + + Changes how inline markdown items are shown in preview. +>lua + -- [ Markview | Inline ] ------------------------------------------------------------------ + + --- Configuration for inline markdown. + ---@class config.markdown_inline + --- + ---@field enable boolean + --- + ---@field block_references inline.block_references | fun(): inline.block_references + ---@field checkboxes inline.checkboxes | fun(): inline.checkboxes + ---@field emails inline.emails | fun(): inline.emails + ---@field embed_files inline.embed_files | fun(): inline.embed_files + ---@field emoji_shorthands inline.emojis | fun(): inline.emojis + ---@field entities inline.entities | fun(): inline.entities + ---@field escapes inline.escapes | fun(): inline.escapes + ---@field footnotes inline.footnotes | fun(): inline.footnotes + ---@field highlights inline.highlights | fun(): inline.highlights + ---@field hyperlinks inline.hyperlinks | fun(): inline.hyperlinks + ---@field images inline.images | fun(): inline.images + ---@field inline_codes inline.inline_codes | fun(): inline.inline_codes + ---@field internal_links inline.internal_links | fun(): inline.internal_links + ---@field uri_autolinks inline.uri_autolinks | fun(): inline.uri_autolinks + M.markdown_inline = { + enable = true, + + block_references = {}, + checkboxes = {}, + emails = {}, + embed_files = {}, + emoji_shorthands = {}, + entities = {}, + escapes = {}, + footnotes = {}, + highlights = {}, + hyperlinks = {}, + images = {}, + inline_codes = {}, + internal_links = {}, + uri_autolinks = {}, + }; + + -- [ Markview | Inline โ€ข Static ] --------------------------------------------------------- + + --- Static configuration for inline markdown. + ---@class config.markdown_inline_static + --- + ---@field enable boolean + --- + ---@field block_references inline.block_references Block reference link configuration. + ---@field checkboxes inline.checkboxes Checkbox configuration. + ---@field inline_codes inline.inline_codes Inline code/code span configuration. + ---@field emails inline.emails Email link configuration. + ---@field embed_files inline.embed_files Embed file link configuration. + ---@field emoji_shorthands inline.emojis Github styled emoji shorthands. + ---@field entities inline.entities HTML entities configuration. + ---@field escapes inline.escapes Escaped characters configuration. + ---@field footnotes inline.footnotes Footnotes configuration. + ---@field highlights inline.highlights Highlighted text configuration. + ---@field hyperlinks inline.hyperlinks Hyperlink configuration. + ---@field images inline.images Image link configuration. + ---@field internal_links inline.internal_links Internal link configuration. + ---@field uri_autolinks inline.uri_autolinks URI autolink configuration. +< +โ–‹ ๐Ÿ“œ Note +โ–‹ Almost every element in inline markdown have the same customisation options. +โ–‹ As such these options are given below. +>lua + -- [ Markview | Generic inline element ] -------------------------------------------------- + + --- Generic configuration for inline markdown items. + --- Note: {item} will be different based on the node this is being used by. + ---@class config.inline_generic + --- + ---@field corner_left? string | fun(buffer: integer, item: table): string? + ---@field corner_left_hl? string | fun(buffer: integer, item: table): string? + ---@field corner_right? string | fun(buffer: integer, item: table): string? + ---@field corner_right_hl? string | fun(buffer: integer, item: table): string? + ---@field hl? string | fun(buffer: integer, item: table): string? + ---@field icon? string | fun(buffer: integer, item: table): string? + ---@field icon_hl? string | fun(buffer: integer, item: table): string? + ---@field padding_left? string | fun(buffer: integer, item: table): string? + ---@field padding_left_hl? string | fun(buffer: integer, item: table): string? + ---@field padding_right? string | fun(buffer: integer, item: table): string? + ---@field padding_right_hl? string | fun(buffer: integer, item: table): string? + --- + ---@field file_hl? string | fun(buffer: integer, item: table): string? + ---@field block_hl? string | fun(buffer: integer, item: table): string? + M.inline_generic = { + corner_left = "<", + padding_left = " ", + icon = "ฯ€ ", + padding_right = " ", + corner_right = ">", + + hl = "MarkviewCode" + }; + + -- [ Markview | Generic inline element โ€ข Static ] ----------------------------------------- + + --- Static configuration for inline elements. + ---@class config.inline_generic_static + --- + ---@field corner_left? string Left corner. + ---@field corner_left_hl? string Highlight group for left corner. + ---@field corner_right? string Right corner. + ---@field corner_right_hl? string Highlight group for right corner. + ---@field hl? string Base Highlight group. + ---@field icon? string Icon. + ---@field icon_hl? string Highlight group for icon. + ---@field padding_left? string Left padding. + ---@field padding_left_hl? string Highlight group for left padding. + ---@field padding_right? string Right padding. + ---@field padding_right_hl? string Highlight group for right padding. + --- + ---@field file_hl? string Highlight group for block reference file name. + ---@field block_hl? string Highlight group for block reference block ID. +< + *markview.nvim-inline.block_references* +block_references ~ + + - Type: `inline.block_references` + - Dynamic: false + +Configuration for block reference links(from `Obsidian`). +>lua + -- [ Inline | Block references ] ---------------------------------------------------------- + + --- Configuration for block reference links. + ---@class inline.block_references + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __inline.block_references): config.inline_generic + ---@field [string] config.inline_generic | fun(buffer: integer, item: __inline.block_references): config.inline_generic + block_references = { + enable = true, + + default = { + icon = "๓ฐฟจ ", + + hl = "MarkviewPalette6Fg", + file_hl = "MarkviewPalette0Fg", + } + }; + + -- [ Inline | Block references โ€ข Static ] ------------------------------------------------- + + --- Static configuration for block reference links. + ---@class inline.block_references + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for block reference links. + ---@field [string] config.inline_generic_static Configuration for block references whose label matches with the key's pattern. +< +>lua + -- [ Inline | Block references > Parameters ] --------------------------------------------- + + ---@class __inline.block_references + --- + ---@field class "inline_link_block_ref" + --- + ---@field file? string File name. + ---@field block string Block ID. + --- + ---@field label string + --- + ---@field text string[] + ---@field range inline_link.range + M.__inline_block_references = { + class = "inline_link_block_ref", + + file = "Some_file.md", + block = "Block", + label = "Some_file.md#^Block", + + text = { "![[Some_file.md#^Block]]" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 25, + + label = { 0, 3, 0, 23 }, + file = { 0, 3, 0, 12 }, + block = { 0, 14, 0, 23 } + } + }; +< + *markview.nvim-inline.checkboxes* +checkboxes ~ + + - Type: `inlines.checkboxes` + - Dynamic: false + +Configuration for checkboxes. +>lua + -- [ Inline | Checkboxes ] ---------------------------------------------------------------- + + --- Configuration for checkboxes. + ---@class inline.checkboxes + --- + ---@field enable boolean + --- + ---@field checked checkboxes.opts Configuration for [x] & [X]. + ---@field unchecked checkboxes.opts Configuration for [ ]. + --- + ---@field [string] checkboxes.opts + checkboxes = { + enable = true, + + checked = { text = "๓ฐ— ", hl = "MarkviewCheckboxChecked", scope_hl = "MarkviewCheckboxChecked" }, + unchecked = { text = "๓ฐ„ฐ", hl = "MarkviewCheckboxUnchecked", scope_hl = "MarkviewCheckboxUnchecked" }, + + ["/"] = { text = "๓ฑŽ–", hl = "MarkviewCheckboxPending" }, + [">"] = { text = "๏‡˜", hl = "MarkviewCheckboxCancelled" }, + ["<"] = { text = "๓ฐƒ–", hl = "MarkviewCheckboxCancelled" }, + ["-"] = { text = "๓ฐถ", hl = "MarkviewCheckboxCancelled", scope_hl = "MarkviewCheckboxStriked" }, + + ["?"] = { text = "๓ฐ‹—", hl = "MarkviewCheckboxPending" }, + ["!"] = { text = "๓ฐ€ฆ", hl = "MarkviewCheckboxUnchecked" }, + ["*"] = { text = "๓ฐ“Ž", hl = "MarkviewCheckboxPending" }, + ['"'] = { text = "๓ฐธฅ", hl = "MarkviewCheckboxCancelled" }, + ["l"] = { text = "๓ฐ†‹", hl = "MarkviewCheckboxProgress" }, + ["b"] = { text = "๓ฐƒ€", hl = "MarkviewCheckboxProgress" }, + ["i"] = { text = "๓ฐฐ„", hl = "MarkviewCheckboxChecked" }, + ["S"] = { text = "๎พ", hl = "MarkviewCheckboxChecked" }, + ["I"] = { text = "๓ฐ›จ", hl = "MarkviewCheckboxPending" }, + ["p"] = { text = "๏…ค", hl = "MarkviewCheckboxChecked" }, + ["c"] = { text = "๏…ฅ", hl = "MarkviewCheckboxUnchecked" }, + ["f"] = { text = "๓ฑ ‡", hl = "MarkviewCheckboxUnchecked" }, + ["k"] = { text = "๏‚„", hl = "MarkviewCheckboxPending" }, + ["w"] = { text = "๏‡ฝ", hl = "MarkviewCheckboxProgress" }, + ["u"] = { text = "๓ฐ”ต", hl = "MarkviewCheckboxChecked" }, + ["d"] = { text = "๓ฐ”ณ", hl = "MarkviewCheckboxUnchecked" }, + } +< +>lua + -- [ Inline | Checkboxes > Type definitions ] --------------------------------------------- + + ---@class checkboxes.opts + --- + ---@field text string + ---@field hl? string + ---@field scope_hl? string Highlight group for the list item. + M.checkboxes_opts = { + text = "โˆ†", + hl = "MarkviewCheckboxChecked" + }; + + -- [ HTML | Checkboxes > Parameters ] ----------------------------------------------------- + + ---@class __inline.checkboxes + --- + ---@field class "inline_checkbox" + ---@field state string Checkbox state(text inside `[]`). + --- + ---@field text string[] + ---@field range? node.range Range of the checkbox. `nil` when rendering list items. + M.__inline_checkboxes = { + class = "inline_checkbox", + state = "-", + + text = { "[-]" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 2, + col_end = 5 + } + }; +< + *markview.nvim-inline.emails* +emails ~ + + - Type: `inline.emails` + - Dynamic: true + +Configuration for block reference links. +>lua + -- [ Inline | Emails ] -------------------------------------------------------------------- + + --- Configuration for emails. + ---@class inline.emails + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __inline.emails): config.inline_generic + ---@field [string] config.inline_generic | fun(buffer: integer, item: __inline.emails): config.inline_generic + emails = { + ---+${lua} + + enable = true, + + default = { + icon = "๏• ", + hl = "MarkviewEmail" + }, + + ---+${lua, Commonly used email service providers} + + ["%@gmail%.com$"] = { + --- user@gmail.com + + icon = "๓ฐŠซ ", + hl = "MarkviewPalette0Fg" + }, + + ["%@outlook%.com$"] = { + --- user@outlook.com + + icon = "๓ฐดข ", + hl = "MarkviewPalette5Fg" + }, + + ["%@yahoo%.com$"] = { + --- user@yahoo.com + + icon = "๏†ž ", + hl = "MarkviewPalette6Fg" + }, + + ["%@icloud%.com$"] = { + --- user@icloud.com + + icon = "๓ฐ€ธ ", + hl = "MarkviewPalette6Fg" + } + + ---_ + + ---_ + }; + + -- [ Inline | Emails โ€ข Static ] ----------------------------------------------------------- + + --- Static configuration for emails. + ---@class inline.emails + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for emails + ---@field [string] config.inline_generic_static Configuration for emails whose label(address) matches `string`. +< +>lua + -- [ Inline | Emails > Parameters ] ------------------------------------------------------- + + ---@class __inline.emails + --- + ---@field class "inline_link_email" + ---@field label string + ---@field text string[] + ---@field range inline_link.range + M.__inline_link_emails = { + class = "inline_link_email", + label = "example@mail.com", + + text = { "" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 17, + + label = { 0, 1, 0, 16 } + } + }; +< + *markview.nvim-inline.embed_files* +embed_files ~ + + - Type: `inline.embed_files` + - Dynamic: true + +Configuration for embed file links(from `Obsidian`). +>lua + -- [ Inline | Embed files ] --------------------------------------------------------------- + + --- Configuration for obsidian's embed files. + ---@class inline.embed_files + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __inline.embed_files): inline.embed_files + ---@field [string] config.inline_generic | fun(buffer: integer, item: __inline.embed_files): inline.embed_files + embed_files = { + enable = true, + + default = { + icon = "๓ฐ ฎ ", + hl = "MarkviewPalette7Fg" + } + }; + + -- [ Inline | Embed files โ€ข Static ] ------------------------------------------------------ + + --- Static configuration for obsidian's embed files. + ---@class inline.embed_files + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for embed file links. + ---@field [string] config.inline_generic_static Configuration for embed file links whose label matches `string`. +< +>lua + -- [ Inline | Embed files > Parameters ] -------------------------------------------------- + + ---@class __inline.embed_files + --- + ---@field class "inline_link_embed_file" + --- + ---@field label string Text inside `[[...]]`. + --- + ---@field text string[] + ---@field range node.range + M.__inline_link_embed_files = { + class = "inline_link_embed_file", + label = "v25", + + text = { "![[v25]]" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 8 + } + }; +< + *markview.nvim-inline.emoji_shorthands* +emoji_shorthands ~ + + - Type: `inline.emoji_shorthands` + - Dynamic: true + +Configuration for emoji shorthands. +>lua + -- [ Inline | Emojis ] ------------------------------------------------------------------ + + --- Configuration for emoji shorthands. + ---@class inline.emojis + --- + ---@field enable boolean + --- + ---@field hl? string | fun(buffer: integer, item: __inline.entities): inline.emojis + M.inline_emojis = { + enable = true + }; + + -- [ Inline | Emojis โ€ข Static ] --------------------------------------------------------- + + --- Static configuration for emoji shorthands. + ---@class inline.emojis_static + --- + ---@field enable boolean + --- + ---@field hl? string Highlight group for the emoji. +< +>lua + -- [ Inline | Emojis > Parameters ] -------------------------------------------------------- + + ---@class __inline.emojis + --- + ---@field class "inline_emoji" + --- + ---@field name string Emoji name(without `:`). + --- + ---@field text string[] + ---@field range node.range + M.__inline_emojis = { + class = "inline_emoji", + name = "label", + text = { ":label:" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 7 + } + }; +< + *markview.nvim-inline.entities* +entities ~ + + - Type: `inline.entities` + - Dynamic: true + +Configuration for entity references. +>lua + -- [ Inline | Entities ] ------------------------------------------------------------------ + + --- Configuration for HTML entities. + ---@class inline.entities + --- + ---@field enable boolean + --- + ---@field hl? string | fun(buffer: integer, item: __inline.entities): inline.entities + entities = { + enable = true, + hl = "Special" + }; + + -- [ Inline | Entities โ€ข Static ] --------------------------------------------------------- + + --- Static configuration for HTML entities. + ---@class inline.entities_static + --- + ---@field enable boolean + --- + ---@field hl? string Highlight group for the symbol +< +>lua + -- [ Inline | Entities > Parameters ] ------------------------------------------------------------------ + + ---@class __inline.entities + --- + ---@field class "inline_entity" + --- + ---@field name string Entity name(text after "\") + --- + ---@field text string[] + ---@field range node.range + M.__inline_entities = { + class = "inline_entity", + name = "Int", + text = { "∬" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 5 + } + }; +< + *markview.nvim-inline.escapes* +escapes ~ + + - Type: `inline.escapes` + - Dynamic: true + +Configuration for escaped characters. +>lua + --- Configuration for escaped characters. + ---@class inline.escapes + --- + ---@field enable boolean + escapes = { + enable = true + }; +< +>lua + -- [ Inline | Escapes > Parameters ] ------------------------------------------------------ + + ---@class __inline.escaped + --- + ---@field class "inline_escaped" + --- + ---@field text string[] + ---@field range node.range + M.__inline_escaped = { + class = "inline_escaped", + + text = { "\\'" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 2 + } + }; +< + *markview.nvim-inline.footnotes* +footnotes ~ + + - Type: `inline.footnotes` + - Dynamic: true + +Configuration for footnotes. +>lua + -- [ Inline | Footnotes ] ----------------------------------------------------------------- + + --- Configuration for footnotes. + ---@class inline.footnotes + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __inline.footnotes): inline.footnotes + ---@field [string] config.inline_generic | fun(buffer: integer, item: __inline.footnotes): inline.footnotes + footnotes = { + enable = true, + + default = { + icon = "๓ฐฏ“ ", + hl = "MarkviewHyperlink" + }, + ["^%d+$"] = { + icon = "๓ฐฏ“ ", + hl = "MarkviewPalette4Fg" + } + }; + + -- [ Inline | Footnotes โ€ข Static ] -------------------------------------------------------- + + --- Static configuration for footnotes. + ---@class inline.footnotes_static + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for footnotes. + ---@field [string] config.inline_generic_static Configuration for footnotes whose label matches `string`. +< +>lua + -- [ Inline | Footnotes > Parameters ] ---------------------------------------------------- + + ---@class __inline.footnotes + --- + ---@field class "inline_footnotes" + ---@field label string + ---@field text string[] + ---@field range inline_link.range + M.__inline_footnotes = { + class = "inline_footnotes", + label = "1", + + text = { "[^1]" }, + range = { + label = { 0, 2, 0, 3 }, + + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 4 + } + }; +< + *markview.nvim-inline.highlights* +highlights ~ + + - Type: `inline.highlights` + - Dynamic: true + +Configuration for PKM-like highlights(`==highlights==`). +>lua + -- [ Inline | Highlights ] ---------------------------------------------------------------- + + --- Configuration for highlighted texts. + ---@class inline.highlights + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __inline.highlights): inline.highlights + ---@field [string] config.inline_generic | fun(buffer: integer, item: __inline.highlights): inline.highlights + highlights = { + enable = true, + + default = { + padding_left = " ", + padding_right = " ", + + hl = "MarkviewPalette3" + }, + }; + + -- [ Inline | Highlights โ€ข Static ] ------------------------------------------------------- + + --- Static configuration for highlighted texts. + ---@class inline.highlights + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for highlighted text. + ---@field [string] config.inline_generic_static Configuration for highlighted text that matches `string`. +< +>lua + -- [ Inline | Highlights > Parameters ] --------------------------------------------------- + + ---@class __inline.highlights + --- + ---@field class "inline_highlight" + ---@field text string[] + ---@field range node.range + M.__inline_highlights = { + class = "inline_highlight", + + text = { "==Highlight==" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 13 + } + }; +< + *markview.nvim-inline.hyperlinks* +hyperlinks ~ + + - Type: `inline.hyperlinks` + - Dynamic: true + +Configuration for hyperlinks. +>lua + -- [ Inline | Hyperlinks ] ---------------------------------------------------------------- + + --- Configuration for hyperlinks. + ---@class inline.hyperlinks + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __inline.hyperlinks): inline.hyperlinks + ---@field [string] config.inline_generic | fun(buffer: integer, item: __inline.hyperlinks): inline.hyperlinks + hyperlinks = { + ---+${lua} + + enable = true, + + default = { + icon = "๓ฐŒท ", + hl = "MarkviewHyperlink", + }, + + ---+${lua, Github sites} + + ["github%.com/[%a%d%-%_%.]+%/?$"] = { + --- github.com/ + + icon = "๎ช„ ", + hl = "MarkviewPalette0Fg" + }, + ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/?$"] = { + --- github.com// + + icon = "๓ฐณ ", + hl = "MarkviewPalette0Fg" + }, + ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+/tree/[%a%d%-%_%.]+%/?$"] = { + --- github.com///tree/ + + icon = "๏˜ ", + hl = "MarkviewPalette0Fg" + }, + ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+/commits/[%a%d%-%_%.]+%/?$"] = { + --- github.com///commits/ + + icon = "๏— ", + hl = "MarkviewPalette0Fg" + }, + + ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/releases$"] = { + --- github.com///releases + + icon = "๏‚“ ", + hl = "MarkviewPalette0Fg" + }, + ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/tags$"] = { + --- github.com///tags + + icon = "๏€ฌ ", + hl = "MarkviewPalette0Fg" + }, + ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/issues$"] = { + --- github.com///issues + + icon = "๎ฌŒ ", + hl = "MarkviewPalette0Fg" + }, + ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/pulls$"] = { + --- github.com///pulls + + icon = "๎œฆ ", + hl = "MarkviewPalette0Fg" + }, + + ["github%.com/[%a%d%-%_%.]+/[%a%d%-%_%.]+%/wiki$"] = { + --- github.com///wiki + + icon = "๏€ญ ", + hl = "MarkviewPalette0Fg" + }, + + ---_ + ---+${lua, Commonly used sites by programmers} + + ["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" + }, + + ---_ + + ---_ + }; + + -- [ Inline | Hyperlinks โ€ข Static ] ------------------------------------------------------- + + --- Static configuration for hyperlinks. + ---@class inline.hyperlinks_static + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for hyperlinks. + ---@field [string] config.inline_generic_static Configuration for links whose description matches `string`. +< +>lua + -- [ Inline | Hyperlinks > Parameters ] ---------------------------------------------------- + + ---@class __inline.hyperlinks + --- + ---@field class "inline_link_hyperlink" + --- + ---@field label? string + ---@field description? string + --- + ---@field text string[] + ---@field range inline_link.range + M.__inline_images = { + class = "inline_link_hyperlink", + + label = "link", + description = "test.svg", + + text = { "[link](example.md)" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 18, + + label = { 0, 1, 0, 5 }, + description = { 0, 7, 0, 16 } + } + }; +< + *markview.nvim-inline.images* +images ~ + + - Type: `inline.images` + - Dynamic: true + +Configuration for image links. +>lua + -- [ Inline | Images ] -------------------------------------------------------------------- + + --- Configuration for image links. + ---@class inline.images + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(vuffer: integer, item: __inline.images): inline.images + ---@field [string] config.inline_generic | fun(vuffer: integer, item: __inline.images): inline.images + images = { + ---+${lua} + + enable = true, + + default = { + icon = "๓ฐฅถ ", + hl = "MarkviewImage", + }, + + ["%.svg$"] = { icon = "๓ฐœก " }, + ["%.png$"] = { icon = "๓ฐธญ " }, + ["%.jpg$"] = { icon = "๓ฐˆฅ " }, + ["%.gif$"] = { icon = "๓ฐตธ " }, + ["%.pdf$"] = { icon = "๎™ฝ " } + + ---_ + }; + + -- [ Inline | Images โ€ข Static ] ----------------------------------------------------------- + + --- Static configuration for image links. + ---@class inline.images_static + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for image links + ---@field [string] config.inline_generic_static Configuration image links whose description matches `string`. +< +>lua + -- [ Inline | Images > Parameters ] ------------------------------------------------------- + + ---@class __inline.images + --- + ---@field class "inline_link_image" + ---@field label? string + ---@field description? string + ---@field text string[] + ---@field range inline_link.range + M.__inline_images = { + class = "inline_link_image", + label = "image", + description = "test.svg", + + text = { "![image](test.svg)" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 18, + + label = { 0, 2, 0, 7 }, + description = { 0, 9, 0, 17 } + } + }; +< + *markview.nvim-inline.inline_codes* +inline_codes ~ + + - Type: `inline.inline_codes` + - Dynamic: true. + +Configuration for inline codes. +>lua + -- [ Inline | Inline codes ] -------------------------------------------------------------- + + --- Configuration for inline codes. + ---@alias inline.inline_codes config.inline_generic + inline_codes = { + enable = true, + hl = "MarkviewInlineCode", + + padding_left = " ", + padding_right = " " + }; + + -- [ Inline | Inline codes โ€ข Static ] ----------------------------------------------------- + + --- Static configuration for inline codes. + ---@alias inline.inline_codes_static config.inline_generic_static +< +>lua + -- [ Inline | Inline codes > Parameters ] ------------------------------------------------- + + ---@class __inline.inline_codes + --- + ---@field class "inline_code_span" + ---@field text string[] + ---@field range node.range + M.__inline_inline_codes = { + class = "inline_code_span", + text = { "`inline code`" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 13 + } + }; +< + *markview.nvim-inline.internal_links* +internal_links ~ + + - Type: `inline.internal_links` + - Dynamic: true. + +Configuration for internal links(from `Obsidian`). +>lua + -- [ Inline | Internal links ] ------------------------------------------------------------ + + --- Configuration for obsidian's internal links. + ---@class inline.internal_links + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __inline.internal_links): config.inline_generic + ---@field [string] config.inline_generic | fun(buffer: integer, item: __inline.internal_links): config.inline_generic + internal_links = { + enable = true, + + default = { + icon = "๏‘Œ ", + hl = "MarkviewPalette7Fg", + } + }; + + -- [ Inline | Internal links โ€ข Static ] --------------------------------------------------- + + --- Static configuration for obsidian's internal links. + ---@class inline.internal_links_static + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for internal links. + ---@field [string] config.inline_generic_static Configuration for internal links whose label match `string`. +< +>lua + -- [ Inline | Internal links > Parameters ] ------------------------------------------------------------ + + ---@class __inline.internal_links + --- + ---@field class "inline_link_internal" + --- + ---@field alias? string + ---@field label string Text inside `[[...]]`. + --- + ---@field text string[] + ---@field range inline_link.range + M.__inline_internal_links = { + class = "inline_link_internal", + + alias = "Alias", + label = "v25|Alias", + + text = { "[[v25|alias]]" }, + range = { + alias = { 0, 6, 0, 11 }, + label = { 0, 2, 0, 11 }, + + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 13 + } + }; +< + *markview.nvim-inline.uri_autolinks* +uri_autolinks ~ + + - Type: `inline.uri_autolinks` + - Dynamic: true. + +Configuration for URI autolinks(``). +>lua + -- [ Inline | URI autolinks ] ------------------------------------------------------------ + + --- Configuration for uri autolinks. + ---@class inline.uri_autolinks + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __inline.uri_autolinks): config.inline_generic + ---@field [string] config.inline_generic | fun(buffer: integer, item: __inline.uri_autolinks): config.inline_generic + uri_autolinks = { + enable = true, + + default = { + icon = "๎ฌ• ", + hl = "MarkviewEmail" + } + }; + + -- [ Inline | URI autolinks โ€ข Static ] --------------------------------------------------- + + --- Static configuration for uri autolinks. + ---@class inline.uri_autolinks_static + --- + ---@field enable boolean + --- + ---@field default config.inline_generic_static Default configuration for URI autolinks. + ---@field [string] config.inline_generic_static Configuration for URI autolinks whose label match `string`. +< +>lua + -- [ Inline | URI autolinks > Parameters ] ------------------------------------------------ + + ---@class __inline.uri_autolinks + --- + ---@field class "inline_link_uri_autolinks" + --- + ---@field label string + --- + ---@field text string[] + ---@field range inline_link.range + M.__inline_uri_autolinks = { + class = "inline_link_uri_autolinks", + label = "https://example.com", + + text = { "" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 21, + + label = { 0, 1, 0, 20 } + } + }; +< + +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/markdown_options.txt b/doc/markdown_options.txt new file mode 100644 index 0000000..db9e2c4 --- /dev/null +++ b/doc/markdown_options.txt @@ -0,0 +1,1448 @@ +*markview.nvim-markdown* Preview options for markdown + + Changes how markdown items are shown in preview. + +>lua + -- [ Markview | Markdown ] ---------------------------------------------------------------- + + --- Configuration for markdown. + ---@class config.markdown + --- + ---@field enable boolean + --- + ---@field block_quotes markdown.block_quotes | fun(): markdown.block_quotes + ---@field code_blocks markdown.code_blocks | fun(): __markdown.code_blocks + ---@field headings markdown.headings | fun(): markdown.headings + ---@field horizontal_rules markdown.horizontal_rules | fun(): markdown.horizontal_rules + ---@field list_items markdown.list_items | fun(): markdown.list_items + ---@field metadata_minus markdown.metadata_minus | fun(): markdown.metadata_minus + ---@field metadata_plus markdown.metadata_plus | fun(): markdown.metadata_plus + ---@field reference_definitions markdown.reference_definitions | fun(): markdown.reference_definitions + ---@field tables markdown.tables | fun(): markdown.tables + M.markdown = { + enable = true, + + metadata_minus = {}, + horizontal_rules = {}, + headings = {}, + code_blocks = {}, + block_quotes = {}, + list_items = {}, + metadata_plus = {}, + reference_definitions = {}, + tables = {} + }; + + -- [ Markview | Markdown โ€ข Static ] ------------------------------------------------------- + + --- Static configuration for markdown. + ---@class config.markdown_static + --- + ---@field enable boolean + --- + ---@field block_quotes markdown.block_quotes Block quote configuration. + ---@field code_blocks markdown.code_blocks Fenced code block configuration. + ---@field headings markdown.headings Heading configuration. + ---@field horizontal_rules markdown.horizontal_rules Horizontal rules configuration. + ---@field list_items markdown.list_items List items configuration. + ---@field metadata_minus markdown.metadata_minus YAML metadata configuration. + ---@field metadata_plus markdown.metadata_plus TOML metadata configuration. + ---@field reference_definitions markdown.reference_definitions Reference link definition configuration. + ---@field tables markdown.tables Table configuration. +< + *markview.nvim-markdown.block_quotes* +block_quotes ~ + + - Type: `markdown.block_quotes` + - Dynamic: true + +Configuration for block quotes & callouts. +>lua + -- [ Markdown | Block quotes ] ------------------------------------------------------------ + + --- Configuration for block quotes. + ---@class markdown.block_quotes + --- + ---@field enable boolean + --- + ---@field wrap? boolean | fun(buffer: integer, item: __markdown.block_quotes): boolean? + --- + ---@field default block_quotes.opts | fun(buffer: integer, item: __markdown.block_quotes): boolean? + ---@field [string] block_quotes.opts | fun(buffer: integer, item: __markdown.block_quotes): boolean? + block_quotes = { + enable = true, + wrap = true, + + default = { + border = "โ–‹", hl = "MarkviewBlockQuoteDefault" + }, + + ["ABSTRACT"] = { + preview = "๓ฑ‰ซ Abstract", + hl = "MarkviewBlockQuoteNote", + + title = true, + icon = "๓ฑ‰ซ", + + border = "โ–‹" + }, + ["SUMMARY"] = { + hl = "MarkviewBlockQuoteNote", + preview = "๓ฑ‰ซ Summary", + + title = true, + icon = "๓ฑ‰ซ", + + border = "โ–‹" + }, + ["TLDR"] = { + hl = "MarkviewBlockQuoteNote", + preview = "๓ฑ‰ซ Tldr", + + title = true, + icon = "๓ฑ‰ซ", + + border = "โ–‹" + }, + ["TODO"] = { + hl = "MarkviewBlockQuoteNote", + preview = "๎šœ Todo", + + title = true, + icon = "๎šœ", + + border = "โ–‹" + }, + ["INFO"] = { + hl = "MarkviewBlockQuoteNote", + preview = "๎™ช Info", + + custom_title = true, + icon = "๎šœ", + + border = "โ–‹" + }, + ["SUCCESS"] = { + hl = "MarkviewBlockQuoteOk", + preview = "๓ฐ—  Success", + + title = true, + icon = "๓ฐ— ", + + border = "โ–‹" + }, + ["CHECK"] = { + hl = "MarkviewBlockQuoteOk", + preview = "๓ฐ—  Check", + + title = true, + icon = "๓ฐ— ", + + border = "โ–‹" + }, + ["DONE"] = { + hl = "MarkviewBlockQuoteOk", + preview = "๓ฐ—  Done", + + title = true, + icon = "๓ฐ— ", + + border = "โ–‹" + }, + ["QUESTION"] = { + hl = "MarkviewBlockQuoteWarn", + preview = "๓ฐ‹— Question", + + title = true, + icon = "๓ฐ‹—", + + border = "โ–‹" + }, + ["HELP"] = { + hl = "MarkviewBlockQuoteWarn", + preview = "๓ฐ‹— Help", + + title = true, + icon = "๓ฐ‹—", + + border = "โ–‹" + }, + ["FAQ"] = { + hl = "MarkviewBlockQuoteWarn", + preview = "๓ฐ‹— Faq", + + title = true, + icon = "๓ฐ‹—", + + border = "โ–‹" + }, + ["FAILURE"] = { + hl = "MarkviewBlockQuoteError", + preview = "๓ฐ…™ Failure", + + title = true, + icon = "๓ฐ…™", + + border = "โ–‹" + }, + ["FAIL"] = { + hl = "MarkviewBlockQuoteError", + preview = "๓ฐ…™ Fail", + + title = true, + icon = "๓ฐ…™", + + border = "โ–‹" + }, + ["MISSING"] = { + hl = "MarkviewBlockQuoteError", + preview = "๓ฐ…™ Missing", + + title = true, + icon = "๓ฐ…™", + + border = "โ–‹" + }, + ["DANGER"] = { + hl = "MarkviewBlockQuoteError", + preview = "๏ญ Danger", + + title = true, + icon = "๏ญ", + + border = "โ–‹" + }, + ["ERROR"] = { + hl = "MarkviewBlockQuoteError", + preview = "๏ญ Error", + + title = true, + icon = "๏ญ", + + border = "โ–‹" + }, + ["BUG"] = { + hl = "MarkviewBlockQuoteError", + preview = "๏‘ฏ Bug", + + title = true, + icon = "๏‘ฏ", + + border = "โ–‹" + }, + ["EXAMPLE"] = { + hl = "MarkviewBlockQuoteSpecial", + preview = "๓ฑ–ซ Example", + + title = true, + icon = "๓ฑ–ซ", + + border = "โ–‹" + }, + ["QUOTE"] = { + hl = "MarkviewBlockQuoteDefault", + preview = "๏„ Quote", + + title = true, + icon = "๏„", + + border = "โ–‹" + }, + ["CITE"] = { + hl = "MarkviewBlockQuoteDefault", + preview = "๏„ Cite", + + title = true, + icon = "๏„", + + border = "โ–‹" + }, + ["HINT"] = { + hl = "MarkviewBlockQuoteOk", + preview = "๏€ Hint", + + title = true, + icon = "๏„", + + border = "โ–‹" + }, + ["ATTENTION"] = { + hl = "MarkviewBlockQuoteWarn", + preview = "๎ฉฌ Attention", + + title = true, + icon = "๏„", + + border = "โ–‹" + }, + + + ["NOTE"] = { + match_string = "NOTE", + hl = "MarkviewBlockQuoteNote", + preview = "๓ฐ‹ฝ Note", + + border = "โ–‹" + }, + ["TIP"] = { + match_string = "TIP", + hl = "MarkviewBlockQuoteOk", + preview = "๏€ Tip", + + border = "โ–‹" + }, + ["IMPORTANT"] = { + match_string = "IMPORTANT", + hl = "MarkviewBlockQuoteSpecial", + preview = "๎ญ‚ Important", + + border = "โ–‹" + }, + ["WARNING"] = { + match_string = "WARNING", + hl = "MarkviewBlockQuoteWarn", + preview = "๎ฉฌ Warning", + + border = "โ–‹" + }, + ["CAUTION"] = { + match_string = "CAUTION", + hl = "MarkviewBlockQuoteError", + preview = "๓ฐณฆ Caution", + + border = "โ–‹" + } + }, + -- [ Markdown | Block quotes โ€ข Static ] --------------------------------------------------- + + --- Static configuration for block quotes. + ---@class markdown.block_quotes_static + --- + ---@field enable boolean + --- + ---@field wrap? boolean Enables basic wrap support. + --- + ---@field default block_quotes.opts Default block quote configuration. + ---@field [string] block_quotes.opts Configuration for >[!{string}] callout. +< +>lua + -- [ Markdown | Block quotes > Type definition ] ------------------------------------------ + + --- Configuration options for various types of block quotes. + ---@class block_quotes.opts + --- + ---@field border string | string[] | fun(buffer: integer, item: __markdown.block_quotes): (string | string[]) + ---@field border_hl? (string | string[]) | fun(buffer: integer, item: __markdown.block_quotes): (string | string[])? + ---@field hl? string | fun(buffer: integer, item: __markdown.block_quotes): string? + ---@field icon? string | fun(buffer: integer, item: __markdown.block_quotes): string? + ---@field icon_hl? string | fun(buffer: integer, item: __markdown.block_quotes): string? + ---@field preview? string | fun(buffer: integer, item: __markdown.block_quotes): string? + ---@field preview_hl? string | fun(buffer: integer, item: __markdown.block_quotes): string? + ---@field title? boolean | fun(buffer: integer, item: __markdown.block_quotes): string? + M.block_quotes_opts = { + border = "|", + hl = "MarkviewBlockQuoteDefault", + icon = "ฯ€", + preview = "ฯ€ Some text" + }; + + -- [ Markdown | Block quotes > Type definition โ€ข Static ] --------------------------------- + + --- Static configuration options for various types of block quotes. + ---@class block_quotes.opts + --- + ---@field border string | string[] Text for the border. + ---@field border_hl? string | string[] Highlight group for the border. + ---@field hl? string Base highlight group for the block quote. + ---@field icon? string Icon to show before the block quote title. + ---@field icon_hl? string Highlight group for the icon. + ---@field preview? string Callout/Alert preview string(shown where >[!{string}] was). + ---@field preview_hl? string Highlight group for the preview. + ---@field title? boolean Whether the block quote can have a title or not. + + -- [ Markdown | Block quotes > Parameters ] ----------------------------------------------- + + ---@class __markdown.block_quotes + --- + ---@field class "markdown_block_quote" + --- + ---@field callout string? Callout text(text inside `[!...]`). + ---@field title string? Title of the callout. + --- + ---@field text string[] + ---@field range __block_quotes.range + --- + ---@field __nested boolean Is the node nested? + M.__markdown_block_quotes = { + class = "markdown_block_quote", + callout = "TIP", + title = "Title", + + text = { + ">[!TIP] Title", + "> Something." + }, + range = { + row_start = 0, + row_end = 2, + + col_start = 0, + col_end = 0, + + callout_start = 3, + callout_end = 6, + + title_start = 8, + title_end = 13 + } + }; +< + *markview.nvim-markdown.code_blocks* +code_blocks ~ + + - Type: `markdown.code_blocks` + - Dynamic: true + +Configuration for code blocks. +>lua + --- Configuration for code blocks. + ---@class markdown.code_blocks + --- + ---@field enable boolean + --- + ---@field border_hl? string | fun(buffer: integer, item: __markdown.code_blocks): string? + ---@field info_hl? string | fun(buffer: integer, item: __markdown.code_blocks): string? + ---@field label_direction? "left" | "right" | fun(buffer: integer, item: __markdown.code_blocks): ("left" | "right") + ---@field label_hl? string | fun(buffer: integer, item: __markdown.code_blocks): string? + ---@field min_width? integer | fun(buffer: integer, item: __markdown.code_blocks): integer + ---@field pad_amount? integer | fun(buffer: integer, item: __markdown.code_blocks): integer + ---@field pad_char? string | fun(buffer: integer, item: __markdown.code_blocks): string? + ---@field sign? boolean | fun(buffer: integer, item: __markdown.code_blocks): boolean + ---@field sign_hl? string | fun(buffer: integer, item: __markdown.code_blocks): string? + ---@field style "simple" | "block" | fun(buffer: integer, item: __markdown.code_blocks): ("simple" | "block") + --- + ---@field default code_blocks.opts | fun(buffer: integer, item: __markdown.code_blocks): code_blocks.opts + ---@field [string] code_blocks.opts | fun(buffer: integer, item: __markdown.code_blocks): code_blocks.opts + code_blocks = { + enable = true, + + style = "block", + + label_direction = "right", + + border_hl = "MarkviewCode", + info_hl = "MarkviewCodeInfo", + + min_width = 60, + pad_amount = 2, + pad_char = " ", + + sign = true, + + 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" + } + }; + + -- [ Markdown | Code blocks โ€ข Static ] ---------------------------------------------------- + + --- Configuration for code blocks. + ---@class markdown.code_blocks + --- + ---@field enable boolean + --- + ---@field hl? string Base highlight group for code blocks. + ---@field info_hl? string Highlight group for the info string. + ---@field label_direction? "left" | "right" Changes where the label is shown. + ---@field label_hl? string Highlight group for the label + ---@field min_width? integer width of the code block. + ---@field pad_amount? integer & right padding size. + ---@field pad_char? stringacter to use for the padding. + ---@field sign? booleanher to show signs for the code blocks. + ---@field sign_hl? stringlight group for the signs. + ---@field style "simple" | "block" Preview style for code blocks. + --- + ---@field default code_blocks.opts_static Default line configuration for the code block. + ---@field [string] code_blocks.opts_static Line configuration for the code block whose `language` matches `string` +< +>lua + -- [ Markdown | Code blocks > Type definitions ] ------------------------------------------ + + --- Configuration for highlighting a line inside a code block. + ---@class code_blocks.opts + --- + ---@field block_hl string | fun(buffer: integer, line: string): string? + ---@field pad_hl string | fun(buffer: integer, line: string): string? + + --- Static configuration for highlighting a line inside a code block. + ---@class code_blocks.opts_static + --- + ---@field block_hl string? Highlight group for the background of the line. + ---@field pad_hl string? Highlight group for the padding of the line. + + -- [ Markdown | Code blocks > Parameters ] ------------------------------------------------ + + ---@class __markdown.code_blocks + --- + ---@field class "markdown_code_block" + --- + ---@field delimiters [ string, string ] Code block delimiters. + ---@field language string? Language string(typically after ```). + ---@field info_string string? Extra information regarding the code block. + --- + ---@field text string[] + ---@field range __code_blocks.range + M.__markdown_code_blocks = { + class = "markdown_code_block", + + language = "lua", + info_string = "lua Info string", + + text = { + "``` lua Info string", + 'vim.print("Hello, Neovim!");', + "```" + }, + + range = { + row_start = 0, + row_end = 3, + + col_start = 0, + col_end = 0, + + language = { 0, 4, 0, 7 }, + info_string = { 0, 4, 0, 15 } + } + }; + + ---@class __code_blocks.range + --- + ---@field row_start integer + ---@field row_end integer + ---@field col_start integer + ---@field col_end integer + --- + ---@field language? integer[] Range of the language string. + ---@field info_string? integer[] Range of info string. + M.__code_blocks_range = { + row_start = 0, + row_end = 3, + + col_start = 0, + col_end = 0, + + language = { 0, 4, 0, 7 }, + info_string = { 0, 4, 0, 15 } + }; + + -- [ Advanced usage ] ---------------------------------------------------------------------- + + --- Simple styled code blocks. + code_blocks = { + style = function (_, item) + --- NOTE, Language string & filetypes are *different*. + --- For markdown, the language can be `md`, `markdown`. + if vim.list_contains({ "md", "markdown" }, item.language) then + return "simple"; + else + return "block"; + end + + hl = "MarkviewCode", + info_hl = "MarkviewCodeInfo", + + label_direction = "right" + }; +< + *markview.nvim-markdown.headings* +headings ~ + + - Type: `markdown.headings` + - Dynamic: true + +Configuration for ATX & Setext headings. +>lua + -- [ Markdown | Headings ] ---------------------------------------------------------------- + + ---@class markdown.headings + --- + ---@field enable boolean Enables preview of headings. + --- + ---@field heading_1 headings.atx | fun(buffer: integer, item: __markdown.atx): headings.atx + ---@field heading_2 headings.atx | fun(buffer: integer, item: __markdown.atx): headings.atx + ---@field heading_3 headings.atx | fun(buffer: integer, item: __markdown.atx): headings.atx + ---@field heading_4 headings.atx | fun(buffer: integer, item: __markdown.atx): headings.atx + ---@field heading_5 headings.atx | fun(buffer: integer, item: __markdown.atx): headings.atx + ---@field heading_6 headings.atx | fun(buffer: integer, item: __markdown.atx): headings.atx + --- + ---@field setext_1 headings.setext | fun(buffer: integer, item: __markdown.setext): headings.setext + ---@field setext_2 headings.setext | fun(buffer: integer, item: __markdown.setext): headings.setext + --- + ---@field shift_width integer Amount of spaces to add before the heading(per level). + --- + ---@field org_indent? boolean Whether to enable org-mode like section indentation. + ---@field org_shift_width? integer Shift width for org indents. + ---@field org_shift_char? string Shift char for org indent. + ---@field org_indent_wrap? boolean Whether to enable wrap support. May have severe performance issues! + headings = { + enable = true, + + shift_width = 1, + org_indent = false, + org_indent_wrap = true, + + 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", + }, + + setext_1 = { + style = "decorated", + + sign = "๓ฐŒ• ", sign_hl = "MarkviewHeading1Sign", + icon = " ๎ชซ ", hl = "MarkviewHeading1", + border = "โ–‚" + }, + setext_2 = { + style = "decorated", + + sign = "๓ฐŒ– ", sign_hl = "MarkviewHeading2Sign", + icon = " ๎ชช ", hl = "MarkviewHeading2", + border = "โ–" + } + }; +< +>lua + -- [ Markdown | Headings > Type definitions ] --------------------------------------------- + + ---@class headings.atx + --- + ---@field align? "left" | "center" | "right" Label alignment. + ---@field corner_left? string Left corner. + ---@field corner_left_hl? string Highlight group for left corner. + ---@field corner_right? string Right corner. + ---@field corner_right_hl? string Highlight group for right corner. + ---@field hl? string Base Highlight group. + ---@field icon? string Icon. + ---@field icon_hl? string Highlight group for icon. + ---@field padding_left? string Left padding. + ---@field padding_left_hl? string Highlight group for left padding. + ---@field padding_right? string Right padding. + ---@field padding_right_hl? string Highlight group for right padding. + ---@field sign? string Text to show on the sign column. + ---@field sign_hl? string Highlight group for the sign. + ---@field style "simple" | "label" | "icon" Preview style. + M.headings_atx = { + style = "simple", + hl = "MarkviewHeading1" + } or { + style = "label", + align = "center", + + padding_left = " ", + padding_right = " ", + + hl = "MarkviewHeading1" + } or { + style = "icon", + + icon = "~", + hl = "MarkviewHeading1" + }; + + ---@class headings.setext + --- + ---@field border string Text to use for the preview border. + ---@field border_hl? string Highlight group for the border. + ---@field hl? string Base highlight group. + ---@field icon? string Text to use for the icon. + ---@field icon_hl? string Highlight group for the icon. + ---@field sign? string Text to show in the sign column. + ---@field sign_hl? string Highlight group for the sign. + ---@field style "simple" | "decorated" Preview style. + M.headings_setext = { + style = "simple", + hl = "MarkviewHeading1" + } or { + style = "decorated", + border = "โ€”", + hl = "MarkviewHeading1" + }; + + -- [ Markdown | Headings > Parameters ] --------------------------------------------------- + + ---@class __markdown.atx + --- + ---@field class "markdown_atx_heading" + --- + ---@field marker "#" | "##" | "###" | "####" | "#####" | "######" Heading marker. + --- + ---@field text string[] + ---@field range node.range + M.__markdown_atx = { + class = "markdown_atx_heading", + marker = "#", + + text = { "# Heading 1" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 11 + } + }; + + + ---@class __markdown.setext + --- + ---@field class "markdown_setext_heading" + --- + ---@field marker "---" | "===" Heading marker. + --- + ---@field text string[] + ---@field range node.range + M.__markdown_setext = { + class = "markdown_setext_heading", + marker = "---", + text = { + "Heading", + "---" + }, + range = { + row_start = 0, + row_end = 2, + + col_start = 0, + col_end = 3 + } + }; + + -- [ Advanced usage ] ---------------------------------------------------------------------- + + headings = { + --- Changes color if the heading has an ID. + heading_1 = { + hl = function (_, item) + local end_text = item.text[#item.text]; + + if end_text:match("%{%#.+%}$") then + return "MarkviewPalette1"; + else + return "MarkviewPalette1Bg"; + end + end + } + } +< + *markview.nvim-markdown.horizontal_rules* +horizontal_rules ~ + + - Type: `markdown.horizontal_rules` + - Dynamic: true + +Configuration for horizontal rules. +>lua + -- [ Markdown | Horizontal rules ] -------------------------------------------------------- + + --- Configuration for horizontal rules. + ---@class markdown.horizontal_rules + --- + ---@field enable boolean Enables preview of horizontal rules. + --- + ---@field parts ( horizontal_rules.text | horizontal_rules.repeating )[] Parts for the horizontal rules. + horizontal_rules = { + enable = true, + + parts = { + { + type = "repeating", + repeat_amount = function (buffer) + local utils = require("markview.utils"); + local window = utils.buf_getwin(buffer) + + local width = vim.api.nvim_win_get_width(window) + local textoff = vim.fn.getwininfo(window)[1].textoff; + + return math.floor((width - textoff - 3) / 2); + end, + + text = "โ”€", + hl = { + "MarkviewGradient1", "MarkviewGradient1", + "MarkviewGradient2", "MarkviewGradient2", + "MarkviewGradient3", "MarkviewGradient3", + "MarkviewGradient4", "MarkviewGradient4", + "MarkviewGradient5", "MarkviewGradient5", + "MarkviewGradient6", "MarkviewGradient6", + "MarkviewGradient7", "MarkviewGradient7", + "MarkviewGradient8", "MarkviewGradient8", + "MarkviewGradient9", "MarkviewGradient9" + } + }, + { + type = "text", + text = " ๎ชช ", + hl = "MarkviewIcon3Fg" + }, + { + type = "repeating", + repeat_amount = function (buffer) + local utils = require("markview.utils"); + local window = utils.buf_getwin(buffer) + + local width = vim.api.nvim_win_get_width(window) + local textoff = vim.fn.getwininfo(window)[1].textoff; + + return math.ceil((width - textoff - 3) / 2); + end, + + direction = "right", + text = "โ”€", + hl = { + "MarkviewGradient1", "MarkviewGradient1", + "MarkviewGradient2", "MarkviewGradient2", + "MarkviewGradient3", "MarkviewGradient3", + "MarkviewGradient4", "MarkviewGradient4", + "MarkviewGradient5", "MarkviewGradient5", + "MarkviewGradient6", "MarkviewGradient6", + "MarkviewGradient7", "MarkviewGradient7", + "MarkviewGradient8", "MarkviewGradient8", + "MarkviewGradient9", "MarkviewGradient9" + } + } + } + }, +< +>lua + -- [ Markdown | Horizontal rules > Parameters ] ------------------------------------------- + + ---@class __markdown.horizontal_rules + --- + ---@field class "markdown_hr" + ---@field text string[] + ---@field range node.range + M.__markdown_hr = { + class = "markdown_hr", + text = { "---" }, + range = { + row_start = 0, + row_end = 1, + + col_start = 0, + col_end = 0 + } + }; +< + *markview.nvim-markdown.list_items* +list_items ~ + + - Type: `markdown.list_items` + - Dynamic: true + +Configuration for various list items. +>lua + -- [ Markdown | List items ] -------------------------------------------------------------- + + --- Configuration for list items. + ---@class markdown.list_items + --- + ---@field enable boolean + --- + ---@field indent_size integer Indentation size for list items. + ---@field shift_width integer Virtual indentation size for previewed list items. + --- + ---@field marker_dot list_items.ordered Configuration for `n.` list items. + ---@field marker_minus list_items.unordered Configuration for `-` list items. + ---@field marker_parenthesis list_items.ordered Configuration for `n)` list items. + ---@field marker_plus list_items.unordered Configuration for `+` list items. + ---@field marker_star list_items.unordered Configuration for `*` list items. + --- + ---@field wrap? boolean Enables wrap support. + list_items = { + enable = true, + wrap = false, + + indent_size = 2, + shift_width = 4, + + marker_minus = { + add_padding = true, + conceal_on_checkboxes = true, + + text = "๎ฉฑ", + hl = "MarkviewListItemMinus" + }, + + marker_plus = { + add_padding = true, + conceal_on_checkboxes = true, + + text = "๎ชซ", + hl = "MarkviewListItemPlus" + }, + + marker_star = { + add_padding = true, + conceal_on_checkboxes = true, + + text = "๎ชฉ", + hl = "MarkviewListItemStar" + }, + + marker_dot = { + add_padding = true, + conceal_on_checkboxes = true, + }, + + marker_parenthesis = { + add_padding = true, + conceal_on_checkboxes = true, + } + }, +< +>lua + -- [ Markdown | List items > Type definitions ] ------------------------------------------- + + ---@class list_items.unordered + --- + ---@field add_padding boolean + ---@field conceal_on_checkboxes? boolean + ---@field enable? boolean + ---@field hl? string + ---@field text string + M.list_items_unordered = { + enable = true, + hl = "MarkviewListItemPlus", + text = "โ€ข", + add_padding = true, + conceal_on_checkboxes = true + }; + + ---@class list_items.ordered + --- + ---@field add_padding boolean + ---@field conceal_on_checkboxes? boolean + ---@field enable? boolean + M.list_items_ordered = { + enable = true, + add_padding = true, + conceal_on_checkboxes = true + }; + + -- [ Markdown | List items > Parameters ] ------------------------------------------------- + + ---@class __markdown.list_items + --- + ---@field class "markdown_list_item" + ---@field candidates integer[] List of line numbers(0-indexed) from `range.row_start` that should be indented. + ---@field marker "-" | "+" | "*" | string List marker text. + ---@field checkbox? string Checkbox state(if there is a checkbox). + ---@field indent integer Spaces before the list marker. + ---@field text string[] + ---@field range node.range + --- + ---@field __block boolean Indicates whether the list item is the children of a block quote. + M.__markdown_list_items = { + class = "markdown_list_item", + marker = "-", + checkbox = nil, + candidates = { 0 }, + + text = { "- List item" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 11 + } + }; +< + *markview.nvim-markdown.metadata_minus* +metadata_minus ~ + + - Type: `markdown.metadata_minus` + - Dynamic: true + +Configuration for metadata minus(YAML metadata). +>lua + -- [ Markdown | Metadata minus ] ---------------------------------------------------------- + + --- Configuration for YAML metadata. + ---@class markdown.metadata_minus + --- + ---@field enable boolean + --- + ---@field border_bottom? string | fun(buffer: integer, item: __markdown.metadata_minus): string? + ---@field border_bottom_hl? string | fun(buffer: integer, item: __markdown.metadata_minus): string? + ---@field border_hl? string | fun(buffer: integer, item: __markdown.metadata_minus): string? + ---@field border_top? string | fun(buffer: integer, item: __markdown.metadata_minus): string? + ---@field border_top_hl? string | fun(buffer: integer, item: __markdown.metadata_minus): string? + --- + ---@field hl? string | fun(buffer: integer, item: __markdown.metadata_minus): string? + metadata_minus = { + enable = true, + + hl = "MarkviewCode", + border_hl = "MarkviewCodeFg", + + border_top = "โ–„", + border_bottom = "โ–€" + }; + + -- [ Markdown | Metadata minus โ€ข Static ] ------------------------------------------------- + + --- Static configuration for YAML metadata. + ---@class markdown.metadata_minus_static + --- + ---@field enable boolean + --- + ---@field border_bottom? string Bottom border. + ---@field border_bottom_hl? string Highlight group for the bottom border. + ---@field border_hl? string Primary highlight group for the borders. + ---@field border_top? string Top border. + ---@field border_top_hl? string Highlight group for the top border. + --- + ---@field hl? string Background highlight group. +< +>lua + -- [ Markdown | Metadata minus > Parameters ] --------------------------------------------- + + ---@class __markdown.metadata_minus + --- + ---@field class "markdown_metadata_minus" + ---@field text string[] + ---@field range node.range + M.__markdown_metadata_minus = { + class = "markdown_metadata_minus", + + text = { + "---", + "author: OXY2DEV", + "---" + }, + range = { + row_start = 0, + row_end = 2, + + col_start = 0, + col_end = 3 + } + }; +< + *markview.nvim-markdown.metadata_plus* +metadata_plus ~ + + - Type: `markdown.metadata_plus` + - Dynamic: true + +Configuration for metadata plus(TOML metadata). +>lua + -- [ Markdown | Metadata plus ] ----------------------------------------------------------- + + --- Configuration for TOML metadata. + ---@class markdown.metadata_plus + --- + ---@field enable boolean + --- + ---@field border_bottom? string | fun(buffer: integer, item: __markdown.metadata_plus): string? + ---@field border_bottom_hl? string | fun(buffer: integer, item: __markdown.metadata_plus): string? + ---@field border_hl? string | fun(buffer: integer, item: __markdown.metadata_plus): string? + ---@field border_top? string | fun(buffer: integer, item: __markdown.metadata_plus): string? + ---@field border_top_hl? string | fun(buffer: integer, item: __markdown.metadata_plus): string? + --- + ---@field hl? string | fun(buffer: integer, item: __markdown.metadata_plus): string? + metadata_plus = { + enable = true, + + hl = "MarkviewCode", + border_hl = "MarkviewCodeFg", + + border_top = "โ–„", + border_bottom = "โ–€" + }; + + -- [ Markdown | Metadata plus โ€ข Static ] -------------------------------------------------- + + --- Static configuration for TOML metadata. + ---@class markdown.metadata_plus_static + --- + ---@field enable boolean + --- + ---@field border_bottom? string Bottom border. + ---@field border_bottom_hl? string Highlight group for the bottom border. + ---@field border_hl? string Primary highlight group for the borders. + ---@field border_top? string Top border. + ---@field border_top_hl? string Highlight group for the top border. + --- + ---@field hl? string Background highlight group. +< +>lua + -- [ Markdown | Metadata plus > Parameters ] ---------------------------------------------- + + ---@class __markdown.metadata_plus + --- + ---@field class "markdown_metadata_plus" + ---@field text string[] + ---@field range node.range + M.__markdown_metadata_plus = { + class = "markdown_metadata_plus", + + text = { + "---", + "author: OXY2DEV", + "---" + }, + range = { + row_start = 0, + row_end = 2, + + col_start = 0, + col_end = 3 + } + }; +< + *markview.nvim-markdown.reference_definitions* +reference_definitions ~ + + - Type: `markdown.reference_definitions` + - Dynamic: true + +Configuration for reference definitions. +>lua + -- [ Markdown | Reference definitions ] --------------------------------------------------- + + --- Configuration for reference definitions. + ---@class markdown.reference_definitions + --- + ---@field enable boolean + --- + ---@field default config.inline_generic Default configuration for reference definitions. + ---@field [string] config.inline_generic Configuration for reference definitions whose description matches `string`. + reference_definitions = { + enable = true, + + default = { + icon = "๏…Œ ", + hl = "Palette4Fg" + } + }; +< +>lua + -- [ Markdown | Reference definitions > Parameters ] -------------------------------------- + + ---@class __markdown.reference_definitions + --- + ---@field class "markdown_link_ref_definition" + --- + ---@field label? string Visible part of the reference link definition. + ---@field description? string Description of the reference link. + --- + ---@field text string[] + ---@field range __reference_definitions.range + M.__markdown_reference_definitions = { + class = "markdown_link_ref_definition", + label = "nvim", + description = "https://www.neovim.org", + + text = { + "[nvim]:", + "https://www.neovim.org" + }, + range = { + row_start = 0, + row_end = 1, + + col_start = 0, + col_end = 21, + + label = { 0, 0, 0, 7 }, + description = { 1, 0, 1, 21 } + } + }; +< + *markview.nvim-markdown.tables* +tables ~ + + - Type: `markdown.tables` + - Dynamic: true + +Configuration for tables. +>lua + -- [ Markdown | Tables ] ------------------------------------------------------------------ + + --- Configuration for tables. + ---@class markdown.tables + --- + ---@field enable boolean + --- + ---@field block_decorator boolean + ---@field use_virt_lines boolean + --- + ---@field hl tables.parts | fun(buffer: integer, item: __markdown.tables): tables.parts + ---@field parts tables.parts | fun(buffer: integer, item: __markdown.tables): tables.parts + tables = { + enable = true, + + parts = { + top = { "โ•ญ", "โ”€", "โ•ฎ", "โ”ฌ" }, + header = { "โ”‚", "โ”‚", "โ”‚" }, + separator = { "โ”œ", "โ”€", "โ”ค", "โ”ผ" }, + row = { "โ”‚", "โ”‚", "โ”‚" }, + bottom = { "โ•ฐ", "โ”€", "โ•ฏ", "โ”ด" }, + + overlap = { "โ”", "โ”", "โ”ฅ", "โ”ฟ" }, + + align_left = "โ•ผ", + align_right = "โ•พ", + align_center = { "โ•ด", "โ•ถ" } + }, + + hl = { + top = { "TableHeader", "TableHeader", "TableHeader", "TableHeader" }, + header = { "TableHeader", "TableHeader", "TableHeader" }, + separator = { "TableHeader", "TableHeader", "TableHeader", "TableHeader" }, + row = { "TableBorder", "TableBorder", "TableBorder" }, + bottom = { "TableBorder", "TableBorder", "TableBorder", "TableBorder" }, + + overlap = { "TableBorder", "TableBorder", "TableBorder", "TableBorder" }, + + align_left = "TableAlignLeft", + align_right = "TableAlignRight", + align_center = { "TableAlignCenter", "TableAlignCenter" } + }, + + col_min_width = 10, + block_decorator = true, + use_virt_lines = false + }; + + -- [ Markdown | Tables โ€ข Static ] --------------------------------------------------------- + + --- Static configuration for tables. + ---@class markdown.tables_static + --- + ---@field enable boolean + --- + ---@field block_decorator boolean Whether to draw top & bottom border. + ---@field use_virt_lines boolean Whether to use virtual lines for the borders. + --- + ---@field hl tables.parts Highlight groups for the parts. + ---@field parts tables.parts Parts for the table. +< +>lua + -- [ Markdown | Tables > Type definitions ] ----------------------------------------------- + + --- Parts that make the previewed table. + ---@class tables.parts + --- + ---@field align_center [ string, string ] + ---@field align_left string + ---@field align_right string + ---@field top string[] + ---@field header string[] + ---@field separator string[] + ---@field row string[] + ---@field bottom string[] + ---@field overlap string[] + M.tables_parts = { + align_center = { "" }, + row = { "", "", "" }, + top = { "", "", "", "" }, + bottom = { "", "", "", "" }, + header = { "", "", "" }, + overlap = { "", "", "", "" }, + separator = { "", "", "" }, + align_left = "", + align_right = "" + }; + + -- [ Markdown | Tables > Parameters ] ----------------------------------------------------- + + ---@class __markdown.tables + --- + ---@field class "markdown_table" + --- + ---@field top_border boolean Can we draw the top border? + ---@field bottom_border boolean Can we draw the bottom border? + ---@field border_overlap boolean Is the table's borders overlapping another table? + --- + ---@field alignments ( "left" | "center" | "right" | "default" )[] Text alignments. + ---@field header __tables.cell[] + ---@field separator __tables.cell[] + ---@field rows __tables.cell[][] + --- + ---@field text string[] + ---@field range node.range + M.__markdown_tables = { + class = "markdown_table", + + top_border = true, + bottom_border = true, + border_overlap = false, + + alignments = { "default", "default", "default" }, + header = { + { + class = "separator", + text = "|", + col_start = 0, + col_end = 1 + }, + { + class = "column", + text = " Col 1 ", + col_start = 2, + col_end = 9 + }, + { + class = "separator", + text = "|", + col_start = 10, + col_end = 11 + }, + { + class = "column", + text = " Col 2 ", + col_start = 12, + col_end = 19 + }, + { + class = "separator", + text = "|", + col_start = 20, + col_end = 21 + } + }, + separator = { + { + class = "separator", + text = "|", + col_start = 0, + col_end = 1 + }, + { + class = "column", + text = " ----- ", + col_start = 2, + col_end = 9 + }, + { + class = "separator", + text = "|", + col_start = 10, + col_end = 11 + }, + { + class = "column", + text = " ----- ", + col_start = 12, + col_end = 19 + }, + { + class = "separator", + text = "|", + col_start = 20, + col_end = 21 + } + }, + rows = { + { + { + class = "separator", + text = "|", + col_start = 0, + col_end = 1 + }, + { + class = "column", + text = " Cell 1 ", + col_start = 2, + col_end = 10 + }, + { + class = "separator", + text = "|", + col_start = 11, + col_end = 12 + }, + { + class = "column", + text = " Cell 2 ", + col_start = 13, + col_end = 21 + }, + { + class = "separator", + text = "|", + col_start = 22, + col_end = 23 + } + } + }, + + text = { + "| Col 1 | Col 2 |", + "| ----- | ----- |", + "| Cell 1 | Cell 2 |" + } + }; + + ---@class __tables.cell + --- + ---@field class "separator" | "column" | "missing_separator" + --- + ---@field text string + --- + ---@field col_start integer + ---@field col_end integer + M.__tables_cell = { + class = "separator", + text = "|", + col_start = 0, + col_end = 1 + }; +< + +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/markview.txt b/doc/markview.txt deleted file mode 100644 index 2bf15a8..0000000 --- a/doc/markview.txt +++ /dev/null @@ -1,2195 +0,0 @@ -*markview.nvim* An experimental markdown previewer for Neovim - - โ•ญโ”€โ•ผ Nvim - .../markview.nvim/README.md โ•พโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ - โ”‚ โ—ˆ markview.nvim โ”‚ - โ”‚ โ”‚ - โ”‚ Highly customisable & feature rich markdown previewer for Neovim. โ”‚ - โ”‚ โ”‚ - โ”‚ โ—ˆ Features โ”‚ - โ”‚ โ”‚ - โ”‚ โœ” Basic markdown support. โ”‚ - โ”‚ โœ” Extended markdown support. โ”‚ - โ”‚ โœ” Github alerts โ”‚ - โ”‚ โœ” Obsidian callouts โ”‚ - โ”‚ โœ” Obsidian checkboxes โ”‚ - โ”‚ โœ” LaTeX support(basic) โ”‚ - โ”‚ โœ” Html tags & entities support. โ”‚ - โ”‚ โœ” Can work on files other than markdown. โ”‚ - โ”‚ โœ” Works like normal even on large files. โ”‚ - โ”‚ โœ” Hybrid mode & split view. โ”‚ - โ”‚ โœ” Tree-sitter injection support. โ”‚ - โ”‚ โœ” Dynamic highlighlight groups. โ”‚ - โ”‚ โ”‚ - โ”‚ And so much more! โ”‚ - โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ - -============================================================================== -Table of contents - - -============================================================================== -Setup *markview.nvim-setup* - -This is the simplified version of the available options. You can find all the -options in their own sections. ->lua - { - --- When true, markdown, html, latex aren't rendered inside - --- of code blocks - ---@type boolean - __inside_code_block = false, - - --- Buffer types to ignore. - ---@type string[]? - buf_ignore = { "nofile" }, - - --- Callbacks to execute during various states of the - --- plugin - callbacks = { - --- Called when attaching to a buffer(while the plugin - --- is enabled). - ---@param buf integer Buffer ID - ---@param win integer Window ID - on_enable = function (buf, win) end, - - --- Called when disabling the plugin(either globally - --- or in a buffer). - ---@param buf integer Buffer ID - ---@param win integer Window ID - on_disable = function (buf, win) end, - - --- Called when changing "Vim modes"(while the plugin - --- is enabled). - ---@param buf integer Buffer ID - ---@param win integer Window ID - ---@param mode string Mode short name - on_mode_change = function (buf, win, mode) end, - - --- Called when entering split view - ---@param split_buf integer Buffer ID for the preview split - ---@param split_win integer Window ID for the preview split - split_enter = function (split_buf, split_win) end - }, - - --- Time in miliseconds to wait before a redraw occurs(after any - --- of the redraw events). - --- - --- Redraw events are, cursorMoved, "ModeChanged", "TextChanged"; - --- - --- Change this depending on your machine's power - ---@type integer - debounce = 50, - - --- Filetypes where the plugin is enabled - ---@type string[] - filetypes = { "markdown", "quarto", "rmd" }, - - --- Highlight groups to use. - --- Can be a list of tables that define the highlight groups. - ---@type "dynamic" | "light" | "dark" | table[] - highlight_groups = "dynamic", - - --- Vim modes where "hybrid mode" should be enabled. - ---@type string[] - hybrid_modes = nil, - - --- Tree-sitter query injections - injections = { - enable = true, - - languages = { - --- Key is the language - markdown = { - enable = true, - - --- When true, other injections are replaced - --- with the ones provided here - ---@type boolean - override = false, - - query = [[ - (section - (atx_heading)) @fold (#set! @fold) - ]] - } - } - }, - - --- Initial state of the plugin for newly attached buffers. - --- When false, automatic previews are disabled. You can then - --- enable the preview via a command. - ---@type boolean - initial_state = true, - - --- Maximum number of lines a buffer can have before only a part - --- of it is rendered, instead of the entire buffer. - ---@type integer - max_file_length = 1000, - - --- Vim modes where the preview is shown - ---@type string[] - modes = { "n", "no", "c" }, - - --- Number of lines to render on large files(when line count - --- is larger then "max_file_length"). - ---@type integer - render_distance = 100, - - --- Window configuration for the split window - ---@type table - split_conf = { - split = "right" - }, - - block_quotes = { - enable = true, - - --- Default configuration for block quotes. - default = { - --- Text to use as border for the block - --- quote. - --- Can also be a list if you want multiple - --- border types! - ---@type string | string[] - border = "โ–‹", - - --- Highlight group for "border" option. Can also - --- be a list to create gradients. - ---@type (string | string[])? - hl = "MarkviewBlockQuoteDefault" - }, - - --- Configuration for custom block quotes - callouts = { - { - --- String between "[!" & "]" - ---@type string - match_string = "ABSTRACT", - - --- Primary highlight group. Used by other options - --- that end with "_hl" when their values are nil. - ---@type string? - hl = "MarkviewBlockQuoteNote", - - --- Text to show in the preview. - ---@type string - preview = "๓ฑ‰ซ Abstract", - - --- Highlight group for the preview text. - ---@type string? - preview_hl = nil - - --- When true, adds the ability to add a title - --- to the block quote. - ---@type boolean - title = true, - - --- Icon to show before the title. - ---@type string? - icon = "๓ฑ‰ซ ", - - ---@type string | string - border = "โ–‹", - - ---@type (string | string[])? - border_hl = nil - }, - } - }, - - checkboxes = { - enable = true, - - checked = { - --- Text to show - ---@type string - text = "โœ”", - - --- Highlight group for "text" - ---@type string? - hl = "MarkviewCheckboxChecked", - - --- Highlight group to add to the body - --- of the list item. - ---@type string? - scope_hl = nil - }, - - unchecked = { - text = "โœ˜", hl = "MarkviewCheckboxUnchecked", - scope_hl = nil - }, - - --- Custom checkboxes configuration - custom = { - { - --- Text inside [] - ---@type string - match_string = "-", - - ---@type string - text = "โ—ฏ", - - ---@type string? - hl = "MarkviewCheckboxPending", - - ---@type string? - scope_hl = nil - } - } - }, - - code_blocks = { - enable = true, - - --- Icon provider for the block icons & signs. - --- - --- Possible values are, - --- โ€ข "devicons", Uses `nvim-web-devicons`. - --- โ€ข "mini", Uses `mini.icons`. - --- โ€ข "internal", Uses the internal icon provider. - --- โ€ข "", Disables icons - --- - ---@type "devicons" | "mini" | "internal" | "" - icons = "internal", - - --- Render style for the code block. - --- - --- Possible values are, - --- โ€ข "simple", Simple line highlighting. - --- โ€ข "language", Signs, icons & much more. - --- - ---@type "simple" | "language" - style = "language", - - --- Primary highlight group. - --- Used by other options that end with "_hl" when - --- their values are nil. - ---@type string - hl = "MarkviewCode", - - --- Highlight group for the info string - ---@type string[] - info_hl = "MarkviewCodeInfo", - - --- Minimum width of a code block. - ---@type integer - min_width = 60, - - --- Left & right padding amount - ---@type integer - pad_amount = 3, - - --- Character to use as whitespace - ---@type string? - pad_char = " ", - - --- Table containing various code block language names - --- and the text to show. - --- e.g. { cpp = "C++" } - ---@type { [string]: string } - language_names = nil, - - --- Direction of the language preview - ---@type "left" | "right" - language_direction = "right", - - --- Enables signs - ---@type boolean - sign = true, - - --- Highlight group for the sign - ---@type string? - sign_hl = nil - }, - - footnotes = { - enable = true, - - --- When true, uses Unicode characters to - --- fake superscript text. - ---@type boolean - superscript = true, - - --- Highlight group for the footnotes - hl = "Special" - } - - headings = { - enable = true, - - --- Amount of character to shift per heading level - ---@type integer - shift_width = 1, - - heading_1 = { - style = "simple", - - --- Background highlight group. - ---@type string - hl = "MarkviewHeading1" - }, - heading_2 = { - style = "icon", - - --- Primary highlight group. Used by other - --- options that end with "_hl" when their - --- values are nil. - ---@type string - hl = "MarkviewHeading2", - - --- Character used to shift/indent the heading - ---@type string - shift_char = " ", - - --- Highlight group for the "shift_char" - ---@type string? - shift_hl = "MarkviewHeading2Sign", - - --- Text to show on the signcolumn - ---@type string? - sign = "๓ฐŒ• ", - - --- Highlight group for the sign - ---@type string? - sign_hl = "MarkviewHeading2Sign", - - --- Icon to show before the heading text - ---@type string? - icon = "๓ฐผ ", - - --- Highlight group for the Icon - ---@type string? - icon_hl = "MarkviewHeading2" - }, - heading_3 = { - style = "label", - - --- Alignment of the heading. - ---@type "left" | "center" | "right" - align = "center", - - --- Primary highlight group. Used by other - --- options that end with "_hl" when their - --- values are nil. - ---@type string - hl = "MarkviewHeading3", - - --- Left corner, Added before the left padding - ---@type string? - corner_left = nil, - - --- Left padding, Added before the icon - ---@type string? - padding_left = nil, - - --- Right padding, Added after the heading text - ---@type string? - padding_right = nil, - - --- Right corner, Added after the right padding - ---@type string? - corner_right = nil, - - ---@type string? - corner_left_hl = nil, - ---@type string? - padding_left_hl = nil, - - ---@type string? - padding_right_hl = nil, - ---@type string? - corner_right_hl = nil, - - --- Text to show on the signcolumn. - ---@type string? - sign = "๓ฐŒ• ", - - --- Highlight group for the sign. - ---@type string? - sign_hl = "MarkviewHeading2Sign", - - --- Icon to show before the heading text. - ---@type string? - icon = "๓ฐผ ", - - --- Highlight group for the Icon. - ---@type string? - icon_hl = "MarkviewHeading2" - }, - heading_4 = {}, - heading_5 = {}, - heading_6 = {}, - - setext_1 = { - style = "simple", - - --- Background highlight group. - ---@type string - hl = "MarkviewHeading1" - } - setext_2 = { - style = "decorated", - - --- Text to show on the signcolumn. - ---@type string? - sign = "๓ฐŒ• ", - - --- Highlight group for the sign. - ---@type string? - sign_hl = "MarkviewHeading2Sign", - - --- Icon to show before the heading text. - ---@type string? - icon = " ๎ชซ ", - - --- Highlight group for the Icon. - ---@type string? - icon_hl = "MarkviewHeading2", - - --- Bottom border for the heading. - ---@type string? - border = "โ–‚", - - --- Highlight group for the bottom border. - ---@type string? - border_hl = "MarkviewHeading2" - } - }, - - horizontal_rules = { - enable = true, - - parts = { - { - type = "repeating", - - --- Amount of time to repeat the text - --- Can be an integer or a function. - --- - --- If the value is a function the "buffer" ID - --- is provided as the parameter. - ---@type integer | fun(buffer: integer): nil - repeat_amount = function (buffer) - local textoff = vim.fn.getwininfo(vim.api.nvim_get_current_win())[1].textoff; - - return math.floor((vim.o.columns - textoff - 3) / 2); - end, - - --- Text to repeat. - ---@type string - text = "โ”€", - - --- Highlight group for this part. - --- Can be a string(for solid color) or a - --- list of string(for gradient) - ---@type string[] | string - hl = { - "MarkviewGradient1", "MarkviewGradient2", "MarkviewGradient3", "MarkviewGradient4", "MarkviewGradient5", "MarkviewGradient6", "MarkviewGradient7", "MarkviewGradient8", "MarkviewGradient9", "MarkviewGradient10" - }, - - --- Placement direction of the gradient. - ---@type "left" | "right" - direction = "left" - }, - { - type = "text", - text = " ๎ชช ", - - ---@type string? - hl = "MarkviewGradient10" - } - } - }, - - html = { - enable = true, - - --- Tag renderer for tags that have an - --- opening & closing tag. - tags = { - enable = true, - - --- Default configuration - default = { - --- When true, the tag is concealed. - ---@type boolean - conceal = false, - - --- Highlight group for the text inside - --- of the tag - ---@type string? - hl = nil - }, - - --- Configuration for specific tag(s). - --- The key is the tag and the value is the - --- used configuration. - configs = { - b = { conceal = true, hl = "Bold" }, - u = { conceal = true, hl = "Underlined" }, - } - }, - - --- HTML entity configuration - entities = { - enable = true, - - --- Highlight group for the rendered entity. - ---@type string? - hl = nil - } - }, - - inline_codes = { - enable = true, - - --- Primary highlight group. Used by other - --- options that end with "_hl" when their - --- values are nil. - ---@type string - hl = "MarkviewHeading3", - - --- Left corner, Added before the left padding. - ---@type string? - corner_left = nil, - - --- Left padding, Added before the text. - ---@type string? - padding_left = nil, - - --- Right padding, Added after the text. - ---@type string? - padding_right = nil, - - --- Right corner, Added after the right padding. - ---@type string? - corner_right = nil, - - ---@type string? - corner_left_hl = nil, - ---@type string? - padding_left_hl = nil, - - ---@type string? - padding_right_hl = nil, - ---@type string? - corner_right_hl = nil, - }, - - latex = { - enable = true, - - --- Bracket conceal configuration. - --- Shows () in specific cases - brackets = { - enable = true, - - --- Highlight group for the () - ---@type string - hl = "@punctuation.brackets" - }, - - --- LaTeX blocks renderer - block = { - enable = true, - - --- Highlight group for the block - ---@type string - hl = "Code", - - --- Virtual text to show on the bottom - --- right. - --- First value is the text and second value - --- is the highlight group. - ---@type string[] - text = { "๎š› LaTeX ", "Special" } - }, - - --- Configuration for inline LaTeX maths - inline = { - enable = true - }, - - --- Configuration for operators(e.g. "\frac{1}{2}") - operators = { - enable = true, - configs = { - sin = { - --- Configuration for the extmark added - --- to the name of the operator(e.g. "\sin"). - --- - --- see `nvim_buf_set_extmark()` for all the - --- options. - ---@type table - operator = { - conceal = "", - virt_text = { { "๐šœ๐š’๐š—", "Special" } } - }, - - --- Configuration for the arguments of this - --- operator. - --- Item index is used to apply the configuration - --- to a specific argument - ---@type table[] - args = { - { - --- Extmarks are only added - --- if a config for it exists. - - --- Configuration for the extmark - --- added before this argument. - --- - --- see `nvim_buf_set_extmark` for more. - before = {}, - - --- Configuration for the extmark - --- added after this argument. - --- - --- see `nvim_buf_set_extmark` for more. - after = {}, - - --- Configuration for the extmark - --- added to the range of text of - --- this argument. - --- - --- see `nvim_buf_set_extmark` for more. - scope = {} - } - } - } - } - }, - - --- Configuration for LaTeX symbols. - symbols = { - enable = true, - - --- Highlight group for the symbols. - ---@type string? - hl = "@operator.latex", - - --- Allows adding/modifying symbol definitions. - overwrite = { - --- Symbols can either be strings or functions. - --- When the value is a function it receives the buffer - --- id as the parameter. - --- - --- The resulting string is then used. - ---@param buffer integer. - today = function (buffer) - return os.date("%d %B, %Y"); - end - }, - - --- Create groups of symbols to only change their - --- appearance. - groups = { - { - --- Matcher for this group. - --- - --- Can be a list of symbols or a function - --- that takes the symbol as the parameter - --- and either returns true or false. - --- - ---@type string[] | fun(symbol: string): boolean - match = { "lim", "today" }, - - --- Highlight group for this group. - ---@type string - hl = "Special" - } - } - }, - - subscript = { - enable = true, - - hl = "MarkviewLatexSubscript" - }, - - superscript = { - enable = true, - - hl = "MarkviewLatexSuperscript" - } - }, - - links = { - enable = true, - - --- Configuration for normal links - hyperlinks = { - enable = true, - - --- When true, link texts that start with an emoji - --- won't have an icon in front of them. - ---@type boolean - __emoji_link_compatability = true, - - --- Icon to show. - ---@type string? - icon = "๓ฐŒท ", - - --- Highlight group for the "icon". - ---@type string? - hl = "MarkviewHyperlink", - - --- Configuration for custom links. - custom = { - { - --- Pattern of the address. - ---@type string - match_string = "stackoverflow%.com", - - --- Icon to show. - ---@type string? - icon = "๏…ฌ ", - - --- Highlight group for the icon - ---@type string? - hl = nil - }, - { match_string = "stackexchange%.com", icon = "๏† " }, - } - }, - - images = { - enable = true, - - --- When true, link texts that start with an emoji - --- won't have an icon in front of them. - ---@type boolean - __emoji_link_compatability = true, - - --- Icon to show. - ---@type string? - icon = "๓ฐฅถ ", - - --- Highlight group for the "icon". - ---@type string? - hl = "MarkviewImageLink", - - --- Configuration for custom image links. - custom = { - { - --- Pattern of the address. - ---@type string - match_string = "%.svg$", - - --- Icon to show. - ---@type string? - icon = "๓ฐœก ", - - --- Highlight group for the icon - ---@type string? - hl = nil - }, - } - }, - - emails = { - enable = true, - - --- Icon to show. - ---@type string? - icon = "๏• ", - - --- Highlight group for the "icon". - ---@type string? - hl = "MarkviewEmail" - - --- Configuration for custom emails - custom = {} - }, - - internal_links = { - enable = true, - - --- When true, link texts that start with an emoji - --- won't have an icon in front of them. - __emoji_link_compatability = true, - - --- Icon to show. - ---@type string? - icon = "๎ญž ", - - --- Highlight group for the "icon". - ---@type string? - hl = "MarkviewHyperlink", - - --- Configuration for custom internal links - custom = {} - } - }, - - list_items = { - enable = true, - - --- Amount of spaces that defines an indent - --- level of the list item. - ---@type integer - indent_size = 2, - - --- Amount of spaces to add per indent level - --- of the list item. - ---@type integer - shift_width = 4, - - marker_minus = { - add_padding = true, - - text = "๎ฉฑ", - hl = "MarkviewListItemMinus" - }, - marker_plus = { - add_padding = true, - - text = "๎ชซ", - hl = "MarkviewListItemPlus" - }, - marker_star = { - add_padding = true, - - text = "๎ชฉ", - hl = "MarkviewListItemStar" - }, - - --- These items do NOT have a text or - --- a hl property! - - --- n. Items - marker_dot = { - add_padding = true - }, - - --- n) Items - marker_parenthesis = { - add_padding = true - } - }, - - tables = { - enable = true, - - --- Parts for the table border. - ---@type { [string]: string[] } - text = { - top = { "โ•ญ", "โ”€", "โ•ฎ", "โ”ฌ" }, - header = { "โ”‚", "โ”‚", "โ”‚" }, - separator = { "โ”œ", "โ”€", "โ”ค", "โ”ผ" }, - row = { "โ”‚", "โ”‚", "โ”‚" }, - bottom = { "โ•ฐ", "โ”€", "โ•ฏ", "โ”ด" }, - - overlap = { "โ”œ", "โ”€", "โ”ค", "โ”ผ" }, - - align_left = "โ•ผ", - align_right = "โ•พ", - align_center = { "โ•ด", "โ•ถ",} - }, - - --- Highlight groups for the "parts". - ---@type { [string]: string[] } - hls = { - top = { "TableHeader", "TableHeader", "TableHeader", "TableHeader" }, - header = { "TableHeader", "TableHeader", "TableHeader" }, - separator = { "TableHeader", "TableHeader", "TableHeader", "TableHeader" }, - row = { "TableBorder", "TableBorder", "TableBorder" }, - bottom = { "TableBorder", "TableBorder", "TableBorder", "TableBorder" }, - - overlap = { "TableBorder", "TableBorder", "TableBorder", "TableBorder" }, - - align_left = "TableAlignLeft", - align_right = "TableAlignRight", - align_center = { "TableAlignCenter", "TableAlignCenter",} - }, - - --- Minimum width of a table cell - ---@type integer? - col_min_width = 5, - - --- When true, top & bottom borders aren't drawn - ---@type boolean - block_decorator = true, - - --- When true, top & bottom borders are made with - --- virtual lines instead of virtual text. - ---@type boolean - use_virt_lines = true - } - } -< - -============================================================================== -Configuration: Block quotes *markview.nvim-c-block_quotes* - ->lua - block_quotes = { - enable = true, - - --- Default configuration for block quotes. - default = { - --- Text to use as border for the block - --- quote. - --- Can also be a list if you want multiple - --- border types! - ---@type string | string[] - border = "โ–‹", - - --- Highlight group for "border" option. Can also - --- be a list to create gradients. - ---@type (string | string[])? - hl = "MarkviewBlockQuoteDefault" - }, - - --- Configuration for custom block quotes - callouts = { - { - --- String between "[!" & "]" - ---@type string - match_string = "ABSTRACT", - - --- Primary highlight group. Used by other options - --- that end with "_hl" when their values are nil. - ---@type string? - hl = "MarkviewBlockQuoteNote", - - --- Text to show in the preview. - ---@type string - preview = "๓ฑ‰ซ Abstract", - - --- Highlight group for the preview text. - ---@type string? - preview_hl = nil, - - --- When true, adds the ability to add a title - --- to the block quote. - ---@type boolean - title = true, - - --- Icon to show before the title. - ---@type string? - icon = "๓ฑ‰ซ ", - - ---@type string | string - border = "โ–‹", - - ---@type (string | string[])? - border_hl = nil - }, - } - } -< - -`markview.nvim` comes with the following block quote types by default. - -From `Github`, - - - Note - - Tip - - Important - - Warning - - Caution - -From `Obsidian`, - - - Abstract, Summary, Tldr - - Todo, Info - - Success, Check, Done - - Question, Help, Faq - - Failure, Fail, Missing - - Danger, Error - - Bug - - Example - - Quote, Cite - - Hint - - Attention - -Usage example ->md - >[!Custom] A custom title - > Some text -< -Results in, ->txt - โ–‹ ๓ฐ ณ A custom title - โ–‹ Some text -< ------------------------------------------------------------------------------- -Creating a new callout - -Creating a new callout is pretty simple. - -Just set the match string to the text to use as the identifier for the -callout. It is `case-insensitive` so keep that in mind. - -Now you set the `border`, this is required. - -If you want to support titles(like in `Obsidian`) then set the `custom_title` -to true. - -Note: You will also need to set the `custom_icon` option to show the -correct icon. ->lua - callouts = { - { - --- String between "[!" & "]" - ---@type string - match_string = "ABSTRACT", - - --- Primary highlight group. Used by other options - --- that end with "_hl" when their values are nil. - ---@type string? - hl = "MarkviewBlockQuoteNote", - - --- Text to show in the preview. - ---@type string - preview = "๓ฑ‰ซ Abstract", - - --- Highlight group for the preview text. - ---@type string? - preview_hl = nil, - - --- When true, adds the ability to add a title - --- to the block quote. - ---@type boolean - title = true, - - --- Icon to show before the title. - ---@type string? - icon = "๓ฑ‰ซ ", - - ---@type string | string - border = "โ–‹", - - ---@type (string | string[])? - border_hl = nil - }, - } -< ------------------------------------------------------------------------------- -Creating aliases for a callout - -You can also set aliases for a callout. ->lua - callouts = { - { - --- A list of aliases - match_string = { "Abstract", "tldr", "Summary" }, - - callout_preview = "๏ฉ Abstract", - callout_preview_hl = "MarkviewBlockQuoteWarn", - border = "โ–‹", border_hl = "MarkviewBlockQuoteWarn" - } - } -< - -Now for either `Abstract`, `tldr` or `Summary` the plugin will show -`๏ฉ Abstract`. - ------------------------------------------------------------------------------- -Gradient borders - -The plugin also supports multi-colored/gradient borders for block quotes. ->lua - callouts = { - { - --- ... Other options - border = "โ–‹", - border_hl = { - "Gradient1", "Gradient2", "Gradient3", "Gradient4", - "Gradient5", "Gradient6", "Gradient7", "Gradient8", - "Gradient9", "Gradient10" - } - } - } -< -This also works with the `border`! ->lua - callouts = { - { - --- ... Other options - border = { "โ–‹", "โ–Œ", "โ–", "โ–Ž", "โ–" } - } - } -< -============================================================================== -checkboxes *markview.nvim-c-checkboxes* - -`markview.nvim` supports the default checkboxes along with the option to -create your own checkboxes! ->lua - checkboxes = { - enable = true, - - checked = { - --- Text to show - ---@type string - text = "โœ”", - - --- Highlight group for "text" - ---@type string? - hl = "MarkviewCheckboxChecked", - - --- Highlight group to add to the body - --- of the list item. - ---@type string? - scope_hl = nil - }, - - unchecked = { - text = "โœ˜", hl = "MarkviewCheckboxUnchecked", - scope_hl = nil - }, - - --- Custom checkboxes configuration - custom = { - { - --- Text inside [] - ---@type string - match_string = "-", - - ---@type string - text = "โ—ฏ", - - ---@type string? - hl = "MarkviewCheckboxPending", - - ---@type string? - scope_hl = nil - } - } - } -< - ------------------------------------------------------------------------------- -Creating a new checkbox state - -The plugin supports custom checkbox states that can be made via the `custom` -option. ->lua - custom = { - { - --- Text inside of [] - match_string = "p" - text = "๎ญฌ", - hl = "CheckboxChecked", - - scope_hl = "CheckboxChecked" - } - } -< -============================================================================== -Code blocks *markview.nvim-c-code_blocks* - -`markview.nvim` provides 3 different ways to render fenced code blocks. - -Here's the default configuration. ->lua - code_blocks = { - enable = true, - - --- Icon provider for the block icons & signs. - --- - --- Possible values are, - --- โ€ข "devicons", Uses `nvim-web-devicons`. - --- โ€ข "mini", Uses `mini.icons`. - --- โ€ข "internal", Uses the internal icon provider. - --- โ€ข "", Disables icons - --- - ---@type "devicons" | "mini" | "internal" | "" - icons = "internal", - - --- Render style for the code block. - --- - --- Possible values are, - --- โ€ข "simple", Simple line highlighting. - --- โ€ข "minimal", Box surrounding the code block. - --- โ€ข "language", Signs, icons & much more. - --- - ---@type "simple" | "minimal" | "language" - style = "language", - - --- Primary highlight group. - --- Used by other options that end with "_hl" when - --- their values are nil. - ---@type string - hl = "MarkviewCode", - - --- Highlight group for the info string - ---@type string - info_hl = "MarkviewCodeInfo", - - --- Minimum width of a code block. - ---@type integer - min_width = 40, - - --- Left & right padding amount - ---@type integer - pad_amount = 3, - - --- Character to use as whitespace - ---@type string? - pad_char = " ", - - --- Table containing various code block language names - --- and the text to show. - --- e.g. { cpp = "C++" } - ---@type { [string]: string } - language_names = nil, - - --- Direction of the language preview - ---@type "left" | "right" - language_direction = "right", - - --- Enables signs - ---@type boolean - sign = true, - - --- Highlight group for the sign - ---@type string? - sign_hl = nil - } -< ------------------------------------------------------------------------------- -Style: simple - -Adds a background to the lines within the code block. ->lua - code_blocks = { - enable = true, - style = "simple", - - hl = "Code", -- Highlight group to use for the background - - info_hl = "MarkviewCodeInfo", -- Highlight group for the info string - - --- Table containing various code block language names - --- and the text to show. - --- e.g. { cpp = "C++" } - ---@type { [string]: string } - language_names = nil, - - --- Direction of the language preview - ---@type "left" | "right" - language_direction = "right", - - --- Enables signs - ---@type boolean - sign = true, - - --- Highlight group for the sign - ---@type string? - sign_hl = nil - } -< ------------------------------------------------------------------------------- -Style: language - -Creates a box around the code and shows the language(with icons) & the info -string(wrapped). ->lua - code_blocks = { - enable = true, - style = "language", - icons = true, -- Used for disable the icons - - hl = "Code", -- Highlight group to use for the background - -- Highlight group for the info string - -- - -- ```lua This is an info string - -- ```` - info_hl = "CodeInfo", - -- Highlight group for the language name - language_hl = nil, - -- A table whose keys are the text in the code block and the value - -- is the text to show - language_names = { - ["cpp"] = "C++" - } - - min_width = 70, -- Minimum width of the code block - pad_char = " ", -- Character used for paddings and empty cells - pad_amount = 3, -- Number of `pad_char` to add before & after the code - - -- Direction of the language string - -- Possible values: "left" | "right" - language_direction = "left", - - -- When true, the icon of that language is shown on the signcolumn - -- where the code block starts - sign = true, - -- Highlight group for the signs, when nil the icon's highlight - -- group is used - sign_hl = nil - } -< -============================================================================== -Escaped characters *markview.nvim-c-escaped* - -`markview.nvim` can hide the `\` in escaped characters. Here's a simple -example to show what it does. ->md - \& โ†’ & -< -Currently it only has one option. ->lua - escaped = { - enable = true - } -< -============================================================================== -Footnotes *markview.nvim-c-footnotes* - -`markview.nvim` comes with footnote support. Here's an example, ->md - This is a [^footnote]. - โ†“ - This is a แถ แต’แต’แต—โฟแต’แต—แต‰. -< -Here's the configuration table for it, ->lua - footnotes = { - enable = true, - - -- When true, uses various Unicode characters to mimic superscript - -- text - use_unicode = true - } -< -============================================================================== -Headings *markview.nvim-c-headings* - -`markview.nvim` comes with various customisation options for the headings. ->lua - headings = { - enable = true, - - --- Amount of character to shift per heading level - ---@type integer - shift_width = 1, - - heading_1 = { - style = "simple", - - --- Background highlight group. - ---@type string - hl = "MarkviewHeading1" - }, - heading_2 = { - style = "icon", - - --- Primary highlight group. Used by other - --- options that end with "_hl" when their - --- values are nil. - ---@type string - hl = "MarkviewHeading2", - - --- Character used to shift/indent the heading - ---@type string - shift_char = " ", - - --- Highlight group for the "shift_char" - ---@type string? - shift_hl = "MarkviewHeading2Sign", - - --- Text to show on the signcolumn - ---@type string? - sign = "๓ฐŒ• ", - - --- Highlight group for the sign - ---@type string? - sign_hl = "MarkviewHeading2Sign", - - --- Icon to show before the heading text - ---@type string? - icon = "๓ฐผ ", - - --- Highlight group for the Icon - ---@type string? - icon_hl = "MarkviewHeading2" - }, - heading_3 = { - style = "label", - - --- Alignment of the heading. - ---@type "left" | "center" | "right" - align = "center", - - --- Primary highlight group. Used by other - --- options that end with "_hl" when their - --- values are nil. - ---@type string - hl = "MarkviewHeading3", - - --- Left corner, Added before the left padding - ---@type string? - corner_left = "๎‚ฒ", - - --- Left padding, Added before the icon - ---@type string? - padding_left = "๎ƒ– ", - - --- Right padding, Added after the heading text - ---@type string? - padding_right = " ๎ƒ—", - - --- Right corner, Added after the right padding - ---@type string? - corner_right = "๎‚ฐ", - - ---@type string? - corner_left_hl = "MarkviewHeading3Sign", - ---@type string? - padding_left_hl = nil, - - ---@type string? - padding_right_hl = nil, - ---@type string? - corner_right_hl = "MarkviewHeading3Sign", - - --- Text to show on the signcolumn. - ---@type string? - sign = "๓ฐŒ• ", - - --- Highlight group for the sign. - ---@type string? - sign_hl = "MarkviewHeading3Sign", - - --- Icon to show before the heading text. - ---@type string? - icon = "", - - --- Highlight group for the Icon. - ---@type string? - icon_hl = "MarkviewHeading3" - }, - heading_4 = {}, - heading_5 = {}, - heading_6 = {}, - - setext_1 = { - style = "simple", - - --- Background highlight group. - ---@type string - hl = "MarkviewHeading1" - }, - setext_2 = { - style = "decorated", - - --- Text to show on the signcolumn. - ---@type string? - sign = "๓ฐŒ• ", - - --- Highlight group for the sign. - ---@type string? - sign_hl = "MarkviewHeading2Sign", - - --- Icon to show before the heading text. - ---@type string? - icon = " ๎ชซ ", - - --- Highlight group for the Icon. - ---@type string? - icon_hl = "MarkviewHeading2", - - --- Bottom border for the heading. - ---@type string? - border = "โ–‚", - - --- Highlight group for the bottom border. - ---@type string? - border_hl = "MarkviewHeading2" - } - } -< ------------------------------------------------------------------------------- - -Each heading type can be configured individually. There are 2 types of -headings in markdown ->md - # ATX heading - - Setext heading - -------------- -< ------------------------------------------------------------------------------- -ATX Headings - -These are headings that start with one or more `#`. Their configuration can -vary dependinh on what style is used. - -Currently available styles for atx headings are, - - - simple - - label - - icon - -Style: simple ~ - -Highlights the line containing the heading. ->lua - heading_1 = { - style = "simple", - hl = "Heading1" - } -< -Style: label ~ - -Shows the heading like a label. Also hides the `#`. Can also shift the label -based on the heading level if `shift_width` is set. ->lua - heading_2 = { - style = "label", - -- Alignment of the label - -- Possible values: "left" | "center" | "right" - align = "left", - - -- Default highlight group - -- Used for options that end with "_hl" - hl = "Heading2", - - -- Sign to show on the sigmcolumn - sign = nil, - -- Highlight group for the sign - sign_hl = nil, - - -- Various parts to use for the label - corner_left = nil, - padding_left = nil, - - -- Icon is added before the text itself - icon = nil, - - padding_right = nil, - corner_right = nil, - - -- Highlight groups for the various parts - -- Fallback to "hl" if the value is nil - corner_left_hl = nil, - padding_left_hl = nil, - - icon_hl = nil, - - padding_right_hl = nil, - corner_right_hl = nil - } -< -You can see here how various options are rendered. ->txt - padding_left โ”€โ” โ”Œโ”€โ”€ padding_right - corner_left โ”€โ”โ”‚ โ”‚โ”Œโ”€ corner_right - โ–ˆ โ—‰ Text โ–ˆ - โ””โ”€ icon -< -Style: icon ~ - -Indents the heading text, hides the `#` and shows an icon. Can also shift the -text if `shift_width` is set. ->lua - heading_3 = { - style = "icon", - - -- Character used for shifting the text - shift_char = " ", - -- Highlight group for the shift_char - shift_hl = nil, - - -- Sign to show on the sigmcolumn - sign = nil, - -- Highlight group for the sign - sign_hl = nil, - - -- Icon is added before the text itself - icon = nil, - icon_hl = nil, - } -< ------------------------------------------------------------------------------- -Setext Headings - -These are headings that use `-` or `=` under the heading text. - -They currently have 2 styles, - - - simple - - decorated - -Style: simple ~ - -Adds a background to the lines of heading. ->lua - setext_1 = { - style = "simple", - hl = "Heading1" - } -< - -Style: decorated ~ - -Adds icons to the headings(like in github) and adds a decorated line below the -heading text. - -This also supports signs! ->lua - { - style = "decorated", - - -- Highlight group used by the icon & line - -- when "icon_hl" or "line_hl" isn't set - hl = nil, - - sign = nil, - sign_hl = nil, - - icon = "๏‘Œ ", - icon_hl = nil, - - line = "โ”", - line_hl = nil - } -< -============================================================================== -Horizontal rules *markview.nvim-c-hrs* - -`markview.nvim` allows creating your own custom horizontal rules with parts. ->lua - horizontal_rules = { - enable = true, - parts = {} - } -< -Currently available parts are - - - repeating - - text - ------------------------------------------------------------------------------- -Part: repeating - -Repeats the provided text by the specified number. Also supports `gradients`. ->lua - parts = { - { - type = "repeating", - - -- The number of times to repeat text - -- Can also be a integer value - -- ```lua - -- repeat_amount = 10, - -- ``` - repeat_amount = function (buf) - return 10; - end, - - -- Text to repeat - text = "-", - - -- Highlight groups to use on the final string - -- When the value is a string it is used as a solid color - hl = { "Gradient1", "Gradient2", "Gradient3", "Gradient4" }, - - -- Direction from where the gradient is applied for - direction = "left" - } - } -< -Here's a simple diagram to show how the gradient is applied to a text. ->txt - Gradient4 โ” - Gradient3 โ”โ”‚ - Gradient2 โ”โ”‚โ”‚ direction = "left" - Gradient1 โ”โ”‚โ”‚โ”‚ - โ”‚โ”‚โ”‚โ”‚โ”‚ - โ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•ŒSome text with a ๐Ÿ˜‘!โ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œ - โ”‚โ”‚โ”‚โ”‚โ”‚ - โ”‚โ”‚โ”‚โ”‚โ”” Gradient1 - direction = "right" โ”‚โ”‚โ””โ”ด Gradient2 - โ”‚โ””โ”€ Gradient3 - โ””โ”€Gradient4 -< ------------------------------------------------------------------------------- -Part: text - -Shows the provided text with the specified highlight group. ->lua - parts = { - { - type = "text", - - text = "Some text", - hl = "Special" - } - } -< -============================================================================== -HTML *markview.nvim-c-html* - -`markview.nvim` comes with basic HTML support. It is limited by design as it's -much easier to implament and it makes more sense to use them inside of text -rather then writing large chunks of HTML between lines. ->md - โœ” This works - hi - - โœ– This doesn't work - - hi - -< -`markview.nvim` also supports `HTML entities`! ->md - ∠ โ†’ โˆ  -< -Configuration table, ->lua - html = { - enable = true, - - tags = { - enable = true, - - default = { - conceal = false, -- If true, the tags are hidden - hl = nil -- Highlight group for the text - }, - - -- The key is the tag - -- The value is a table with 2 properties - -- conceal, If true the tag is hidden - -- hl, Highlight group for the text within the tag - configs = { - b = { conceal = true, hl = "Bold" } - } - }, - - entities = { - enable = true, - -- Highlight group for the entity - hl = nil - } - } -< -============================================================================== -Inline codes *markview.nvim-c-inline_codes* - -You can add paddings & other similar decorations to inline code via this -plugin. ->lua - inline_codes = { - enable = true, - - hl = "InlineCode", - - corner_left = " ", - padding_left = nil, - - padding_right = nil, - corner_right = " ", - - -- Highlight groups for the various parts - -- Fallback to "hl" if the value is nil - corner_left_hl = nil, - padding_left_hl = nil, - - padding_right_hl = nil, - corner_right_hl = nil - } -< -============================================================================== -LaTeX *markview.nvim-c-latex* - -`markview.nvim` comes with basic LaTeX support. ->lua - latex = { - enable = true, - - --- Bracket conceal configuration. - --- Shows () in specific cases - brackets = { - enable = true, - - --- Highlight group for the () - ---@type string - hl = "@punctuation.brackets" - }, - - --- LaTeX blocks renderer - block = { - enable = true, - - --- Highlight group for the block - ---@type string - hl = "Code", - - --- Virtual text to show on the bottom - --- right. - --- First value is the text and second value - --- is the highlight group. - ---@type string[] - text = { "๎š› LaTeX ", "Special" } - }, - - --- Configuration for inline LaTeX maths - inline = { - enable = true - }, - - --- Configuration for operators(e.g. "\frac{1}{2}") - operators = { - enable = true, - configs = { - sin = { - --- Configuration for the extmark added - --- to the name of the operator(e.g. "\sin"). - --- - --- see `nvim_buf_set_extmark()` for all the - --- options. - ---@type table - operator = { - conceal = "", - virt_text = { { "๐šœ๐š’๐š—", "Special" } } - }, - - --- Configuration for the arguments of this - --- operator. - --- Item index is used to apply the configuration - --- to a specific argument - ---@type table[] - args = { - { - --- Extmarks are only added - --- if a config for it exists. - - --- Configuration for the extmark - --- added before this argument. - --- - --- see `nvim_buf_set_extmark` for more. - before = {}, - - --- Configuration for the extmark - --- added after this argument. - --- - --- see `nvim_buf_set_extmark` for more. - after = {}, - - --- Configuration for the extmark - --- added to the range of text of - --- this argument. - --- - --- see `nvim_buf_set_extmark` for more. - scope = {} - } - } - } - } - }, - - --- Configuration for LaTeX symbols. - symbols = { - enable = true, - - --- Highlight group for the symbols. - ---@type string? - hl = "@operator.latex", - - --- Allows adding/modifying symbol definitions. - overwrite = { - --- Symbols can either be strings or functions. - --- When the value is a function it receives the buffer - --- id as the parameter. - --- - --- The resulting string is then used. - ---@param buffer integer. - today = function (buffer) - return os.date("%d %B, %Y"); - end - }, - - --- Create groups of symbols to only change their - --- appearance. - groups = { - { - --- Matcher for this group. - --- - --- Can be a list of symbols or a function - --- that takes the symbol as the parameter - --- and either returns true or false. - --- - ---@type string[] | fun(symbol: string): boolean - match = { "lim", "today" }, - - --- Highlight group for this group. - ---@type string - hl = "Special" - } - } - }, - - subscript = { - enable = true, - - hl = "MarkviewLatexSubscript" - }, - - superscript = { - enable = true, - - hl = "MarkviewLatexSuperscript" - } - } -< ------------------------------------------------------------------------------- -LaTeX: brackets - -Hides LaTeX brackets(unless in specific situations). ->lua - brackets = { - enable = true, - hl = "@punctuation.brackets" - }, -< ------------------------------------------------------------------------------- -LaTeX: block - -`markview.nvim` allows highlighting blocks of LaTeX(text inside "$$...$$"). ->lua - block = { - enable = true, - - -- Number of spaces to add before the lines - pad_amount = 3, - - -- Highlight group for the background - hl = "Code", - -- { text, highlight group } that is shown on the bottom right - -- of the block - text = { "๎š› Latex ", "Special" } - }, -< -Note: Due to the nature of LaTeX blocks it is currently not possible to -make them work like fenced code blocks in markdown. - ------------------------------------------------------------------------------- - LaTeX: symbols ->lua - symbols = { - enable = true, - - -- A table whose keys are the text after \ - -- and the values are the symbol to show - custom = { - equiv = "โ‰ก" - } - } -< -Usage, ->md - $a \equiv b$ โ†’ a โ‰ก b -< -============================================================================== -Links *markview.nvim-c-links* - -`markview.nvim` supports hyperlinks, images & emails. ->lua - links = { - enable = true, - - hyperlinks = { - enable = true, - - icon = "๓ฐŒท ", - hl = "MarkviewHyperlink", - - custom = {} - }, - images = { - enable = true, - - icon = "๓ฐฅถ ", - hl = "MarkviewImageLink", - - custom = {} - }, - emails = { - enable = true, - - icon = "๏• ", - hl = "MarkviewEmail" - - custom = {} - } - } -< ------------------------------------------------------------------------------- -Link options - -Each link type has the following options. ->lua - hyperlinks = { - enable = true, - - hl = "MarkviewHyperlink", - - icon = "๓ฐŒท ", - icon_hl = nil, - - corner_left = nil, - padding_left = nil, - - padding_right = nil, - corner_right = nil, - - corner_left_hl = nil, - padding_left_hl = nil, - - padding_right_hl = nil, - corner_right_hl = nil - - custom = {} - } -< ------------------------------------------------------------------------------- -Links: custom - -You can customise how links look based on their address. ->lua - hyperlinks = { - custom = { - { - match_string = "^https:", - - hl = "Hyperlink", - - icon = "๎ฌ ", - icon_hl = nil, - - corner_left = nil, - padding_left = nil, - - padding_right = nil, - corner_right = nil, - - corner_left_hl = nil, - padding_left_hl = nil, - - padding_right_hl = nil, - corner_right_hl = nil - } - } - } -< -============================================================================== -List items *markview.nvim-c-list_items* - -`markview.nvim` supports links with custom markers with indentations! ->lua - list_items = { - enable = true, - - -- The number of spaces per level of list items - indent_size = 2, - - -- The number of spaces added per list level - shift_width = 4, - - marker_minus = { - -- When true, paddings are added to list items - add_padding = true, - - text = "๎ฉฑ", - hl = "MarkviewListItemMinus" - }, - - marker_plus = { - add_padding = true, - - text = "๎ชซ", - hl = "MarkviewListItemPlus" - }, - - marker_star = { - add_padding = true, - - text = "๎ชฉ", - hl = "MarkviewListItemStar" - }, - - marker_dot = { - -- 1. type list items - -- These don't support text & hl - add_padding = true - }, - - marker_parenthasis = { - -- 1) type list items - -- These don't support text & hl - add_padding = true - }, - } -< -============================================================================== -Tables *markview.nvim-c-tables* - -`markview.nvim` supports rendering of tables. Tables support markdown -syntax, html elements & entities, escaped characters etc. ->lua - tables = { - enable = true, - - --- Parts for the table border. - ---@type { [string]: string[] } - text = { - top = { "โ•ญ", "โ”€", "โ•ฎ", "โ”ฌ" }, - header = { "โ”‚", "โ”‚", "โ”‚" }, - separator = { "โ”œ", "โ”€", "โ”ค", "โ”ผ" }, - row = { "โ”‚", "โ”‚", "โ”‚" }, - bottom = { "โ•ฐ", "โ”€", "โ•ฏ", "โ”ด" }, - - --- Used when tables are overlapping - overlap = { "โ”œ", "โ”€", "โ”ค", "โ”ผ" }, - - align_left = "โ•ผ", - align_right = "โ•พ", - align_center = { "โ•ด", "โ•ถ",} - }, - - --- Highlight groups for the "parts". - ---@type { [string]: string[] } - hls = { - top = { "TableHeader", "TableHeader", "TableHeader", "TableHeader" }, - header = { "TableHeader", "TableHeader", "TableHeader" }, - separator = { "TableHeader", "TableHeader", "TableHeader", "TableHeader" }, - row = { "TableBorder", "TableBorder", "TableBorder" }, - bottom = { "TableBorder", "TableBorder", "TableBorder", "TableBorder" }, - - overlap = { "TableHeader", "TableHeader", "TableHeader", "TableHeader" }, - - align_left = "TableAlignLeft", - align_right = "TableAlignRight", - align_center = { "TableAlignCenter", "TableAlignCenter",} - }, - - --- Minimum width of a table cell - ---@type integer? - col_min_width = 5, - - --- When true, top & bottom borders aren't drawn - ---@type boolean - block_decorator = true, - - --- When true, top & bottom borders are made with - --- virtual lines instead of virtual text. - ---@type boolean - use_virt_lines = true - } -< ------------------------------------------------------------------------------- - -If you find an issue in the help file(s), feel free to open a new issue in -the Github repository. - -Huge thanks to everyone who downloaded & starred this plugin! - -vim:ft=help:bt=help:textwidth=78:ts=4:spell: diff --git a/doc/migration.txt b/doc/migration.txt new file mode 100644 index 0000000..468aa3b --- /dev/null +++ b/doc/migration.txt @@ -0,0 +1,290 @@ +*markview.nvim-migration* Migration guides for markview.nvim + +------------------------------------------------------------------------------ +v24.x โ†’ v25.x +>diff + { + - __inside_code_block = false + + - buf_ignore = {}, + - debounce = 50, + - filetypes = {}, + - hybrid_modes = {}, + - ignore_nodes = {}, + - initial_state = true, + - max_file_length = 1000, + - modes = {}, + - render_distance = 500, + - split_conf = {}, + + preview = { + + enable = true, + + buf_ignore = {}, + + debounce = nil, + + icon_provider = "internal", + + filetypes = {}, + + hybrid_modes = {}, + + ignore_previews = {}, + + max_buf_lines = 1000, + + modes = {}, + + render_distance = { 200, 200 }, + + splitview_winopts = {} + + }, + + - block_quotes = { + - callbacks = {} + - }, + - code_blocks = { + - icons = "internal", + - language_names = {} + - }, + - headings = {}, + - horizontal_rules = {}, + - list_items = {}, + - tables = { + - col_min_width = 10 + - }, + + markdown = { + + block_quotes = { + + ["^NOTE$"] = {}, + + }, + + code_blocks = {}, + + headings = {}, + + horizontal_rules = {}, + + list_items = {}, + + tables = {} + + }, + + - injections = {}, + + - checkboxes = { + - custom = {} + - }, + - links = { + - hyperlinks = { + - __emoji_link_compatability = false, + - icon = "", hl = nil, + + - custom = {} + - }, + - images = { + - __emoji_link_compatability = false, + - icon = "", hl = nil, + + - custom = {} + - }, + - emails = { + - __emoji_link_compatability = false, + - icon = "", hl = nil, + + - custom = {} + - }, + - internal_links = { + - __emoji_link_compatability = false, + - icon = "", hl = nil, + + - custom = {} + - } + - }, + - footnotes = { + - use_unicode = true + - }, + - inline_codes = {}, + + markdown_inline = { + + checkboxes = { + + ["-"] = {} + + }, + + hyperlinks = { + + ["^neovim%.org"] = {} + + }, + + images = { + + ["%.svg"] = {} + + }, + + emails = { + + ["gmail"] = {} + + }, + + internal_links = { + + ["^neovim"] = {} + + }, + + inline_codes = {}, + + footnotes = {}, + + }, + + - html = { + - tags = {}, + - entities = {} + - }, + + html = { + + container_elements = {}, + + headings = {}, + + void_elements = {}, + + }, + + latex = { + - brackets = {}, + + parenthesis = {}, + + - block = {}, + + blocks = {}, + + - inline = {}, + + inlines = {}, + + - operators = { + - custom = {} + - }, + + commands = { + + ["sin"] = {} + + }, + + symbols = { + - overwrite = (), + - groups = {} + }, + + - subscript = {}, + + subscripts = {}, + + - superscript = {}, + + superscripts = {}, + } + } +< +โ–‹ ๐Ÿ“œ Note: +โ–‹ Some of these have backwards compatibility, but not all of them. + +`v25` introduces the following breaking changes, + + - `buf_ignore` has been moved inside of `preview`. + + - `callbacks` has been moved inside of `preview`. + + - `debounce` has been moved inside of `preview`. + + - `filetypes` has been moved inside of `preview`. + + - `hybrid_modes` has been moved inside of `prwview`. + + - `ignore_nodes` has been deprecated. Use `preview โ†’ ignore_previews` + instead. + + - `initial_state` has been deprecated. Use `preview โ†’ enable` instead. + + - `max_file_length` has been deprecated. Use `preview โ†’ max_buf_lines` + instead. + + - `modes` has been moved inside of `preview`. + + - `render_distance` has been moved inside of `preview` + + - `render_distance` options type has changed + (`integer โ†’ [ integer, integer]`). + + - `split_conf` has been deprecated. Use `preview โ†’ splitview_winopts` + instead. + + - `injections` has been deprecated. Use `queries/langauge/.scm` instead. + + - `block_quotes` has been moved inside of `markdown`. + + - `callouts` has been deprecated. The `match_string` is used as + the key for defining a new callout. + + - `code_blocks` has been moved inside of `markdown`. + + - `minimal` style is deprecated in favor of `block`. + + - `icone` has been deprecated. Use `preview โ†’ icon_provider` instead. + + - `language_names` has been deprecated. + + - `headings` has been moved inside of `markdown`. + + - `horizontal_rules` has been moved inside of `markdown`. + + - `list_items` has been moved inside of `markdown`. + + - `tables` has been moved inside of `markdown`. + + - `col_min_width` has been removed to reduce code complexity of the + renderer. + + - `inline_codes` has been moved inside of `markdown_inline`. + + - `checkboxes` has been moved inside of `markdown_inline`. + + - `custom` has been deprecated. The `match_string` is used as the key + for defining new checkbox states. + + - `links` has been deprecated. + + - `hyperlinks` has been moved inside of `markdown_inline`. + + - `icon`, `hl` has been deprecated. Use `default โ†’ icon`, + `default โ†’ hl` instead. + + - `custom` has been deprecated. The `match_string` is used as + the key for defining new checkbox states. + + - `images` has been moved inside of `markdown_inline`. + + - `icon`, `hl` has been deprecated. Use `default โ†’ icon`, + `default โ†’ hl` instead. + + - `custom` has been deprecated. The `match_string` is used as + the key for defining new checkbox states. + + - `emails` has been moved inside of `markdown_inline`. + + - `icon`, `hl` has been deprecated. Use `default โ†’ icon`, + `default โ†’ hl` instead. + + - `custom` has been deprecated. The `match_string` is used as + the key for defining new checkbox states. + + - `internal_links` has been moved inside of `markdown_inline`. + + - `icon`, `hl` has been deprecated. Use `default โ†’ icon`, + `default โ†’ hl` instead. + + - `custom` has been deprecated. The `match_string` is used as + the key for defining new checkbox states. + + - `footnotes` has been moved inside of `markdown_inline`. + + - `use_unicode` has been deprecated as it reduces readability. + + - `html โ†’ tags` has been deprecated. + + - Use `html โ†’ container_elements` for container elements(e.g. ``). + + - Use `html โ†’ headings` for headings(e.g. `

`). + + - Use `html โ†’ void_elements` for void elements(e.g. `
`). + + - `html โ†’ entities` has been deprecated. Use `markdown_inline โ†’ entities` + instead. + + - `latex โ†’ brackets` has been renamed to `latex โ†’ parenthesis`. + + - `latex โ†’ block` has been renamed to `latex โ†’ blocks`. + + - `latex โ†’ inline` has been renamed to `latex โ†’ inlines`. + + - `latex โ†’ operators` has been deprecated. Use `latex โ†’ commands` instead. + + - `custom` has been deprecated. The `match_string` is used as the key + for defining new commands. + + - `latex โ†’ symbols`, + + - `overwrite` has been deprecated due to lack of use cases. + + - `groups` has been deprecated due to not being practical. + + - `latex โ†’ subscript` has been renamed to `latex โ†’ subscripts`. + + - `latex โ†’ superscript` has been renamed to `latex โ†’ superscripts`. + + +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/presets.txt b/doc/presets.txt new file mode 100644 index 0000000..388b69b --- /dev/null +++ b/doc/presets.txt @@ -0,0 +1,107 @@ +*markview.nvim-presets* Presets for markview + +Pre-defined configurations to take inspiration from. + +------------------------------------------------------------------------------ +๐Ÿ”ฉ Usage *markview.nvim-presets.use* +>lua + local presets = require("markview.presets"); + + require("markview").setup({ + markdown = { + headings = presets.headings.glow + } + }); + + --- You can again call `setup()` to modify + --- the options without changing the preset. + require("markview").setup({ + markdown = { + headings = { shift_width = 1 } + } + }); +< +------------------------------------------------------------------------------ +๐Ÿ”– Heading presets *markview.nvim-presets.headings* + +๐Ÿ“š Use: ~ +>lua + local presets = require("markview.presets").headings; + + require("markview").setup({ + markdown = { + headings = presets.glow + } + }); +< +๐ŸŒŸ Showcase: ~ + + - glow + + - glow_center + + - slanted + + - arrowed + + - simple + + - marker + +------------------------------------------------------------------------------ +๐Ÿ”– Horizontal rules presets *markview.nvim-presets.hr* + +๐Ÿ“š Use: ~ + +>lua + local presets = require("markview.horizontal_rules").horizontal_rules; + + require("markview").setup({ + markdown = { + horizontal_rules = presets.arrowed + } + }); +< + +๐ŸŒŸ Showcase: ~ + + - thin + + - thick + + - double + + - dashed + + - dotted + + - solid + + - arrowed + +------------------------------------------------------------------------------ +๐Ÿ”– Tables presets *markview.nvim-presets.tables* + +๐Ÿ“š Use: ~ +>lua + local presets = require("markview.presets").tables; + + require("markview").setup({ + markdown = { + tables = presets.none + } + }); +< +๐ŸŒŸ Showcase: ~ + + - none + + - single + + - double + + - rounded + + - solid + +vim:ft=help:tw=78: diff --git a/doc/preview_options.txt b/doc/preview_options.txt new file mode 100644 index 0000000..d9c2597 --- /dev/null +++ b/doc/preview_options.txt @@ -0,0 +1,803 @@ +*markview.nvim-preview* Preview options for markview + + Options that change how previews are shown. +>lua + -- [ Markview | Preview options ] --------------------------------------------------------- + + --- Preview configuration for `markview.nvim`. + ---@class config.preview + --- + --- Enables *preview* when attaching to new buffers. + ---@field enable? boolean + --- Enables `hybrid mode` when attaching to new buffers. + ---@field enable_hybrid_mode? boolean + --- + --- Icon provider. + ---@field icon_provider? + ---| "internal" Internal icon provider. + ---| "devicons" `nvim-web-devicons` as icon provider. + ---| "mini" `mini.icons` as icon provider. + --- + --- Callback functions. + ---@field callbacks? preview.callbacks + --- VIM-modes where `hybrid mode` is enabled. + ---@field hybrid_modes? string[] + --- Options that should/shouldn't be previewed in `hybrid_modes`. + ---@field ignore_previews? preview.ignore + --- Clear lines around the cursor in `hybrid mode`, instead of nodes? + ---@field linewise_hybrid_mode? boolean + --- VIM-modes where previews will be shown. + ---@field modes? string[] + --- + --- Debounce delay for updating previews. + ---@field debounce? integer + --- Buffer filetypes where the plugin should attach. + ---@field filetypes? string[] + --- Buftypes that should be ignored(e.g. nofile). + ---@field ignore_buftypes? string[] + --- Maximum number of lines a buffer can have before switching to partial rendering. + ---@field max_buf_lines? integer + --- + --- Lines before & after the cursor that is considered being edited. + --- Edited content isn't rendered. + ---@field edit_range? [ integer, integer ] + --- Lines before & after the cursor that is considered being previewed. + ---@field draw_range? [ integer, integer ] + --- + --- Window options for the `splitview` window. + --- See `:h nvim.open_win()`. + ---@field splitview_winopts? table + preview = { + ---+${conf} + + enable = true, + + callbacks = { + ---+${func} + + on_attach = function (_, wins) + ---+${lua} + + --- Initial state for attached buffers. + ---@type string + local attach_state = spec.get({ "preview", "enable" }, { fallback = true, ignore_enable = true }); + + if attach_state == false then + --- Attached buffers will not have their previews + --- enabled. + --- So, don't set options. + return; + end + + for _, win in ipairs(wins) do + --- Preferred conceal level should + --- be 3. + vim.wo[win].conceallevel = 3; + end + + ---_ + end, + + on_detach = function (_, wins) + ---+${lua} + for _, win in ipairs(wins) do + --- Only set `conceallevel`. + --- `concealcursor` will be + --- set via `on_hybrid_disable`. + vim.wo[win].conceallevel = 0; + end + ---_ + end, + + on_enable = function (_, wins) + ---+${lua} + + for _, win in ipairs(wins) do + vim.wo[win].conceallevel = 3; + end + + ---_ + end, + + on_disable = function (_, wins) + ---+${lua} + for _, win in ipairs(wins) do + vim.wo[win].conceallevel = 0; + end + ---_ + end, + + on_hybrid_enable = function (_, wins) + ---+${lua} + + ---@type string[] + local prev_modes = spec.get({ "preview", "modes" }, { fallback = {} }); + ---@type string[] + local hybd_modes = spec.get({ "preview", "hybrid_modes" }, { fallback = {} }); + + local concealcursor = ""; + + for _, mode in ipairs(prev_modes) do + if vim.list_contains(hybd_modes, mode) == false and vim.list_contains({ "n", "v", "i", "c" }, mode) then + concealcursor = concealcursor .. mode; + end + end + + for _, win in ipairs(wins) do + vim.wo[win].concealcursor = concealcursor; + end + + ---_ + end, + + on_hybrid_disable = function (_, wins) + ---+${lua} + + ---@type string[] + local prev_modes = spec.get({ "preview", "modes" }, { fallback = {} }); + local concealcursor = ""; + + for _, mode in ipairs(prev_modes) do + if vim.list_contains({ "n", "v", "i", "c" }, mode) then + concealcursor = concealcursor .. mode; + end + end + + for _, win in ipairs(wins) do + vim.wo[win].concealcursor = concealcursor; + end + + ---_ + end, + + on_mode_change = function (_, wins, current_mode) + ---+${lua} + + ---@type string[] + local preview_modes = spec.get({ "preview", "modes" }, { fallback = {} }); + ---@type string[] + local hybrid_modes = spec.get({ "preview", "hybrid_modes" }, { fallback = {} }); + + local concealcursor = ""; + + for _, mode in ipairs(preview_modes) do + if vim.list_contains(hybrid_modes, mode) == false and vim.list_contains({ "n", "v", "i", "c" }, mode) then + concealcursor = concealcursor .. mode; + end + end + + for _, win in ipairs(wins) do + if vim.list_contains(preview_modes, current_mode) then + vim.wo[win].conceallevel = 3; + vim.wo[win].concealcursor = concealcursor; + else + vim.wo[win].conceallevel = 0; + vim.wo[win].concealcursor = ""; + end + end + ---_ + end, + + on_splitview_open = function (_, _, win) + ---+${lua} + vim.wo[win].conceallevel = 3; + vim.wo[win].concealcursor = "n"; + ---_ + end + ---_ + }, + debounce = 150, + icon_provider = "internal", + + draw_range = { 2 * vim.o.lines, 2 * vim.o.lines }, + edit_range = { 0, 0 }, + + modes = { "n", "no", "c" }, + hybrid_modes = {}, + linewise_hybrid_mode = false, + max_buf_lines = 1000, + + filetypes = { "markdown", "quarto", "rmd", "typst" }, + ignore_buftypes = { "nofile" }, + ignore_previews = {}, + + splitview_winopts = { + split = "right" + } + + ---_ + }; +< + +------------------------------------------------------------------------------ +๐Ÿ“š Table of contents *markview.nvim-preview.toc* + + *markview.nvim-preview.enable* +enable ~ + + - Type: `boolean` + - Dynamic: true + - Default: true + +Enables previews. Can be set to `false` in case you want to use keymaps to toggle previews. + + *markview.nvim-preview.enable_hybrid_mode* +enable_hybrid_mode ~ + + - Type: `boolean` + - Dynamic: true + - Default: true + +Enables hybrid mode(if `hybrid_modes` is set). Set this to `false` if you want to enable hybrid mode on-demand. + + *markview.nvim-preview.icon_provider* +icon_provider ~ + + - Type: `"devicons | "internal" | "mini"` + - Dynamic: true + - Default: "internal" + + +โ–‹ ๐Ÿ“œ Note: +โ–‹ You will need to install the external icon providers to use them! + +Changes the icon provider used for drawing icons. Currently supported providers are, + +>lua + --- Icon provider. + ---@field icon_provider? + ---| "internal" Internal icon provider. + ---| "devicons" `nvim-web-devicons` as icon provider. + ---| "mini" `mini.icons` as icon provider. + icon_provider = "internal", +< + +Here's a simple comparison, + + โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ + โ”ƒ Feature โ”ƒ `devicons` โ”ƒ `mini` โ”ƒ `internal` โ”ƒ + โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ + โ”‚ Icon supoort โ”‚ many โ”‚ many โ”‚ limited โ”‚ + โ”‚ Dynamic colors โ”‚ no โ”‚ partial โ”‚ yes โ”‚ + โ”‚ External โ”‚ yes โ”‚ yes โ”‚ no โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + + *markview.nvim-preview.callbacks* +callbacks ~ + + - Type: `table` + - Dynamic: false + +Functions to execute when specific tasks are done by the plugin. + +โ–‹ ๐Ÿ“œ Note: +โ–‹ Callbacks are executed before [autocmds](). + +>lua + -- [ Markview | Preview options > Callbacks ] --------------------------------------------- + + --- Callback functions for specific events. + ---@class preview.callbacks + --- + --- Called when attaching to a buffer. + ---@field on_attach? fun(buf: integer, wins: integer[]): nil + --- Called when detaching from a buffer. + ---@field on_detach? fun(buf: integer, wins: integer[]): nil + --- + --- Called when disabling preview of a buffer. + --- Also called when opening `splitview`. + ---@field on_disable? fun(buf: integer, wins: integer[]): nil + --- Called when enabling preview of a buffer. + --- Also called when disabling `splitview`. + ---@field on_enable? fun(buf: integer, wins: integer[]): nil + --- + --- Called when disabling hybrid mode in a buffer. + --- > Called after `on_attach` when attaching to a buffer. + --- > Called after `on_disable`. + ---@field on_hybrid_disable? fun(buf: integer, wins: integer[]): nil + --- Called when enabling hybrid mode in a buffer. + --- > Called after `on_attach`(if `hybrid_mod` is disabled). + --- > Called after `on_enable`. + ---@field on_hybrid_enable? fun(buf: integer, wins: integer[]): nil + --- + --- Called when changing VIM-modes(only on active buffers). + ---@field on_mode_change? fun(buf: integer, wins: integer[], mode: string): nil + --- + --- Called before closing splitview. + ---@field on_splitview_close? fun(source: integer, preview_buf: integer, preview_win: integer): nil + --- Called when opening splitview. + ---@field on_splitview_open? fun(source: integer, preview_buf: integer, preview_win: integer): nil + preview_callbacks = { + ---+${func} + + on_attach = function (_, wins) + ---+${lua} + + --- Initial state for attached buffers. + ---@type string + local attach_state = spec.get({ "preview", "enable" }, { fallback = true, ignore_enable = true }); + + if attach_state == false then + --- Attached buffers will not have their previews + --- enabled. + --- So, don't set options. + return; + end + + for _, win in ipairs(wins) do + --- Preferred conceal level should + --- be 3. + vim.wo[win].conceallevel = 3; + end + + ---_ + end, + + on_detach = function (_, wins) + ---+${lua} + for _, win in ipairs(wins) do + --- Only set `conceallevel`. + --- `concealcursor` will be + --- set via `on_hybrid_disable`. + vim.wo[win].conceallevel = 0; + end + ---_ + end, + + on_enable = function (_, wins) + ---+${lua} + + for _, win in ipairs(wins) do + vim.wo[win].conceallevel = 3; + end + + ---_ + end, + + on_disable = function (_, wins) + ---+${lua} + for _, win in ipairs(wins) do + vim.wo[win].conceallevel = 0; + end + ---_ + end, + + on_hybrid_enable = function (_, wins) + ---+${lua} + + ---@type string[] + local prev_modes = spec.get({ "preview", "modes" }, { fallback = {} }); + ---@type string[] + local hybd_modes = spec.get({ "preview", "hybrid_modes" }, { fallback = {} }); + + local concealcursor = ""; + + for _, mode in ipairs(prev_modes) do + if vim.list_contains(hybd_modes, mode) == false and vim.list_contains({ "n", "v", "i", "c" }, mode) then + concealcursor = concealcursor .. mode; + end + end + + for _, win in ipairs(wins) do + vim.wo[win].concealcursor = concealcursor; + end + + ---_ + end, + + on_hybrid_disable = function (_, wins) + ---+${lua} + + ---@type string[] + local prev_modes = spec.get({ "preview", "modes" }, { fallback = {} }); + local concealcursor = ""; + + for _, mode in ipairs(prev_modes) do + if vim.list_contains({ "n", "v", "i", "c" }, mode) then + concealcursor = concealcursor .. mode; + end + end + + for _, win in ipairs(wins) do + vim.wo[win].concealcursor = concealcursor; + end + + ---_ + end, + + on_mode_change = function (_, wins, current_mode) + ---+${lua} + + ---@type string[] + local preview_modes = spec.get({ "preview", "modes" }, { fallback = {} }); + ---@type string[] + local hybrid_modes = spec.get({ "preview", "hybrid_modes" }, { fallback = {} }); + + local concealcursor = ""; + + for _, mode in ipairs(preview_modes) do + if vim.list_contains(hybrid_modes, mode) == false and vim.list_contains({ "n", "v", "i", "c" }, mode) then + concealcursor = concealcursor .. mode; + end + end + + for _, win in ipairs(wins) do + if vim.list_contains(preview_modes, current_mode) then + vim.wo[win].conceallevel = 3; + vim.wo[win].concealcursor = concealcursor; + else + vim.wo[win].conceallevel = 0; + vim.wo[win].concealcursor = ""; + end + end + ---_ + end, + + on_splitview_open = function (_, _, win) + ---+${lua} + vim.wo[win].conceallevel = 3; + vim.wo[win].concealcursor = "n"; + ---_ + end + ---_ + }; +< + +A short description of what each parameter represents, + + - buf + Buffer where the callback is being run on. + + - wins + List of windows that contain `buf`. + + - mode + VIM mode short-hand(e.g. "n", "i"). Output of + `vim.api.nvim_get_mode().mode`. + + - source + Source buffer for splitview. + + - preview_buf + Buffer containing the preview of splitview. + + - preview_win + Window containing the preview of splitview. + + *markview.nvim-preview.hybrid_modes* +hybrid_modes ~ + + - Type: `string[]` + - Dynamic: true(not recommended) + - Default: {} + +List of VIM-modes where `hybrid mode` is enable. These modes must be present +in the `modes` to take effect! + +โ–‹ Hybrid mode is used to preview & edit files at the same time. +โ–‹ When enabled, text within a specified range around the cursor will +โ–‹ not show the preview. + + *markview.nvim-preview.ignore_previews* +ignore_previews ~ + + - Type `preview.ignore` + - Dynamic: true(not recommended) + +>lua + -- [ Markview | Preview options > Ignore preview ] ---------------------------------------- + + --- Items to ignore when rendering. + ---@class preview.ignore + --- + ---@field html? ignore_html[] + ---@field latex? ignore_latex[] + ---@field markdown? ignore_md[] + ---@field markdown_inline? ignore_inline[] + ---@field typst? ignore_typst[] + ---@field yaml? ignore_yaml[] + preview_ignore = {}; + + ---@alias ignore_html + ---| "!container_elements" + ---| "!headings" + ---| "!void_elements" + --- + ---| "container_elements" + ---| "headings" + ---| "void_elements" + + ---@alias ignore_latex + ---| "!blocks" + ---| "!commands" + ---| "!escapes" + ---| "!fonts" + ---| "!inlines" + ---| "!parenthesis" + ---| "!subscripts" + ---| "!superscripts" + ---| "!symbols" + ---| "!texts" + --- + ---| "blocks" + ---| "commands" + ---| "escapes" + ---| "fonts" + ---| "inlines" + ---| "parenthesis" + ---| "subscripts" + ---| "superscripts" + ---| "symbols" + ---| "texts" + + ---@alias ignore_md + ---| "!block_quotes" + ---| "!code_blocks" + ---| "!headings" + ---| "!horizontal_rules" + ---| "!list_items" + ---| "!metadata_minus" + ---| "!metadata_plus" + ---| "!reference_definitions" + ---| "!tables" + --- + ---| "block_quotes" + ---| "code_blocks" + ---| "headings" + ---| "horizontal_rules" + ---| "list_items" + ---| "metadata_minus" + ---| "metadata_plus" + ---| "reference_definitions" + ---| "tables" + + ---@alias ignore_inline + ---| "!block_references" + ---| "!checkboxes" + ---| "!emails" + ---| "!embed_files" + ---| "!entities" + ---| "!escapes" + ---| "!footnotes" + ---| "!highlights" + ---| "!hyperlinks" + ---| "!images" + ---| "!inline_codes" + ---| "!internal_links" + ---| "!uri_autolinks" + --- + ---| "block_references" + ---| "checkboxes" + ---| "emails" + ---| "embed_files" + ---| "entities" + ---| "escapes" + ---| "footnotes" + ---| "highlights" + ---| "hyperlinks" + ---| "images" + ---| "inline_codes" + ---| "internal_links" + ---| "uri_autolinks" + + ---@alias ignore_typst + ---| "!code_blocks" + ---| "!code_spans" + ---| "!escapes" + ---| "!headings" + ---| "!labels" + ---| "!list_items" + ---| "!math_blocks" + ---| "!math_spans" + ---| "!raw_blocks" + ---| "!raw_spans" + ---| "!reference_links" + ---| "!subscripts" + ---| "!superscripts" + ---| "!symbols" + ---| "!terms" + ---| "!url_links" + --- + ---| "code_blocks" + ---| "code_spans" + ---| "escapes" + ---| "headings" + ---| "labels" + ---| "list_items" + ---| "math_blocks" + ---| "math_spans" + ---| "raw_blocks" + ---| "raw_spans" + ---| "reference_links" + ---| "subscripts" + ---| "superscripts" + ---| "symbols" + ---| "terms" + ---| "url_links" + + ---@alias ignore_yaml + ---| "!properties" + --- + ---| "properties" +< + +Controls which items get affected by `hybrid mode`. + +โ–‹ Items that are affected by `hybrid mode` will show the raw version +โ–‹ of them(instead of the preview) when the cursor is inside them. + +Each language can have a list of `option names`. + + - `html`, + + container_elements + + headings + + void_elements + + - `latex`, + + blocks + + commands + + escapes + + fonts + + inlines + + parenthesis + + subscripts + + superscripts + + symbols + + texts + + - `markdown`, + + block_quotes + + code_blocks + + headings + + horizontal_rules + + list_items + + metadata_minus + + metadata_plus + + reference_definitions + + tables + + + checkboxes(for `[ ]` & `[X]`) + + - `markdown_inline` + + block_references + + checkboxes + + emails + + embed_files + + entities + + escapes + + footnotes + + highlights + + hyperlinks + + images + + inline_codes + + internal_links + + uri_autolinks + + - `typst` + + code_blocks + + code_spans + + escapes + + headings + + labels + + list_items + + math_blocks + + math_spans + + raw_blocks + + raw_spans + + reference_links + + subscripts + + superscripts + + symbols + + terms + + url_links + + - `yaml` + + properties + +โ–‹ ๐Ÿ’ก Tip: +โ–‹ You can add a `!` before the option name to make it affect everything +โ–‹ other than the given option name. >lua + -- Affects everything other than "block quotes". + markdown = { "!block_quotes" } +< + + *markview.nvim-preview.linewise_hybrid_mode* +linewise_hybrid_mode ~ + + - Type: `boolean` + - Dynamic: false + - Default: false + +Enables linewise hybrid mode. + + *markview.nvim-preview.modes* +modes ~ + + - Type: `string[]` + - Dynamic: true(not recommended) + - Default: { "n", "no", "c" } + +List of VIM-modes where previews are shown. + + *markview.nvim-preview.debounce* +debounce ~ + + - Type: `integer` + - Dynamic: true(not recommended) + - Default: 50 + +Debounce delay(in `milliseconds`) for rendering. Affects how frequently the +preview is updated. + + *markview.nvim-preview.filetypes* +filetypes ~ + + - Type: `string[]` + - Dynamic: true(not recommended) + - Default: { "markdown", "rmd", "quarto", "typst" } + +List of buffer filetypes to enable this plugin in. This will cause the plugin +to attach to new buffers who have any of these filetypes. + + *markview.nvim-preview.ignore_buftypes* +ignore_buftypes ~ + + - Type: `string[]` + - Dynamic: true(not recommended) + - Default: { "nofile" } + +List of buffer types to ignore when attaching to new buffers. Checked after +the filetype. + + *markview.nvim-preview.max_buf_lines* +max_buf_lines ~ + + - Type: `integer` + - Dynamic: true(not recommended) + - Default: 1000 + +Maximum number of lines a buffer can have before the plugin switches to +partial-rendering. + +โ–‹ ๐Ÿ“œ Note: +โ–‹ When partial-rendering is used, only part of the buffer will have preview. +โ–‹ This may be distracting when moving long distances in the buffer. + + *markview.nvim-preview.edit_range* +edit_range ~ + + - Type: `[ integer, integer ]` + - Dynamic: true + - Default: { 0, 0 } + +Number of lines above & below the cursor that will be affected by +`hybrid mode`. + +This changes 2 behaviors, + + 1. When `linewise_hybrid_mode = true`, this changes the lines that will + not be rendered. + + 2. When `linewise_hybrid_mode` isn't being used, this affects which nodes + aren't rendered. + + *markview.nvim-preview.draw_range* +draw_range ~ + + - Type: `[ integer, integer ]` + - Dynamic: true + - Default: { vim.o.columns, vim.o.columns } + +Number of lines above & below the cursor to render. + + *markview.nvim-preview.splitview_winopts* +splitview_winopts ~ + + - Type: `table` + - Dynamic: true(not recommended) + - Default: { split = "right" } + +Window options(see `:h vim.api.nvim_open_win()`) for the splitview window. + +------------------------------------------------------------------------------ +vim:ft=help:tw=78: diff --git a/doc/tags b/doc/tags index aeeced2..a6521e6 100644 --- a/doc/tags +++ b/doc/tags @@ -1,15 +1,107 @@ -markview.nvim markview.txt /*markview.nvim* -markview.nvim-c-block_quotes markview.txt /*markview.nvim-c-block_quotes* -markview.nvim-c-checkboxes markview.txt /*markview.nvim-c-checkboxes* -markview.nvim-c-code_blocks markview.txt /*markview.nvim-c-code_blocks* -markview.nvim-c-escaped markview.txt /*markview.nvim-c-escaped* -markview.nvim-c-footnotes markview.txt /*markview.nvim-c-footnotes* -markview.nvim-c-headings markview.txt /*markview.nvim-c-headings* -markview.nvim-c-hrs markview.txt /*markview.nvim-c-hrs* -markview.nvim-c-html markview.txt /*markview.nvim-c-html* -markview.nvim-c-inline_codes markview.txt /*markview.nvim-c-inline_codes* -markview.nvim-c-latex markview.txt /*markview.nvim-c-latex* -markview.nvim-c-links markview.txt /*markview.nvim-c-links* -markview.nvim-c-list_items markview.txt /*markview.nvim-c-list_items* -markview.nvim-c-tables markview.txt /*markview.nvim-c-tables* -markview.nvim-setup markview.txt /*markview.nvim-setup* +markview.nvim home.txt /*markview.nvim* +markview.nvim-advanced advanced_usage.txt /*markview.nvim-advanced* +markview.nvim-advanced.header_folding advanced_usage.txt /*markview.nvim-advanced.header_folding* +markview.nvim-autocmds home.txt /*markview.nvim-autocmds* +markview.nvim-commands home.txt /*markview.nvim-commands* +markview.nvim-config home.txt /*markview.nvim-config* +markview.nvim-dev dev.txt /*markview.nvim-dev* +markview.nvim-dev.functions dev.txt /*markview.nvim-dev.functions* +markview.nvim-dev.manual_previews dev.txt /*markview.nvim-dev.manual_previews* +markview.nvim-dev.states dev.txt /*markview.nvim-dev.states* +markview.nvim-dev.toc dev.txt /*markview.nvim-dev.toc* +markview.nvim-experimental experimental_options.txt /*markview.nvim-experimental* +markview.nvim-experimental.date_formats experimental_options.txt /*markview.nvim-experimental.date_formats* +markview.nvim-experimental.date_time_formats experimental_options.txt /*markview.nvim-experimental.date_time_formats* +markview.nvim-experimental.file_open_command experimental_options.txt /*markview.nvim-experimental.file_open_command* +markview.nvim-experimental.list_empty_line_tolerance experimental_options.txt /*markview.nvim-experimental.list_empty_line_tolerance* +markview.nvim-experimental.read_chunk_size experimental_options.txt /*markview.nvim-experimental.read_chunk_size* +markview.nvim-extra extra.txt /*markview.nvim-extra* +markview.nvim-extra.checkboxes extra.txt /*markview.nvim-extra.checkboxes* +markview.nvim-extra.editor extra.txt /*markview.nvim-extra.editor* +markview.nvim-extra.headings extra.txt /*markview.nvim-extra.headings* +markview.nvim-hl home.txt /*markview.nvim-hl* +markview.nvim-html html_options.txt /*markview.nvim-html* +markview.nvim-html.container_elements html_options.txt /*markview.nvim-html.container_elements* +markview.nvim-html.headings html_options.txt /*markview.nvim-html.headings* +markview.nvim-html.void_elements html_options.txt /*markview.nvim-html.void_elements* +markview.nvim-inline markdown_inline_options.txt /*markview.nvim-inline* +markview.nvim-inline.block_references markdown_inline_options.txt /*markview.nvim-inline.block_references* +markview.nvim-inline.checkboxes markdown_inline_options.txt /*markview.nvim-inline.checkboxes* +markview.nvim-inline.emails markdown_inline_options.txt /*markview.nvim-inline.emails* +markview.nvim-inline.embed_files markdown_inline_options.txt /*markview.nvim-inline.embed_files* +markview.nvim-inline.emoji_shorthands markdown_inline_options.txt /*markview.nvim-inline.emoji_shorthands* +markview.nvim-inline.entities markdown_inline_options.txt /*markview.nvim-inline.entities* +markview.nvim-inline.escapes markdown_inline_options.txt /*markview.nvim-inline.escapes* +markview.nvim-inline.footnotes markdown_inline_options.txt /*markview.nvim-inline.footnotes* +markview.nvim-inline.highlights markdown_inline_options.txt /*markview.nvim-inline.highlights* +markview.nvim-inline.hyperlinks markdown_inline_options.txt /*markview.nvim-inline.hyperlinks* +markview.nvim-inline.images markdown_inline_options.txt /*markview.nvim-inline.images* +markview.nvim-inline.inline_codes markdown_inline_options.txt /*markview.nvim-inline.inline_codes* +markview.nvim-inline.internal_links markdown_inline_options.txt /*markview.nvim-inline.internal_links* +markview.nvim-inline.uri_autolinks markdown_inline_options.txt /*markview.nvim-inline.uri_autolinks* +markview.nvim-latex latex_options.txt /*markview.nvim-latex* +markview.nvim-latex.blocks latex_options.txt /*markview.nvim-latex.blocks* +markview.nvim-latex.commands latex_options.txt /*markview.nvim-latex.commands* +markview.nvim-latex.escapes latex_options.txt /*markview.nvim-latex.escapes* +markview.nvim-latex.fonts latex_options.txt /*markview.nvim-latex.fonts* +markview.nvim-latex.inlines latex_options.txt /*markview.nvim-latex.inlines* +markview.nvim-latex.parenthesis latex_options.txt /*markview.nvim-latex.parenthesis* +markview.nvim-latex.subscripts latex_options.txt /*markview.nvim-latex.subscripts* +markview.nvim-latex.superscripts latex_options.txt /*markview.nvim-latex.superscripts* +markview.nvim-latex.symbols latex_options.txt /*markview.nvim-latex.symbols* +markview.nvim-latex.texts latex_options.txt /*markview.nvim-latex.texts* +markview.nvim-markdown markdown_options.txt /*markview.nvim-markdown* +markview.nvim-markdown.block_quotes markdown_options.txt /*markview.nvim-markdown.block_quotes* +markview.nvim-markdown.code_blocks markdown_options.txt /*markview.nvim-markdown.code_blocks* +markview.nvim-markdown.headings markdown_options.txt /*markview.nvim-markdown.headings* +markview.nvim-markdown.horizontal_rules markdown_options.txt /*markview.nvim-markdown.horizontal_rules* +markview.nvim-markdown.list_items markdown_options.txt /*markview.nvim-markdown.list_items* +markview.nvim-markdown.metadata_minus markdown_options.txt /*markview.nvim-markdown.metadata_minus* +markview.nvim-markdown.metadata_plus markdown_options.txt /*markview.nvim-markdown.metadata_plus* +markview.nvim-markdown.reference_definitions markdown_options.txt /*markview.nvim-markdown.reference_definitions* +markview.nvim-markdown.tables markdown_options.txt /*markview.nvim-markdown.tables* +markview.nvim-migration migration.txt /*markview.nvim-migration* +markview.nvim-presets presets.txt /*markview.nvim-presets* +markview.nvim-presets.headings presets.txt /*markview.nvim-presets.headings* +markview.nvim-presets.hr presets.txt /*markview.nvim-presets.hr* +markview.nvim-presets.tables presets.txt /*markview.nvim-presets.tables* +markview.nvim-presets.use presets.txt /*markview.nvim-presets.use* +markview.nvim-preview preview_options.txt /*markview.nvim-preview* +markview.nvim-preview.callbacks preview_options.txt /*markview.nvim-preview.callbacks* +markview.nvim-preview.debounce preview_options.txt /*markview.nvim-preview.debounce* +markview.nvim-preview.draw_range preview_options.txt /*markview.nvim-preview.draw_range* +markview.nvim-preview.edit_range preview_options.txt /*markview.nvim-preview.edit_range* +markview.nvim-preview.enable preview_options.txt /*markview.nvim-preview.enable* +markview.nvim-preview.enable_hybrid_mode preview_options.txt /*markview.nvim-preview.enable_hybrid_mode* +markview.nvim-preview.filetypes preview_options.txt /*markview.nvim-preview.filetypes* +markview.nvim-preview.hybrid_modes preview_options.txt /*markview.nvim-preview.hybrid_modes* +markview.nvim-preview.icon_provider preview_options.txt /*markview.nvim-preview.icon_provider* +markview.nvim-preview.ignore_buftypes preview_options.txt /*markview.nvim-preview.ignore_buftypes* +markview.nvim-preview.ignore_previews preview_options.txt /*markview.nvim-preview.ignore_previews* +markview.nvim-preview.max_buf_lines preview_options.txt /*markview.nvim-preview.max_buf_lines* +markview.nvim-preview.modes preview_options.txt /*markview.nvim-preview.modes* +markview.nvim-preview.splitview_winopts preview_options.txt /*markview.nvim-preview.splitview_winopts* +markview.nvim-preview.toc preview_options.txt /*markview.nvim-preview.toc* +markview.nvim-renderers custom_renderers.txt /*markview.nvim-renderers* +markview.nvim-toc home.txt /*markview.nvim-toc* +markview.nvim-typst typst_options.txt /*markview.nvim-typst* +markview.nvim-typst.code_blocks typst_options.txt /*markview.nvim-typst.code_blocks* +markview.nvim-typst.code_spans typst_options.txt /*markview.nvim-typst.code_spans* +markview.nvim-typst.escapes typst_options.txt /*markview.nvim-typst.escapes* +markview.nvim-typst.headings typst_options.txt /*markview.nvim-typst.headings* +markview.nvim-typst.labels typst_options.txt /*markview.nvim-typst.labels* +markview.nvim-typst.list_items typst_options.txt /*markview.nvim-typst.list_items* +markview.nvim-typst.math_blocks typst_options.txt /*markview.nvim-typst.math_blocks* +markview.nvim-typst.math_spans typst_options.txt /*markview.nvim-typst.math_spans* +markview.nvim-typst.raw_blocks typst_options.txt /*markview.nvim-typst.raw_blocks* +markview.nvim-typst.raw_spans typst_options.txt /*markview.nvim-typst.raw_spans* +markview.nvim-typst.reference_links typst_options.txt /*markview.nvim-typst.reference_links* +markview.nvim-typst.subscripts typst_options.txt /*markview.nvim-typst.subscripts* +markview.nvim-typst.superscripts typst_options.txt /*markview.nvim-typst.superscripts* +markview.nvim-typst.symbols typst_options.txt /*markview.nvim-typst.symbols* +markview.nvim-typst.terms typst_options.txt /*markview.nvim-typst.terms* +markview.nvim-typst.url_links typst_options.txt /*markview.nvim-typst.url_links* +markview.nvim-wiki-guide home.txt /*markview.nvim-wiki-guide* +markview.nvim-yaml yaml_options.txt /*markview.nvim-yaml* +markview.nvim-yaml.properties yaml_options.txt /*markview.nvim-yaml.properties* +preview preview_options.txt /*preview* diff --git a/doc/typst_options.txt b/doc/typst_options.txt new file mode 100644 index 0000000..ba62141 --- /dev/null +++ b/doc/typst_options.txt @@ -0,0 +1,1072 @@ +*markview.nvim-typst* Typst preview options for markview + + Changes how typst items are shown in preview. + +>lua + -- [ Markview | Typst ] ------------------------------------------------------------------- + + --- Configuration for Typst. + ---@class config.typst + --- + ---@field enable boolean + --- + ---@field code_blocks typst.code_blocks | fun(): typst.code_blocks + ---@field code_spans typst.code_spans | fun(): typst.code_spans + ---@field escapes typst.escapes | fun(): typst.escapes + ---@field headings typst.headings | fun(): typst.headings + ---@field labels typst.labels | fun(): typst.labels + ---@field list_items typst.list_items | fun(): typst.list_items + ---@field math_blocks typst.math_blocks | fun(): typst.math_blocks + ---@field math_spans typst.math_spans | fun(): typst.math_spans + ---@field raw_blocks typst.raw_blocks | fun(): typst.raw_blocks + ---@field raw_spans typst.raw_spans | fun(): typst.raw_spans + ---@field reference_links typst.reference_links | fun(): typst.reference_links + ---@field subscripts typst.subscripts | fun(): typst.subscripts + ---@field superscripts typst.subscripts | fun(): typst.superscripts + ---@field symbols typst.symbols | fun(): typst.symbols + ---@field terms typst.terms | fun(): typst.terms + ---@field url_links typst.url_links | fun(): typst.url_links + M.typst = { + enable = true, + + code_blocks = {}, + code_spans = {}, + escapes = {}, + headings = {}, + labels = {}, + list_items = {}, + math_spans = {}, + math_blocks = {}, + raw_spans = {}, + raw_blocks = {}, + reference_links = {}, + subscripts = {}, + superscript = {}, + symbols = {}, + terms = {}, + url_links = {}, + }; + + -- [ Markview | Typst โ€ข Static ] ---------------------------------------------------------- + + --- Static configuration for Typst. + ---@class config.typst_static + --- + ---@field enable boolean + --- + ---@field code_blocks typst.code_blocks Configuration for block of typst code. + ---@field code_spans typst.code_spans Configuration for inline typst code. + ---@field escapes typst.escapes Configuration for escaped characters. + ---@field headings typst.headings Configuration for headings. + ---@field labels typst.labels Configuration for labels. + ---@field list_items typst.list_items Configuration for list items + ---@field math_blocks typst.math_blocks Configuration for blocks of math code. + ---@field math_spans typst.math_spans Configuration for inline math code. + ---@field raw_blocks typst.raw_blocks Configuration for raw blocks. + ---@field raw_spans typst.raw_spans Configuration for raw spans. + ---@field reference_links typst.reference_links Configuration for reference links. + ---@field subscripts typst.subscripts Configuration for subscript texts. + ---@field superscripts typst.subscripts Configuration for superscript texts. + ---@field symbols typst.symbols Configuration for typst symbols. + ---@field terms typst.terms Configuration for terms. + ---@field url_links typst.url_links Configuration for URL links. +< + *markview.nvim-typst.code_blocks* +code_blocks ~ + + - Type: `typst.code_blocks` + - Dynamic: true + +Configuration for blocks of code. +>lua + -- [ Typst | Code blocks ] ---------------------------------------------------------------- + + --- Configuration for code blocks. + ---@class typst.code_blocks + --- + ---@field enable boolean + --- + ---@field hl? string | fun(buffer: integer, item: __typst.code_block): string? + ---@field min_width integer | fun(buffer: integer, item: __typst.code_block): integer + ---@field pad_amount integer | fun(buffer: integer, item: __typst.code_block): integer + ---@field pad_char? string | fun(buffer: integer, item: __typst.code_block): string? + ---@field sign? string | fun(buffer: integer, item: __typst.code_block): string + ---@field sign_hl? string | fun(buffer: integer, item: __typst.code_block): string? + ---@field style ( "simple" | "block" ) | fun(buffer: integer, item: __typst.code_block): ( "simple" | "block" ) + ---@field text string | fun(buffer: integer, item: __typst.code_block): string + ---@field text_direction ( "left" | "right" ) | fun(buffer: integer, item: __typst.code_block): ( "left" | "right" ) + ---@field text_hl? string | fun(buffer: integer, item: __typst.code_block): string? + code_blocks = { + enable = true, + + style = "block", + text_direction = "right", + min_width = 60, + pad_char = " ", + pad_amount = 3, + + text = "๓ฐฃ– Code", + + hl = "MarkviewCode", + text_hl = "MarkviewIcon5" + }; + + -- [ Typst | Code blocks โ€ข Static ] ------------------------------------------------------- + + --- Static configuration for code blocks. + ---@class typst.code_blocks_static + --- + ---@field enable boolean + --- + ---@field hl? string + ---@field min_width integer Minimum width of code blocks. + ---@field pad_amount integer Number of paddings added around the text. + ---@field pad_char? string Character to use for padding. + ---@field sign? string Sign for the code block. + ---@field sign_hl? string Highlight group for the sign. + ---@field style + ---| "simple" Only highlights the lines inside this block. + ---| "block" Creates a box around the code block. + ---@field text string Text to use as the label. + ---@field text_direction + ---| "left" Shows label on the top-left side of the block + ---| "right" Shows label on the top-right side of the block + ---@field text_hl? string Highlight group for the label +< +>lua + -- [ Typst | Code blocks > Parameters ] --------------------------------------------------- + + ---@class __typst.code_block + ---@field class "typst_code_block" + ---@field text string[] + ---@field range node.range + M.__typst_codes = { + class = "typst_code_block", + + text = { + "#{", + " let a = [from]", + "}" + }, + range = { + row_start = 0, + row_end = 2, + + col_start = 0, + col_end = 1 + } + }; +< + *markview.nvim-typst.code_spans* +code_spans ~ + + - Type: `typst.code_spans` + - Dynamic: true + +Configuration for spans of code. +>lua + -- [ Typst | Code spans ] ---------------------------------------------------------------- + + --- Configuration for code spans. + ---@class typst.code_spans + --- + ---@field enable boolean + --- + ---@field corner_left? string | fun(buffer: integer, item: __typst.code_spans): string? + ---@field corner_left_hl? string | fun(buffer: integer, item: __typst.code_spans): string? + ---@field corner_right? string | fun(buffer: integer, item: __typst.code_spans): string? + ---@field corner_right_hl? string | fun(buffer: integer, item: __typst.code_spans): string? + ---@field hl? string | fun(buffer: integer, item: __typst.code_spans): string? + ---@field padding_left? string | fun(buffer: integer, item: __typst.code_spans): string? + ---@field padding_left_hl? string | fun(buffer: integer, item: __typst.code_spans): string? + ---@field padding_right? string | fun(buffer: integer, item: __typst.code_spans): string? + ---@field padding_right_hl? string | fun(buffer: integer, item: __typst.code_spans): string? + code_spans = { + enable = true, + + padding_left = " ", + padding_right = " ", + + hl = "MarkviewCode" + }; + + -- [ Typst | Code spans โ€ข Static ] ------------------------------------------------------- + + --- Static configuration for code spans. + ---@class typst.code_spans_static + --- + ---@field enable boolean + --- + ---@field corner_left? string Left corner. + ---@field corner_left_hl? string Highlight group for left corner. + ---@field corner_right? string Right corner. + ---@field corner_right_hl? string Highlight group for right corner. + ---@field hl? string Base Highlight group. + ---@field padding_left? string Left padding. + ---@field padding_left_hl? string Highlight group for left padding. + ---@field padding_right? string Right padding. + ---@field padding_right_hl? string Highlight group for right padding. +< +>lua + -- [ Typst | Code spans > Parameters ] ---------------------------------------------------- + + ---@class __typst.code_spans + ---@field class "typst_code_span" + ---@field text string[] + ---@field range node.range + M.__typst_codes = { + class = "typst_code_span", + + text = { "#{ let a = 1 }" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 13 + } + }; +< + *markview.nvim-typst.escapes* +escapes ~ + + - Type: `typst.escapes` + - Dynamic: false + +Configuration for escaped characters. +>lua + -- [ Typst | Escapes ] --------------------------------------------------------------------- + + ---@class typst.escapes + --- + ---@field enable boolean + escapes = { enable = true }; +< +>lua + -- [ Typst | Escapes > Parameters ] ------------------------------------------------------- + + ---@class __typst.escapes + --- + ---@field class "typst_escaped" + ---@field text string[] + ---@field range node.range + M.__typst_escapes = { + class = "typst_escaped", + + text = { "\\|" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 2 + } + }; +< + *markview.nvim-typst.headings* +headings ~ + + - Type: `typst.headings` + - Dynamic: true + +Configuration for headings. +>lua + -- [ Typst | Headings ] ------------------------------------------------------------------- + + --- Configuration for Typst headings. + ---@class typst.headings + --- + ---@field enable boolean + --- + ---@field shift_width integer Amount of spaces to shift per heading level. + --- + ---@field [string] headings.typst Heading level configuration(name format: "heading_%d", %d = heading level). + 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", + } + }; +< +>lua + -- [ Typst | Headings > Type definitions ] ------------------------------------------------ + + --- Heading level configuration. + ---@class headings.typst + --- + ---@field style "simple" | "icon" + ---@field hl? string + ---@field icon? string + ---@field icon_hl? string + ---@field sign? string + ---@field sign_hl? string + M.headings_typst = { + style = "simple", + hl = "MarkviewHeading1" + } or { + style = "icon", + + icon = "~", + hl = "MarkviewHeading1" + }; + + -- [ Typst | Headings > Parameters ] ------------------------------------------------------ + + ---@class __typst.headings + --- + ---@field class "typst_heading" + --- + ---@field level integer Heading level. + --- + ---@field text string[] + ---@field range node.range + M.__typst_headings = { + class = "typst_heading", + level = 1, + + text = { "= Heading 1" }, + range = { + row_start = 0, + row_end = 0, + + col_start = 0, + col_end = 10 + } + }; +< + *markview.nvim-typst.labels* +labels ~ + + - Type: `typst.labels` + - Dynamic: true + +Configuration for labels. +>lua + -- [ Typst | Labels ] --------------------------------------------------------------------- + + --- Configuration for typst labels. + ---@class typst.labels + --- + ---@field enable boolean + --- + ---@field default config.inline_generic | fun(buffer: integer, item: __typst.labels): config.inline_generic + ---@field [string] config.inline_generic | fun(buffer: integer, item: __typst.labels): config.inline_generic + labels = { + enable = true, + + default = { + hl = "MarkviewInlineCode", + padding_left = " ", + icon = "๏€ซ ", + padding_right = " " + }, + }; + + -- [ Typst | Labels โ€ข Static ] ------------------------------------------------------------ + + --- Static configuration for typst labels. + ---@class typst.labels + --- + ---@field enable boolean + --- + ---@field default config.inline_generic Default configuration for labels. + ---@field [string] config.inline_generic Configuration for labels whose text matches `string`. +< +>lua + -- [ Typst | Labels > Parameters ] -------------------------------------------------------- + + ---@class __typst.labels + --- + ---@field class "typst_labels" + --- + ---@field text string[] + ---@field range node.range + M.__typst_labels = { + class = "typst_labels", + + text = { "