diff --git a/README.md b/README.md index e77f065e..df9c2fc3 100755 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ An example in C, look in the command area: ![](ressources/visual_assets/demo_c.gif) -##### The result can be displayed in multiple (even at the same time) ways: +##### The result can be displayed in multiple (even at the same time) ways: [Classic](ressources/display_classic.md)| [Virtual Text](ressources/display_virtualtext.md) :------------------------------------------:|:------------------: @@ -95,7 +95,7 @@ Basically, it allows you to run a part of your code. Do either of: - Position the cursor on a line `:SnipRun` -- Select some visual range, `:'<,'>SnipRun` +- Select some visual range, `:'<,'>SnipRun` - Combine a motion with the operator (preferably through a shortcut!) @@ -111,7 +111,7 @@ Sniprun will then: - **Add boilerplate** when it exists. In C, it surrounds your snip with "int main() {", "}". (disclaimer: oversimplifed) - **Build** (write to a script file, or compile) the code - **Execute** the code -- Return stdout, or stderr using the +- Return stdout, or stderr using the ![](ressources/visual_assets/760091.png) @@ -275,7 +275,7 @@ require'sniprun'.setup({ -- "LongTempFloatingWindow", -- "same as above, but only long results. To use with VirtualText__ -- "Terminal" -- "display results in a vertical split }, - + -- customize highlight groups (setting this overrides colorscheme) snipruncolors = { SniprunVirtualTextOk = {bg="#66eeff",fg="#000000",ctermbg="Cyan",cterfg="Black"}, @@ -387,15 +387,15 @@ println!("-> {}", alphabet); | ------------ | ------------- | --- | ---------- | ---------------- | | Ada | Line | | Java | Bloc | | Bash/Shell | Bloc + REPL\* | | JavaScript | Bloc | -| C | Import | | Julia | Bloc | +| C | Import | | Julia | Bloc + REPL\*\* | | C++ | Import | | Lisp | Untested | | Clojure | Untested | | Lua | Bloc | | COBOL | Untested | | Lua-nvim | Bloc | -| Coffeescript | Bloc | | Markdown (GFM) | Bloc + REPL \*** | +| Coffeescript | Bloc | | Markdown (GFM) | Bloc + REPL \*\*\* | | C# | Untested | | Perl6 | Line | | D | Bloc | | Perl | Line | | Elixir | Untested | | PHP | Untested | -| Elm | Untested | | Python3 | Import +REPL\*\* | +| Elm | Untested | | Python3 | Import +REPL*\* | | Erlang | Untested | | R | Bloc + REPL \*\* | | F# | Untested | | Ruby | Bloc | | Go | Bloc | | Rust | Bloc | @@ -425,7 +425,7 @@ Due to its nature, Sniprun may have trouble with programs that : ## Troubleshooting -begin by updating the plugin and running `:SnipReset` and then `:checkhealth sniprun` +begin by updating the plugin and running `:SnipReset` and then `:checkhealth sniprun` - **Silent fail**: the sniprun binary may be incompatible with your distro/OS/arch. Use `bash ./install.sh 1` as post-install to compile locally. - Terminal and Floating Window display mode do not work: Linked to [this](https://github.com/michaelb/sniprun/issues/70) issue, no fix found yet. diff --git a/doc/Julia_jupyter.md b/doc/Julia_jupyter.md new file mode 100644 index 00000000..8123b6b1 --- /dev/null +++ b/doc/Julia_jupyter.md @@ -0,0 +1,12 @@ +The setup for the julia_jupyter interpreter is quite convoluted: + +Indeed, the Julia jupyter kernel MUST be started before Sniprun can run (and there is even a consequent delay since the kernel is so slow to start). + +You should start a julia jupyter kernel with the following command: +` jupyter-kernel --kernel=julia-1.5 --KernelManager.connection_file=$HOME/.cache/sniprun/julia_jupyter/kernel_sniprun.json` + +(adapt to your XDG_CACHE location if you're on Mac) + +You manage kernel startup AND shutodwn manually. Why? There is a terrible data race if sniprun does it. Python_jupyter works, julia doesn't. That's about it. + +If you want to use another kernel location, post a feature request at github.com/michaelb/sniprun and i'll see what I can do. diff --git a/src/interpreters/Julia_jupyter.rs b/src/interpreters/Julia_jupyter.rs index 892e0636..90fe9a5c 100644 --- a/src/interpreters/Julia_jupyter.rs +++ b/src/interpreters/Julia_jupyter.rs @@ -123,28 +123,10 @@ impl Interpreter for Julia_jupyter { impl ReplLikeInterpreter for Julia_jupyter { fn fetch_code_repl(&mut self) -> Result<(), SniprunError> { self.fetch_code()?; - let saved_code = self.read_previous_code(); - if saved_code.is_empty() { - //initialize kernel. Relying on self.read_previous_code to - //know when to start a new kernel is important as - //this will be cleared by the SnipReplMemoryClean command - let _res = std::fs::remove_file(&self.kernel_file); - let _res = Command::new("jupyter-kernel") - .arg("--kernel=julia-1.5") - .arg(String::from("--KernelManager.connection_file=") + &self.kernel_file) - .spawn(); - info!("Initialized kernel at {}", self.kernel_file); - } else { - // kernel already running - info!( - "Using already loaded jupyter kernel at {}", - self.kernel_file - ); + if !std::path::Path::new(&self.kernel_file).exists() { + info!("no kernel file found"); + return Err(SniprunError::RuntimeError("No running kernel found".to_string())); } - - // save kernel - self.save_code(saved_code); - Ok(()) } fn add_boilerplate_repl(&mut self) -> Result<(), SniprunError> { @@ -186,15 +168,6 @@ impl ReplLikeInterpreter for Julia_jupyter { } fn execute_repl(&mut self) -> Result { - if !std::path::Path::new(&self.kernel_file).exists() { - info!("no kernel file found"); - return Err(SniprunError::RuntimeError("No kernel found or provided".to_string())); - } - info!( - "json kernel file exists yet? {}", - std::path::Path::new(&self.kernel_file).exists() - ); - info!("starting executing repl: bash {}",&self.launcher_path); let output = Command::new("bash") .arg(&self.launcher_path) @@ -234,25 +207,3 @@ impl ReplLikeInterpreter for Julia_jupyter { } } } - -#[cfg(test)] -mod test_julia_jupyter { - use super::*; - use crate::*; - - #[test] - fn run_all() { - simple_print(); - } - - fn simple_print() { - let mut data = DataHolder::new(); - data.current_bloc = String::from("println(\"a\")"); - let mut interpreter = Julia_jupyter::new(data); - let res = interpreter.run_at_level(SupportLevel::Bloc); - - // should panic if not an Ok() - let string_result = res.unwrap(); - assert!(string_result.contains(&"a")); - } -}