Skip to content

Commit

Permalink
Merge pull request #145 from michaelb/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
michaelb authored Feb 9, 2022
2 parents 8567986 + 1dd5629 commit 91653fc
Show file tree
Hide file tree
Showing 12 changed files with 834 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ coverage:
patch:
default:
target: 1%
threshold: 1%
threshold: 90%
path: "src"

project:
default:
target: 50%
threshold: 50%
target: 1%
threshold: 90%
path: "src"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v1.2.1
- F# support
- Fix multiline display in floating windows
- Deno brings REPL support for Javascript and TypeScript

## v1.2
- Live mode (a @ChristianChiarulli idea and partial realisation)
- Lower ressources usage for REPL interpreters
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sniprun"
version = "1.2.0"
version = "1.2.1"
authors = ["michaelb <[email protected]>"]
edition = "2018"

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,11 @@ println!("-> {}", alphabet);
| C++ | Import | No |
| Coffeescript | Bloc | No |
| D | Bloc | No |
| F# | Bloc | No, but _could_ \*\* |
| Go | Bloc | No |
| Haskell | Line | No |
| Java | Bloc | No |
| JavaScript | Bloc | No |
| JavaScript | Bloc | Yes\*\* (Deno)|
| Julia | Bloc | Yes\*\* |
| Lua | Bloc | No |
| Lua-nvim | Bloc | Yes\*\* |
Expand All @@ -448,8 +449,7 @@ println!("-> {}", alphabet);
| Rust | Bloc | No |
| SageMath | Import | Yes\*\* |
| Scala | Bloc | No |
| TypeScript | Bloc | No |

| TypeScript | Bloc | Yes\*\* (Deno)|

Want support for your language? Submit an [issue](https://github.com/michaelb/sniprun/issues/new?assignees=&labels=new-langage-support&template=support-for--language-.md&title=), or even better, [contribute](CONTRIBUTING.md), it's easy!

Expand Down
61 changes: 61 additions & 0 deletions doc/FSharp_Original.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This interpreter relies on dotnet fsi being available and on your path


The default interpreter command is `dotnet fsi --nologo` but it can be changed via the configuration key


```
require'sniprun'.setup({
interpreter_options = {
FSharp_fifo = {
interpreter = "...."
}
}
}
})
```


### REPL (would solve slowness issues)

For now, REPL is broken due to dotnet fsi being capricious about its stdin.

I'll explain rapidly how sniprun implement a REPL interpreter around named pipes (FIFOs).

The first time a fifo-based interpreter receive a run command, it forks to the background and executes `ressources/init_repl.sh`.
There is a lot of thing in that script but to replicate, you just have to:



- `mkfifo pipe_in`

- create a launcher script:

```bash
#!/bin/bash
/bin/cat pipe_in | dotnet fsi

# or replace 'dotnet fsi' by whatever you cant to try
```

- launch it in the background: `bash ./launcher.sh &`, (or `bash ./launcher.sh > out.txt & ` to redirect stdout to out.txt like sniprun does)

- ensure the pipe will stay open: `sleep 3600 > pipe_in &` (cat, exec 3> variations will also work)

- `echo "printfn \" hey \" " > pipe_in` or `cat hello_world.fsx > pipe_in`

- normally, the result should be printed in the terminal that ran the launcher, or in the out file.




#### The issue:

right now, dotnet fsi looks like it's blocked by the first sleep > pipe_in... but something **has** to keep the pipe open or when it closes, the fsi REPL reading from that will exit.

I suspect the thing has something to do with interactive mode.

For example, `python` has a similar problem, but `python -i ` (forced interactive mode, even if no terminal is detected because it runs in the background / its stdin was hijacked) works fine in the above example.

If you find something to replace dotnet fsi with, that exhibits the same correct behavior as `python -i`, sniprun REPL mode _should_ work.

7 changes: 7 additions & 0 deletions ressources/install_all_compilers_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ sudo apt install haskell-platform -y
sudo apt install -y nodejs npm
sudo npm install -g coffee-script
sudo npm install -g typescript
sudo npm install -g ts-node
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
sudo apt install r-base
Expand All @@ -15,5 +16,11 @@ pip3 install jupyter
sudo apt install lua5.3
sudo apt install sagemath
sudo apt install gprolog
sudo apt install dotnet
./ressources/go_install.sh
export PATH=$PATH:$HOME/golang/go/bin/

# deno for typescript and javascript
# cargo install deno --locked # too long, takes 20 min!
curl -fsSL https://deno.land/x/install/install.sh | sh
cp $HOME/.deno/bin/* $HOME/.cargo/bin
8 changes: 5 additions & 3 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,18 @@ pub fn display_floating_window(
"lua require\"sniprun.display\".fw_open({},{},\"{}\", true)",
row - 1,
col,
no_output_wrap(result, data, &DisplayType::TempFloatingWindow),
no_output_wrap(&result.to_string(), data, &DisplayType::TempFloatingWindow)
.replace("\n", "\\\n"),
)),
Err(result) => nvim.lock().unwrap().command(&format!(
"lua require\"sniprun.display\".fw_open({},{},\"{}\", false)",
row - 1,
col,
no_output_wrap(&result.to_string(), data, &DisplayType::TempFloatingWindow),
no_output_wrap(&result.to_string(), data, &DisplayType::TempFloatingWindow)
.replace("\n", "\\\n"),
)),
};
info!("disaply floating window res = {:?}", res);
info!("display floating window res = {:?}", res);
}

pub fn return_message_classic(
Expand Down
Loading

0 comments on commit 91653fc

Please sign in to comment.