Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
atinylittleshell committed Apr 13, 2024
1 parent 6a7a9d6 commit 1459282
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Comment-REPL.nvim

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/atinylittleshell/comment-repl.nvim/lint-test.yml?branch=main&style=for-the-badge)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/atinylittleshell/comment-repl.nvim/lint_test.yml?branch=main&style=for-the-badge)
![Lua](https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua)

A Neovim plugin for executing REPLs directly in your buffers and showing results as comments.
Execute code directly from your buffer and print the output as a comment.

## How does it work

[Screenshot](doc/screenshot.png)

## Installation

Using lazy.nvim:

```lua
{
'atinylittleshell/comment-repl.nvim',
opts = {},
}
```

## Configuration

See [config.lua](lua/comment-repl/config.lua) for config schema and default values.

## Commands

`:CommentREPLExecute` - Execute the code cell at the cursor and print the output as a comment.

`:CommentREPLLog` - View logs from Comment-REPL.nvim.

```lua
-- By default the plugin will not enable any key bindings.
-- Your can define your own keybind behavior like below.
vim.keymap.set('n', '<leader>ce', '<cmd>CommentREPLExecute<CR>')
vim.keymap.set('n', '<leader>cl', '<cmd>CommentREPLLog<CR>')
```
Binary file added doc/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 13 additions & 6 deletions examples/python.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
i = 30
print(i)
def fibonacci_below(n):
a, b = 0, 1
while a < n:
print(a, end=" ")
a, b = b, a + b


fibonacci_below(5)


"""
30
0 1 1 2 3
"""

# %%
j = {"hello", "world"}
print(j)
# The marker above separates the code below into a different cell

fibonacci_below(10)


"""
{'world', 'hello'}
0 1 1 2 3 5 8
"""
5 changes: 5 additions & 0 deletions lua/comment_repl/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
---@field repls table<string, LanguageConfig>?
local M = {
output = {
-- Margin around the output comment
margin = {
top = 2,
bottom = 1,
Expand All @@ -23,14 +24,18 @@ local M = {
level = "info",
},
repls = {
-- Python is supported by default
python = {
display = "Python",
cmd = "python",
args = { "-i" },
-- The marker is what separates code cells
cell_marker = "# %%",
multi_line_comment_open = '"""',
multi_line_comment_close = '"""',
},
-- Add your own repl configurations below.
-- Use filetype as the key.
},
}

Expand Down

0 comments on commit 1459282

Please sign in to comment.