Skip to content

yeasin50/manim.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

manim.nvim

A small Neovim plugin to run Manim scenes directly from your editor. Pick the class under the cursor and play it in your terminal without leaving Neovim.


✨ Features

  • Multi-core rendering for faster project exports. All files at once.
  • Plays animations from the cursor.
  • Detects the class under your cursor and ensures import manim is present.
  • Checks for a valid manim executable:
    • Uses system manim if available (didn’t test).
    • Falls back to a provided virtual environment (venv).
  • Configurable play/export arguments.

You have to open terminal (toggleterm) for the first time.


Compatibility

This plugin has been tested with:

  • Manim Community Edition v0.19.0

📦 Installation

Using lazy.nvim:

{
   "yeasin50/manim.nvim",
    cmd = { "ManimCheck", "ManimPlay" , "ManimExport", "ManimExportProject", "ManimPlayFrom"},
    ft = "python",
    keys = {
       -- modify  as your will
       -- { "<leader>c", "<cmd>ManimCheck<cr>", desc = "Check Manim availability" },
        { "<leader>m", "<cmd>ManimPlay<cr>",  desc = "Play Manim class" },
    },

    config = function()
        require("manim").setup({
            manim_path = "manim", -- system binary
            venv_path = "/home/...../manim/env", -- optional but if you are just using environment,provide full path
            play_args = { "-pql" }, -- quality/preview args
			export_args = {
				"-qk",
				"--media_dir=/home/..../manim_output",
				"--transparent",
			},
        },
     project_config = {
                    resolution = {3840, 2160},           -- width x height
                    fps = 60,                             -- frames per second
                    transparent = true,                   -- transparent background
                    export_dir = "/home/youruser/Videos/manim_exports", -- output directory
                    max_workers = 3,                      -- number of concurrent renders
                    ignore_files = {"common.py", "export.py"},         -- files to skip
                    failed_list_file = "failed_files.txt",             -- log failures
                }
        )
    end,
}

🚀 Usage

  1. Open a Python file that contains Manim scenes.
  2. Make sure it has import manim or from manim import ... at the top.
  3. Place your cursor inside the class definition of the scene you want to render.
  4. Run one of the commands: or use keymap
Command Description
:ManimCheck Verifies Manim is available (system binary or virtual environment).
:ManimPlay Renders and plays the scene class under the cursor.
:ManimPlayFrom Renders and plays the scene from the cursor line, injecting self.next_section().
:ManimExport Exports the scene under the cursor using export_args.
:ManimExportProject Exports all scene files in the project using the Python export script and multi-core rendering.

For project export make sure you are at the root of the project where it will have multiple python files.

Example

from manim import *

class Title(Scene):
    def construct(self):
        self.add(Text("Hello from Manim!"))

If your cursor is inside Title and you run:

:ManimPlay

The plugin will send this command to your terminal:

manim -pql test.py Title

TODO:

  • project based configs
  • Export multi-core
  • play from cursor
  • without toggleterm dependency(but I use it, so maybe I won't work on it
  • ....

About

Play and preview Manim Community scenes directly from Neovim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published