Git Product home page Git Product logo

vim-manim's Introduction

vim-manim

A tiny plugin to render animations with manim ce without leaving Vim.

Written in Vim9.

Usage

Commands

This plugin provides only two commands:

Type :Manin then hit <tab> to select a Scene. Then hit <space> and <tab> again to select a list of rendering flags.

Type :ManimCheck to perform a check on your manim installation.

The rendering output is stored in the quickfix list. Type :copen and :cclose to open/close the quickfix list. See :h quickfix.txt for more info.

Events

Two events ManimPre and ManimPost are also provided. The former triggers actions before the actual manim program is executed, whereas the latter just after. As an example of usage, you may consider the following:

autocmd! User ManimPre echom "Manim renderer is being called..."
autocmd! User ManimPost echom "Rendering done! Check eventual errors."

See :h autocommand for more info on Vim autocommands.

Configuration

There are only two configuration variables: g:manim_flags and g:manim_default_flag.

The former is a dictionary where the keys are tags and the values are the actual rendering flags. For example, you could define:

var manim_common_flags = '--fps 30 --disable_caching -v WARNING'
g:manim_flags = {'low_quality': $"-pql {manim_common_flags}",
                'high_quality': $"-pqh -c ~/my_config.cfg {manim_common_flags}",
                'transparent': $"-pqh -c ~/my_config.cfg {manim_common_flags} --transparent"}

Note

No spaces are allowed in the dictionary keys!

The latter is a default flag that must be a key of g:manim_flags. For example, you could set the following:

g:manim_default_flag = keys(g:manim_flags)[-1]

If such variables are not set by the user, the following default values are provided:

g:manim_flags = {'low_quality': $"-pql"}
g:manim_default_flag = keys(g:manim_flags)[0]

Enjoy!

What about docs?

You don't really need a plugin for that. It is enough that you define your own command in e.g. your .vimrc, or, even better, in your ~/.vim/after/ftplugin/python.vim file (replace .vim with vimfiles if you are using Windows). You can for example have something like the following:

    if executable("open")
        command! ManimDocs silent :!open -a safari.app
                \ ~/Documents/manimce-latest/index.html
    elseif executable("xdg-open")
        command! ManimDocs silent :!xdg-open
                \ https://docs.manim.community/en/stable/
    else
        command! ManimDocs silent :!start
                \ ~/Somepath/manimce-0.18.0/index.html
    endif

Change the above according to your setup. Then, run :ManimDocs to open the doc page.

Tip

Having your docs stored somewhere locally is obviously much faster to open doc pages. But don't forget to update them when you install a newer version of manim.

License

BSD3-Clause.

vim-manim's People

Contributors

ubaldot avatar

Stargazers

Andres Mendez  avatar  avatar Colin Kennedy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.