Coder Social home page Coder Social logo

michaelb / sniprun Goto Github PK

View Code? Open in Web Editor NEW
1.4K 8.0 45.0 14.3 MB

A neovim plugin to run lines/blocs of code (independently of the rest of the file), supporting multiples languages

License: MIT License

Rust 93.18% Shell 2.07% Python 0.24% Lua 4.43% Vim Script 0.08%
code neovim runner languages interpreter compiled-language interpreted-language partial-evaluators neovim-plugin plugin

sniprun's Introduction

Introduction

Sniprun is a code runner plugin for neovim written in Lua and Rust. It aims to provide stupidly fast partial code testing for interpreted and compiled languages. Sniprun blurs the line between standard save/run workflow, jupyter-like notebook, and REPL/interpreters.


TLDR: Plug 'michaelb/sniprun', {'do': 'sh install.sh'}, :SnipRun, :'<,'>SnipRun, :SnipInfo

Installation, configuration, ...

See installation instructions, configuration tips, usage explanations and much more useful information on the WIKI.

Demos

Send to Sniprun snippets of any language.

A very simple example (in C), play the .gif and look in the command area:

The result can be returned in multiple (even at the same time) ways:
Classic Virtual Text
Temporary Floating Window Terminal
Notification API
REPL-like behavior is available for some languages

Python, Julia, Lua, JavaScript & Typescript (via deno), Clojure, R, Mathematica, Sage, coming soon for many other interpreted (and compiled) languages. With REPL-like behavior, you can run code dependent on previously executed code, just like in a REPL, from within your favorite editor.

Features

Sniprun is a way to quickly run small snippets of code, on the fly, and iterate very quickly and conveniently. To learn a language, to quickly experiment with new features (not yet embedded in classes or a whole project etc...), or to develop simple code pipelines (like a machine learning exercise) that fit in a unique file, sniprun is probably the best plugin out there.

As a matter of proof, Sniprun :

  • Officially supports all these languages (compiled & interpreted), and virtually any language
  • can create and connect to REPLs in order to present an interactive and playful interface
  • can run things like GUI plots, networks requests or even Ansible playbooks
  • doesn't require even one line of configuration by default (but can be customized up to the tiniest things)
  • can run code from a part of a file which isn't complete / contains errors
  • can automatically fetch (in some languages) the imports necessary for your code snippet
  • can run live (at every keystroke)
  • lends itself to easy mappings and Vim motions
  • has an API (for running code, and displaying results)
  • has many result display modes that can be enabled at the same time, and for different output status if wanted
  • supports literate programming in Markdown, Orgmode and Neorg

Known limitations

Due to its nature, Sniprun may have trouble with programs that :

  • Mess with standard output / stderr
  • Need to read from stdin
  • Access files; sniprun does not run in a virtual environment, it accesses files just like your own code do, but since it does not run the whole program, something might go wrong. Relative paths may cause issues, as the current working directory for sniprun will be somewhere in ~/.cache/sniprun, and relative imports may miss.
  • No support for Windows
  • NixOS, MacOS users have to compile sniprun locally. Sniprun has not been tested on other Unixes

Changelog

It's been quite a journey already! For history fans, see the full changelog.

Contributing

Sniprun has been made contributor-friendly (see CONTRIBUTING.md), so it's relatively easy to create / fix interpreters for any language. But any (constructive) issue, discussion, or doc Pull Request is a welcome form of contribution !

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.