Skip to content

Neovim plugin powered by treesitter to run a code region in a REPL shell.

Notifications You must be signed in to change notification settings

mlorthiois/REPL-region.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REPL-region.nvim

This Neovim plugin lets you send the statement region code in a REPL. It's based on Treesitter and neoterm.

Usage

To use with the packer plugin manager, enter in your config file:

use({
  "mlorthiois/repl-region.nvim",
  requires = {
    "nvim-treesitter/nvim-treesitter",
    "kassio/neoterm"
  },
})

Then, place your cursor on the line containing the statement you want to run, and use command :TREPLSendLineStatement. If you want to run the whole statement, use :TREPLSendContextStatement.

From lua, these commands are also availabled from require("repl_region").send_repl_statement("line") and require("repl_region").send_repl_statement("global").

These commands run the code, and set cursor one line below the region runned (like in RStudio).

Example

def my_function():
  for i in range(5): # << cursor here
      if i%2 == 0:
        print(i)
  • :TREPLSendLineStatement will run the for loop, and will place the cursor under the print.
  • :TREPLSendContextStatement will run the whole function, and will place the cursor under the print.

def my_function():
  for i in range(5):
      if i%2 == 0:   # << cursor here
        print(i)
  • :TREPLSendLineStatement will run the if statement, and will place the cursor under the print.
  • :TREPLSendContextStatement will run the whole function and will place the cursor under print.

Tested with Python, R, nodeJS.

About

Neovim plugin powered by treesitter to run a code region in a REPL shell.

Topics

Resources

Stars

Watchers

Forks