Skip to content

Commit 30991d8

Browse files
authored
Merge pull request #287 from michaelb/dev
v1.3.14
2 parents 1420cff + 5d663d8 commit 30991d8

35 files changed

+96
-79
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v1.3.14
2+
- Improve Lua\_nvim's handling of 'local' requires in REPL mode
3+
14
## v1.3.13
25
- Support Python import list syntax
36

CHECKLIST.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# External contributions
22
- only accept contributions to 'dev' branch OR release immediately after
3+
(doc contribution can be exempted)
34

45
# Prepare the release
56

Cargo.lock

+4-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sniprun"
3-
version = "1.3.13"
3+
version = "1.3.14"
44
authors = ["michaelb <[email protected]>"]
55
rust-version = "1.65"
66
edition = "2018"
@@ -29,6 +29,7 @@ serial_test = "2.0"
2929

3030
# jupyter-client = { git = "https://gitlab.com/srwalker101/rust-jupyter-client.git", branch = "dev" }
3131

32+
rmp = "=0.8.8" # fix rmp version because it breaks MSRV
3233

3334
# Python3 interpreter
3435
unindent = "0.2"

doc/sources/README.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,18 @@ Sniprun will then:
7171

7272
## Prerequisites && dependencies
7373

74-
- Sniprun is compatible with **Linux** and **MacOS**. (NixOS and Mac users _need_ the Rust [toolchain](https://www.rust-lang.org/tools/install) version >= 1.65 ). Standard POSIX utilities (grep, cut, sed ...) may be needed too, depending on the languages you want support for.
74+
- Sniprun is compatible with **Linux** and **MacOS**. (NixOS and Mac users _need_ the Rust [toolchain](https://www.rust-lang.org/tools/install) version >= 1.65, in order to compile sniprun locally). Standard POSIX utilities (grep, cut, sed ...) may be needed too, depending on the languages you want support for.
7575

7676
- **Neovim** version >= 0.5
7777

78-
- **Compiler / interpreter** for the languages you work with must be installed & on your \$PATH. In case specific build tools or softwares are required, those are documented in the navigation pane of the [wiki](https://michaelb.github.io/sniprun/), as well as in the [doc/sources/interpreters](https://github.com/michaelb/sniprun/tree/master/doc/sources/interpreters) folder, for each interpreter, which I urge you to get a look at before getting started as it also contains the potential limitations of each interpreter; this information can be accessed through `:SnipInfo <interpreter_name>` (tab autocompletion supported).
78+
- **Compiler / interpreter** for the languages you work with must be installed & on your \$PATH. In case non-standard build tools or softwares are required, those are documented in the navigation pane of the [wiki](https://michaelb.github.io/sniprun/), as well as in the [doc/sources/interpreters](https://github.com/michaelb/sniprun/tree/master/doc/sources/interpreters) folder, for each interpreter, which I urge you to get a look at before getting started as it also contains the potential limitations of each interpreter; this information can be accessed through `:SnipInfo <interpreter_name>` (tab autocompletion supported).
7979

80-
- [optional] **cargo and the rust toolchain** version >= 1.65 (you can find those [here](https://www.rust-lang.org/tools/install)).
80+
- [optional] **cargo and the rust toolchain** version >= 1.65 (you can find those [here](https://www.rust-lang.org/tools/install)), if you want/need to compile sniprun locally.
8181

8282
- [optional] the plugin [nvim-notify](https://github.com/rcarriga/nvim-notify) for the notification display style
8383

84+
Note: Since sniprun is written in Rust and many users may not have/want a Rust toolchain, a binary compiled from a Github Action gets downloaded from Releases. If you don't want that, just install a Rust toolchain and replace the install.sh invocation in your config by `cargo build --release`.
85+
8486
## Install Sniprun
8587

8688
### Use your favorite plugin manager (recommended) ...
@@ -339,7 +341,7 @@ All of sniprun functionalities:
339341

340342
(if you don't know what is the leader key you can find a short explanation [here](https://vim.works/2019/03/03/vims-leader-key-wtf-is-it/)).
341343

342-
<details><summary> recommended mappings in lua</summary>
344+
<details open><summary> recommended mappings in lua</summary>
343345
<p>
344346

345347
```
@@ -350,7 +352,7 @@ vim.api.nvim_set_keymap('n', '<leader>ff', '<Plug>SnipRun', {silent = true})
350352
</details>
351353
</p>
352354

353-
<details open><summary> recommended mappings in vimscript</summary>
355+
<details><summary> recommended mappings in vimscript</summary>
354356
<p>
355357

356358
```
@@ -361,7 +363,7 @@ vmap f <Plug>SnipRun
361363
</details>
362364
</p>
363365

364-
- For interpreted languages with simple output, `:%SnipRun` (or a shortcut, wrapping it with `let b:caret=winsaveview()` and `call winrestview(b:caret)` in order to keep the cursor at the current position) may be a more convenient way to run your entire file. Example mapping `:%SnipRun` to F5: `vim.keymap.set('n', '<F5>', ":let b:caret=winsaveview() <CR> | :%SnipRun <CR>| :call winrestview(b:caret) <CR>", {})`, with my apologies for poor vimscript.
366+
- For interpreted languages with simple output, `:%SnipRun` (or a shortcut, wrapping it with `let b:caret=winsaveview()` and `call winrestview(b:caret)` in order to keep the cursor at the current position) may be a more convenient way to run your entire file. Example mapping `:%SnipRun` to F5: `vim.keymap.set('n', '<F5>', ":let b:caret=winsaveview() <CR> | :%SnipRun <CR>| :call winrestview(b:caret) <CR>", {})`, with my apologies for poor vimscript-fu.
365367

366368
When running the whole file, SnipRun supports taking arguments on the command line: `:%SnipRun 5 "yay"` frictionlessly for interpreted languages, and compiled languages with entry point detection implemented (most of them).
367369

@@ -439,21 +441,22 @@ Want (official) support for your language? Submit an [issue](https://github.com/
439441

440442
\*\* True REPL under the hood
441443

442-
\*\*\* if underlying language supports it
444+
\*\*\* REPL-like functionality if language in code block supports it
443445

444446
(livemode)=
445447
# Live mode
446448

447449
The live mode hooks the SnipRun command to the TextChanged event, meaning that at every change to make to the buffer, the current line will be sent to sniprun for evaluation. This can mean a lot of times, especially if you type fast.
448450

449-
The result is a virtual text, displaying at the end of the current line that print the result (stdout) of the line. Nothing is displayed when the line is incomplete / incorrect, a bit like codi.
451+
The result is a virtual text, displaying at the end of the current line that print the result (stdout) of the line. Nothing is displayed when the line is incomplete / incorrect, a bit like [codi.vim](https://github.com/metakirby5/codi.vim).
450452

451453
## Warnings
452454

453-
The live mode **will execute code you didn't think really about** (and by that I mean even less than usual)
455+
The live mode **will execute code you didn't think really about** (and by that I mean even less than usual).
456+
454457
Thus:
455-
- Your code will get executed **lots** of times; check that your CPU can keep up. Even a slow 60wpm typing can make a Rust program recompile 3x per second, which is also different from sending 3 string/s to a running REPL.
456-
- Sniprun will try to execute even incomplete lines. You hadn't finished typing that `rm /path/to/arghhh` ? sniprun' not aware and removed the parent directory. Whoops. For these reasons, I strongly suggest to:
458+
- Your code will get executed **lots** of times; check that your CPU can keep up. Even a 'slow' 30wpm typing can trigger constant program recompiles.
459+
- Sniprun will try to execute even incomplete lines, example: you hadn't finished typing that `rm /path/to/arghhh` ? Sniprun saw you submitting `rm /path` and removed the parent directory. For these reasons, I strongly suggest to:
457460
- never run bash/shell with live mode
458461
- disable the live mode whenever your code modifies files or invoke system commands.
459462

@@ -512,6 +515,7 @@ Due to its nature, Sniprun may have trouble with programs that :
512515
Begin by updating the plugin and running `:SnipReset` and then `:checkhealth sniprun`
513516

514517
- **Silent fail**: the sniprun binary may be incompatible with your distro/OS/arch. Use `sh ./install.sh 1` as post-install to compile locally.
518+
- Any other kind of bug: a log file is produced in $XDG\_CACHE\_DIR/sniprun (~/.cache/sniprun on Linux or ~/Library/Caches/sniprun on MacOS), usually with all kinds of information of what happened during your last command.
515519

516520
# Contribute
517521

@@ -534,7 +538,7 @@ And many more projects, somewhat similar, but never quite, that I didn't like, n
534538

535539
**Why should you use sniprun instead of these alternatives?**
536540

537-
- **All-language support**. Sniprun can work with virtually any language, including compiled ones. If the language is not supported yet, anyone can create a sniprun interpreter for it!
541+
- **All-language support**. Sniprun can work with virtually any language, including compiled ones. If the language is not supported yet, anyone can create a sniprun interpreter for it! (or more simply, configure the generic interpreter)
538542
- **Better output/display**. Sniprun doesn't use precious screen space (like [codi](https://github.com/metakirby5/codi.vim) or [vim-slime](https://github.com/jpalardy/vim-slime)) by default (but it can).
539543
- **Fast, extendable and maintainable**: this is not a 2k-lines vim script, nor an inherently limited one-liner. It's a Rust project designed to be as clear and "contribuable" as possible.
540544

doc/sources/common_options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ sniprun internally expect, or be straight out incompatible with the formers. Be
120120

121121
Exceptions:
122122
- Scala_original has both interpreter and compiler keys that should be set consistently with each other
123-
- *_jupyter, Generic, GFM_original, Orgmode_original, and Neorg_original do not support any of these keys
123+
- *_jupyter, Generic, GFM_original, Orgmode_original, and Neorg_original do not support any of these keys, as they rely on the interpreter for the code's block language.
124124

125125

doc/sources/interpreters/Ada_original.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Ada original
22

33

4-
dependencies: Need gcc-ada and gnatmake
4+
dependencies: Need `gcc-ada` and `gnatmake`
55

66

77
Note: because Ada needs variables to be declared before the begin (in a non contiguous section of the file), SnipRun is not very useful here and will, in practice, only be able to run blocs like

doc/sources/interpreters/CSharp_original.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This interpreter require the `mono` toolbox to be installed: `csc` and `mono` mu
44

55
a custom compiler can be specified :
66

7-
```
7+
```lua
88
require'sniprun'.setup({
99
interpreter_options = {
1010
CSharp_original = {

doc/sources/interpreters/C_original.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
## C original
22

3-
gcc is recommended, for that it's able to detect, compile and run nested functions, however you can change the default compiler with:
3+
`gcc` is recommended, for that it's able to detect, compile and run nested functions, however you can change the default compiler with:
44

55

6-
```
6+
```lua
77
require'sniprun'.setup({
88
interpreter_options = {
99
C_original = {
@@ -14,7 +14,7 @@ require'sniprun'.setup({
1414
})
1515
```
1616

17-
If you run with GCC, Sniprun will be able to run function + code in the same snippet, or functions + main() function regardlessly,but only the latter is supported by clang.
17+
If you run with GCC, Sniprun will be able to run function + code in the same snippet, or functions + main() function regardlessly, but only the latter is supported by `clang`.
1818

1919
This interpreter will also only import (all) #include \<...> but not any #include "..." (systems-wide include only, not the headers from your project, unless the environment variable `$C_INCLUDE_PATH` or `$CPLUS_INCLUDE_PATH` have been set). In this case, please make sure those variable cover **ALL** the paths needed to fetch every header file `#include`'d
2020

@@ -27,7 +27,7 @@ the C\_original interpreter will also make use of the following environment vari
2727
- `$CFLAGS`
2828

2929

30-
and will add them to the build options it uses. Please specify _absolute path_, and not relative ones!
30+
and will add them to the build options it uses. Please specify _absolute paths_, and not relative ones!
3131

3232

3333
Using a tool such as [direnv](https://direnv.net/) may be really useful to set up those variables when you `cd` into your project' directory.

doc/sources/interpreters/Clojure_fifo.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ The default interpreter command is `clojure` (or `clojure -e "(clojure.main/repl
77

88

99
The defaults are equivalent to specifying:
10-
```
10+
11+
```lua
1112
require'sniprun'.setup({
1213
interpreter_options = {
1314
Clojure_fifo = {

doc/sources/interpreters/Cpp_original.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
Limitations
44

55
- Will only look and load external imports (include) that are SYSTEM import; as sniprun does not have any way to differentiate between #include "math.h" (the system library) and #include "math2.h" (your custom header), it will NOT look for #include "....", but only #include \<....> (those are restricted to system libraries).
6-
- Need 'g++' (or specifiy another compiler in configuration)
6+
- Need `g++` (or specify another compiler in configuration)
77

8-
```
8+
```lua
99
require'sniprun'.setup({
1010
interpreter_options = {
1111
Cpp_original = {
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## D original
22

3-
For the D language, needs the 'dmd' executable
3+
For the D language, needs the `dmd` executable
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## Elixir original
22

3-
Needs "elixir" (or "iex" for REPL mode) available and in $PATH)
3+
Needs `elixir` (or `iex` for REPL mode) available and in $PATH)

doc/sources/interpreters/FSharp_fifo.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
The default interpreter command is `dotnet fsi --nologo` but it can be changed via the configuration key
77

88

9-
```
9+
```lua
1010
require'sniprun'.setup({
1111
interpreter_options = {
1212
FSharp_fifo = {

doc/sources/interpreters/GFM_original.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ done
2525
### example 2
2626

2727

28-
\``rust << running on this line will run the entire bloc
28+
\```rust << running on this line will run the entire bloc
2929

3030
println!("test");
3131

@@ -36,11 +36,11 @@ println!("test");
3636

3737
\* python, but you can ofc configure that:
3838

39-
```
39+
```lua
4040
require'sniprun'.setup({
4141
interpreter_options = {
4242
GFM_original = {
43-
default_filetype = 'bash' -- default filetype (not github flavored markdown name)
43+
default_filetype = 'bash' -- default filetype (not 'github flavored markdown 'name' of the language, as they are sometimes different)
4444
}
4545
}
4646
})

doc/sources/interpreters/Generic.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## Generic
22

3-
This interpreter allows you to support virtually any language, provided it's not to strange, at up to bloc-level
3+
This interpreter allows you to support virtually any language, provided it's not too strange, at up to bloc-level
44

55
If you're trying to override an already-supported language, add Generic to the list of selected interpreters:
66

77

8-
```
8+
```lua
99
require'sniprun'.setup({
1010
selected_interpreters = { 'Generic' },
1111
})
@@ -14,7 +14,7 @@ require'sniprun'.setup({
1414
to add support for, let's say, python2
1515

1616

17-
```
17+
```lua
1818
require'sniprun'.setup({
1919
interpreter_options = {
2020
Generic = {
@@ -24,7 +24,7 @@ require'sniprun'.setup({
2424
extension = ".py", -- recommended, but not mandatory. Sniprun use this to create temporary files
2525

2626
interpreter = "python2", -- interpreter or compiler (+ options if any)
27-
compiler = "", -- one of those MUST be non-empty
27+
compiler = "", -- exactly one of those MUST be non-empty
2828
}
2929
}
3030
}
@@ -35,7 +35,7 @@ require'sniprun'.setup({
3535
to also add support for, let's suppose it wasn't officially supported, C
3636

3737

38-
```
38+
```lua
3939
require'sniprun'.setup({
4040
interpreter_options = {
4141
Generic = {
@@ -57,7 +57,7 @@ require'sniprun'.setup({
5757
extension = ".c",
5858

5959
interpreter = "",
60-
compiler = "gcc -o my_main -O3", -- compiler (+ options if necessary) (current working directory is sniprun's work directory)
60+
compiler = "gcc -o my_main -O3", -- compiler (+ options if necessary) (current working directory is sniprun's work directory - next to sniprun's log in $XDG_CACHE_DIR)
6161

6262
exe_name = "my_main", -- executable name, by default a.out (always in sniprun's work directory)
6363
boilerplate_pre = "#include <stdio.h>\nint main () {" -- include this before code snippets
@@ -66,8 +66,8 @@ require'sniprun'.setup({
6666
}
6767
},
6868

69-
-- other sniprun options, for example:
7069
selected_interpreters = {"Generic"}
70+
-- other sniprun options ...
7171
})
7272
```
7373

@@ -91,4 +91,4 @@ require'sniprun'.setup({
9191

9292
### Community examples for non-officially supported languages
9393

94-
(contribute here)
94+
(contribute here: doc/sources/interpreters/Generic.md)

doc/sources/interpreters/Go_original.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## Go original
2-
the executable (go , llgo or whatever) executable used to _build_ the snippet can be configured via
2+
the executable (`go` , `llgo` or whatever) executable used to _build_ the snippet can be configured via
33

44

5-
```
5+
```lua
66
require'sniprun'.setup({
77
interpreter_options = {
88
Go_original = {

doc/sources/interpreters/Haskell.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## Haskell original
22

3-
require the 'ghc' compiler and the base libraries such as haskell-base-prelude
3+
require the `ghc` compiler and the base libraries such as haskell-base-prelude

doc/sources/interpreters/JS_TS_bun.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ But the REPL is VERY quirky (and even has a greeting saying it's unstable)
1111
It doesn't play well at all with sniprun's stdin-stdout mechanism, so while basic examples are working,
1212
I can't consider this a 'daily driver'... so REPL is disabled by default
1313

14-
```
14+
```lua
1515
require('sniprun').setup({
1616
selected_interpreters={"JS_TS_bun"},
1717
repl_enable={"JS_TS_bun"}
@@ -27,7 +27,7 @@ sniprun runs your code snippets with
2727

2828
more arguments for `bun run` can be added with the interpreter option:
2929

30-
```
30+
```lua
3131
require'sniprun'.setup({
3232
interpreter_options = {
3333
JS_TS_bun = {

doc/sources/interpreters/JS_TS_deno.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A REPL-capable (not enabled by default) Typescript / Javascript interpreter.
44

55
`deno` needs to be installed and on your path (and working). The precise command used by sniprun is `deno repl -q`
66

7-
```
7+
```lua
88
require('sniprun').setup({
99
selected_interpreters={"JS_TS_deno"},
1010
repl_enable={"JS_TS_deno"}

0 commit comments

Comments
 (0)