Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jbyuki/carrot.nvim
Evaluate Neovim Lua inside Markdown
https://github.com/jbyuki/carrot.nvim
Last synced: 2 months ago
JSON representation
Evaluate Neovim Lua inside Markdown
- Host: GitHub
- URL: https://github.com/jbyuki/carrot.nvim
- Owner: jbyuki
- License: mit
- Created: 2022-05-06T02:31:58.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-25T19:04:37.000Z (about 1 year ago)
- Last Synced: 2024-01-24T08:53:07.039Z (5 months ago)
- Language: Lua
- Size: 42 KB
- Stars: 26
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-neovim - jbyuki/carrot.nvim - Markdown evaluator Lua code blocks. (Programming Languages Support / Markdown and LaTeX)
- awesome-stars - jbyuki/carrot.nvim - Evaluate Neovim Lua inside Markdown (Lua)
- awesome-stars - jbyuki/carrot.nvim - Evaluate Neovim Lua inside Markdown (Lua)
- awesome-neovim - jbyuki/carrot.nvim - Markdown evaluator Lua code blocks. (Programming Languages Support / Markdown and LaTeX)
- awesome-neovim - jbyuki/carrot.nvim - Markdown evaluator Lua code blocks. (Programming Languages Support / Markdown and LaTeX)
README
# carrot.nvim ![license](https://img.shields.io/github/license/jbyuki/carrot.nvim) ![version](https://img.shields.io/badge/version-0.0.1-blue)
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](https://raw.githubusercontent.com/jbyuki/gifs/main/carrot.png)
## Prerequisites
* Neovim 0.7.0+
* Tree-sitter : [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
* Markdown parser : Install with `TSInstall markdown` and `TSInstall markdown_inline`.Make sure that the markdown parser is installed with:
```lua
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")
```
```output[1](05/06/22 13:41:59)
OK
```## Install
Install using your prefered method:
- [vim-plug](https://github.com/junegunn/vim-plug).
```vim
Plug 'jbyuki/carrot.nvim'
```- [packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua
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
* [example.md](test/example.md)
* [internals.md](test/internals.md)