Skip to content

jbyuki/carrot.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Evaluate Neovim Lua inside Markdown

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages