v0.5.1 ยท Neovim Plugin

myst-markdown
tree-sitter.nvim

Tree-sitter powered syntax highlighting for MyST Markdown in Neovim.
Code-cell directives, math blocks, and 10+ language injections.

example.md
# MyST Markdown Example

```{code-cell} python
import pandas as pd

df = pd.DataFrame({
    "x": [1, 2, 3],
    "y": [4, 5, 6]
})
print(df)
```

```{math}
\begin{aligned}
    E &= mc^2 \\
    F &= ma
\end{aligned}
```

Features

Everything you need for MyST Markdown editing in Neovim

๐Ÿ”

Auto Detection

Automatically detects MyST files based on content patterns like {code-cell} and {math} directives.

๐ŸŽจ

Code-Cell Highlighting

Language-specific syntax highlighting inside {code-cell} directives โ€” Python, JavaScript, Bash, and more.

๐Ÿ“

Math Directives

Full LaTeX syntax highlighting for {math} directives and $$ blocks.

๐ŸŒณ

Tree-sitter Powered

Built on tree-sitter for robust, accurate parsing. Uses injection queries for language-specific highlighting.

โšก

Fast & Lightweight

Detection caching, configurable scan limits, and zero-cost debug logging when disabled.

๐Ÿงช

170+ Tests

Comprehensive test suite covering directives, edge cases, performance, and tree-sitter integration.

Installation

Get up and running in minutes

plugins/myst.lua
{
  "QuantEcon/myst-markdown-tree-sitter.nvim",
  version = "0.5.1",
  dependencies = { "nvim-treesitter/nvim-treesitter" },
  ft = { "markdown", "myst" },
  config = function()
    require('myst-markdown').setup()
  end,
}
plugins.lua
use {
  'QuantEcon/myst-markdown-tree-sitter.nvim',
  requires = {'nvim-treesitter/nvim-treesitter'},
  config = function()
    require('myst-markdown').setup()
  end
}

Requirements

  • Neovim ≥ 0.8.0
  • nvim-treesitter
  • Tree-sitter parsers: :TSInstall markdown markdown_inline
  • Recommended: :TSInstall python latex

Configuration

Works out of the box โ€” customize when you need to

Minimal (recommended)

require('myst-markdown').setup()

Full options

require('myst-markdown').setup({
  debug = false,
  detection = {
    scan_lines = 50,
  },
  performance = {
    cache_enabled = true,
  },
  highlighting = {
    enabled = true,
  },
})
Option Default Description
debug false Enable verbose debug logging
detection.scan_lines 50 Lines to scan for MyST patterns
performance.cache_enabled true Cache filetype detection results
highlighting.enabled true Enable tree-sitter highlighting

Supported Languages

Language injection for {code-cell} directives

JavaScript
javascript, js
TypeScript
typescript, ts
Bash
bash, sh
R
r
Julia
julia
Rust
rust
Go
go
C / C++
c, cpp

Install parsers with :TSInstall <language>

Commands

Built-in commands for debugging and diagnostics

:MystStatus

Quick health check of MyST highlighting status for the current buffer.

:MystDebug

Comprehensive debugging info โ€” tree-sitter state, queries, injections, diagnostics.

:MystInfo

Show plugin version, configuration, and environment details.

Troubleshooting

Quick fixes for common issues

Highlighting not working at all
  1. Run :MystStatus for a quick health check
  2. Ensure the file contains MyST directives like {code-cell} or {math}
  3. Verify nvim-treesitter is installed and the markdown parser is available
  4. Run :MystDebug for detailed diagnostics
Code-cell highlighting not working for a specific language

The tree-sitter parser for that language may not be installed.

:TSInstall python    -- or javascript, bash, etc.

Verify with :TSInstallInfo to see installed parsers.

Conflicts with other MyST plugins

If you have another MyST plugin installed (e.g., myst-markdown.nvim without tree-sitter in the name), remove it โ€” it can conflict with filetype detection and query injection.

Check via :scriptnames or :echo &runtimepath.

Math directive highlighting not working

Install the LaTeX tree-sitter parser:

:TSInstall latex
Colon-fence directives not highlighted

MyST supports both backtick fences (```) and colon fences (:::), but this plugin only supports backtick fences because the underlying markdown tree-sitter parser doesn't recognize colon fences.

See issue #51 for tracking a dedicated MyST parser.