blob: a9d853a6451236d203447ab9c87e56042f645bdc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/sh
## A poor man's offline Rust playground.
#
# A simple cargo extension to setup and start a simple Rust project.
#
# Usage:
#
# cargo play [<name>]
#
# where `<name>` is the name of the project. If no name is provided a temporary
# directory will be used instead.
#
# Requires:
# - neovim
# - entr (http://eradman.com/entrproject/)
# - cargo
#
# TODO:
# - add ability to pass `cargo init` arguments
# - make `entr` detect new files
PLAY=""
BASE="$GIT/play"
# Check whether the script was invoked as a cargo command (i.e., `cargo play`).
[ "$1" = "play" ] && shift
if [ -z "$1" ] ; then
PLAY=$(mktemp -d --tmpdir "rustplay_XXXXX")
else
PLAY="$BASE/$1"
mkdir -p "$PLAY"
shift
fi
cd "$PLAY" || exit 1
cargo init
# Start neovim with automatic compilation on save on a side terminal
nvim '+vertical split | terminal ls src/* | entr -cs "cargo run"' '+wincmd p' src/main.rs
|