You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: doc/sources/README.md
+16-12
Original file line number
Diff line number
Diff line change
@@ -71,16 +71,18 @@ Sniprun will then:
71
71
72
72
## Prerequisites && dependencies
73
73
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.
75
75
76
76
-**Neovim** version >= 0.5
77
77
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).
79
79
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.
81
81
82
82
-[optional] the plugin [nvim-notify](https://github.com/rcarriga/nvim-notify) for the notification display style
83
83
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
+
84
86
## Install Sniprun
85
87
86
88
### Use your favorite plugin manager (recommended) ...
@@ -339,7 +341,7 @@ All of sniprun functionalities:
339
341
340
342
(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/)).
341
343
342
-
<details><summary> recommended mappings in lua</summary>
344
+
<detailsopen><summary> recommended mappings in lua</summary>
<detailsopen><summary> recommended mappings in vimscript</summary>
355
+
<details><summary> recommended mappings in vimscript</summary>
354
356
<p>
355
357
356
358
```
@@ -361,7 +363,7 @@ vmap f <Plug>SnipRun
361
363
</details>
362
364
</p>
363
365
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.
365
367
366
368
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).
367
369
@@ -439,21 +441,22 @@ Want (official) support for your language? Submit an [issue](https://github.com/
439
441
440
442
\*\* True REPL under the hood
441
443
442
-
\*\*\*if underlying language supports it
444
+
\*\*\*REPL-like functionality if language in code block supports it
443
445
444
446
(livemode)=
445
447
# Live mode
446
448
447
449
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.
448
450
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).
450
452
451
453
## Warnings
452
454
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
+
454
457
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:
457
460
- never run bash/shell with live mode
458
461
- disable the live mode whenever your code modifies files or invoke system commands.
459
462
@@ -512,6 +515,7 @@ Due to its nature, Sniprun may have trouble with programs that :
512
515
Begin by updating the plugin and running `:SnipReset` and then `:checkhealth sniprun`
513
516
514
517
-**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.
515
519
516
520
# Contribute
517
521
@@ -534,7 +538,7 @@ And many more projects, somewhat similar, but never quite, that I didn't like, n
534
538
535
539
**Why should you use sniprun instead of these alternatives?**
536
540
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)
538
542
-**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).
539
543
-**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.
Copy file name to clipboardexpand all lines: doc/sources/common_options.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -120,6 +120,6 @@ sniprun internally expect, or be straight out incompatible with the formers. Be
120
120
121
121
Exceptions:
122
122
- 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.
Copy file name to clipboardexpand all lines: doc/sources/interpreters/Ada_original.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
## Ada original
2
2
3
3
4
-
dependencies: Need gcc-ada and gnatmake
4
+
dependencies: Need `gcc-ada` and `gnatmake`
5
5
6
6
7
7
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
Copy file name to clipboardexpand all lines: doc/sources/interpreters/C_original.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
## C original
2
2
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:
4
4
5
5
6
-
```
6
+
```lua
7
7
require'sniprun'.setup({
8
8
interpreter_options= {
9
9
C_original= {
@@ -14,7 +14,7 @@ require'sniprun'.setup({
14
14
})
15
15
```
16
16
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`.
18
18
19
19
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
20
20
@@ -27,7 +27,7 @@ the C\_original interpreter will also make use of the following environment vari
27
27
-`$CFLAGS`
28
28
29
29
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!
31
31
32
32
33
33
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.
Copy file name to clipboardexpand all lines: doc/sources/interpreters/Cpp_original.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@
3
3
Limitations
4
4
5
5
- 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)
Copy file name to clipboardexpand all lines: doc/sources/interpreters/Generic.md
+8-8
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
## Generic
2
2
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
4
4
5
5
If you're trying to override an already-supported language, add Generic to the list of selected interpreters:
6
6
7
7
8
-
```
8
+
```lua
9
9
require'sniprun'.setup({
10
10
selected_interpreters= { 'Generic' },
11
11
})
@@ -14,7 +14,7 @@ require'sniprun'.setup({
14
14
to add support for, let's say, python2
15
15
16
16
17
-
```
17
+
```lua
18
18
require'sniprun'.setup({
19
19
interpreter_options= {
20
20
Generic= {
@@ -24,7 +24,7 @@ require'sniprun'.setup({
24
24
extension=".py", -- recommended, but not mandatory. Sniprun use this to create temporary files
25
25
26
26
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
28
28
}
29
29
}
30
30
}
@@ -35,7 +35,7 @@ require'sniprun'.setup({
35
35
to also add support for, let's suppose it wasn't officially supported, C
36
36
37
37
38
-
```
38
+
```lua
39
39
require'sniprun'.setup({
40
40
interpreter_options= {
41
41
Generic= {
@@ -57,7 +57,7 @@ require'sniprun'.setup({
57
57
extension=".c",
58
58
59
59
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)
61
61
62
62
exe_name="my_main", -- executable name, by default a.out (always in sniprun's work directory)
63
63
boilerplate_pre="#include <stdio.h>\nint main () {" -- include this before code snippets
@@ -66,8 +66,8 @@ require'sniprun'.setup({
66
66
}
67
67
},
68
68
69
-
-- other sniprun options, for example:
70
69
selected_interpreters= {"Generic"}
70
+
-- other sniprun options ...
71
71
})
72
72
```
73
73
@@ -91,4 +91,4 @@ require'sniprun'.setup({
91
91
92
92
### Community examples for non-officially supported languages
0 commit comments