jbyuki/carrot.nvim

github github
programming-languages-supportmarkdown-and-latex
stars 24
issues 0
subscribers 2
forks 0
CREATED

2022-05-06

UPDATED

2 years ago


carrot.nvim license version

Markdown evaluator for Neovim Lua code blocks.

This is still work-in-progress but the main code evaluation functionnalities should be working.

The plugin will detect the code blocks under the cursor using treesitter's query mechanism, execute it, and show the results directly in the markdown.

It tries to be not intrusive. It won't redefine print() to redirect the result, it uses a subprocess neovim to evaluate the code in a sandboxed safe environnement.

It also tries to keep the spirit of Markdown files and show results in a simple but pleasing way.

carrot screenshot

Prerequisites

Make sure that the markdown parser is installed with:

local buf = vim.api.nvim_create_buf(false, true)
local parser = vim.treesitter.get_parser(buf, "markdown")
assert(parser, "The markdown parser is not installed.")
print("OK")
OK

Install

Install using your prefered method:

Plug 'jbyuki/carrot.nvim'
use "jbyuki/carrot.nvim"

Usage

  • Hover the cursor over a lua code block
  • Execute :CarrotEval

Commands

  • :CarrotEval : Evaluate the code block under the cursor
  • :CarrotNewBlock : Create a new lua codeblock and put the cursor inside it
  • :CarrotStop : Stop the kernel
  • :CarrotEvalAll : Evaluate all the code blocks in the document sequentially

Examples