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.
- Neovim 0.7.0+
- Tree-sitter : nvim-treesitter/nvim-treesitter
- Markdown parser : Install with
TSInstall markdown
andTSInstall markdown_inline
.
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 using your prefered method:
Plug 'jbyuki/carrot.nvim'
use "jbyuki/carrot.nvim"
- Hover the cursor over a lua code block
- Execute
:CarrotEval
: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