sponsor Vim development Vim logo Vim Book Ad

litrepl : Markdown/LaTeX code section execution plugin

 script karma  Rating 7/3, Downloaded by 480  Comments, bugs, improvements  Vim wiki

created by
Sergei Mironov
 
script type
utility
 
description
This script interfaces the Litrepl tool which executes Markdown/LaTeX code snippets by forking standalone interpreters.
For instance, when entering `:LEval` on the following Python code snippet:

``` python
print("Hello!")
```

the contents of the next result section (which should also exist in the document) will be replaced with the string "Hello!" :

``` result
Hello!
```

In other words, this is a text-mode Jupyter Notebook with no custom JSONs or web-servers involved.

The interpreter will be running in the background waiting for new snippets to evaluate. By default, the
interpreter is shared among the files of the same directory. For LaTeX code section formatting, please
check the repository docs.

The supported code section labels and interpreters are:

* `python` sections - get redirected to the default `Python` or to the enhanced `IPython` interpreter
* `sh` sections - a Bourne Shell family of the interpreters, defaulting to the `/bin/sh`
* `ai` sections - a minimalistic `Aicli` interpreter for talking with AI language models

Command basics:

* `:LEval` - Evaluate the section under the cursor.
* `:LStatus` - Show the status of the interpreters.
* `:LRestart (python|sh|ai)` - Restart the background interpreter.
* `:LTerm (python|sh|ai)` - Attach to the interpreter using Vim terminal


Recently, several AI-related commands were introduced in `litrepl_extras.vim`, showcasing the power
of litrepl's session management capabilities. These commands require the third-party Aicli
interpreter where the GPT-4o model is set as default:

* `:LAICode` - Asks the AI model to revise a selected code snippet.
* `:LAIStyle` - Requests the AI to enhance the style of selected text.
* `:LAICont` - Asks the AI model to modify the previous AI-related change.
* `:LAITell` - Proceeds with the dialogue with the AI model within the Vim terminal.

These commands are built upon the base `LitReplAIQuery()` function. They can be seen as examples
demonstrating how you might create additional commands tailored to your project's needs.

 
install details
1. Install the Litrepl tool using the Python's default package manager: `pip install litrepl`.
2. Unpack the plugin tarball and put `litrepl.vim` and `litrepl_extras.vim` into the `~/.vim/plugin` folder.
3. Optionally install socat tool using your system package manager, e.g. `sudo apt-get install socat`.
4. Optionally install Aicli interpreter by `pip install sm_aicli`. Create the suitable `.aicli` config setting
    up a GPT-4o model as the default actor.

For other installation methods and additional options please visit https://github.com/sergei-mironov/litrepl
For details on the Aicli interpreter, check https://github.com/sergei-mironov/aicli

Note: Litrepl tool relies on POSIX OS interface and was tested on Linux only. The author is interested in getting
feedback from MacOS and WSL users! In any case, feel free to open Github issues.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-litrepl-3.11.0-fb83a1b.tar.gz 3.11.0 2024-12-27 9.0 Sergei Mironov Supported the shell family of interpreters; Made code section names adjustable; Fixed cursor handling in `LEvalMon`; Improved error reporting
vim-litrepl-3.10.2-7da8902.tar.gz 3.10.2 2024-12-14 9.0 Sergei Mironov Bug fixes
vim-litrepl-3.10.1-5ff1436.tar.gz 3.10.1 2024-12-12 9.0 Sergei Mironov Bug fixes; Buffer-local versions of all variables are recognized; Environment versions of directory variables are recognized; Updated AI extra commands
vim-litrepl-3.9.0-6a46be1.tar.gz 3.9.0 2024-11-28 9.0 Sergei Mironov Bug fixes; litrepl_extras.vim updated with better AI commands
vim-litrepl-3.8.2-d04b24c.tar.gz 3.8.2 2024-11-19 9.0 Sergei Mironov A number of bugfixes; Introducing `litrepl_extras.vim` featuring LAI command piping the selection through the `aicli` interpreter
vim-litrepl-3.7.4-3b713ff.tar.gz 3.7.4 2024-11-16 9.0 Sergei Mironov Minor fixes, updated to support aicli-2.x.x
vim-litrepl-3.7.3-6284bc9.tar.gz 3.7.3 2024-10-24 9.0 Sergei Mironov Add `LitReplEvalSelection(type)` function
vim-litrepl-3.7.0-b950648.tar.gz 3.7.0 2024-08-24 9.0 Sergei Mironov Verbatim `<!--ai-->/<!--noai--><!--result-->/<!--noresult-->` markdown markup is now supported; Old-style conflicting `<!--code` options are removed;
vim-litrepl-3.5.3-c42c33f.tar.gz 3.5.3 2024-08-03 9.0 Sergei Mironov Fix `LTerm` command, Improve error reporting
vim-litrepl-3.5.2-25fb9d6.tar.gz 3.5.2 2024-08-03 9.0 Sergei Mironov Improve error reporting
vim-litrepl-3.5.1-4f84c7e.tar.gz 3.5.1 2024-08-03 9.0 Sergei Mironov Initial upload
ip used for rating: 18.97.9.168

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github