Skip to content

Commit

Permalink
Merge pull request michaelb#153 from michaelb/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
michaelb authored Apr 14, 2022
2 parents 3c02069 + 012491b commit 711873d
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 92 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2.2
- Run multiple code blocs at one in markup languages
- Fix multiline display for nvim-notify

## v1.2.1
- F# support
- Fix multiline display in floating windows
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Yeah cool but what _code_ goes inside?
---
I just finished some changes, how do I test my code quickly?

-> compile `cargo build --release` and run `nvim --cmd "set rtp+=. -u NONE <testfile>` from the sniprun project root.
-> compile `cargo build --release` and run `nvim --cmd "set rtp+=. -u NONE <testfile>` from the sniprun project root. You may want to remove the 'release' sniprun with your plugin manager in case your runtimepath (rtp) still loads up the release version instead of your development version.

---

Expand Down
106 changes: 73 additions & 33 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.1"
version = "1.2.2"
authors = ["michaelb <[email protected]>"]
edition = "2018"

Expand Down
3 changes: 3 additions & 0 deletions ressources/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ require'sniprun'.setup({
})
```
![](visual_assets/api.png)


Changing the contents of the buffer will generally not interfere with sniprun with the exception of running multiple code blocs in a markup language (such as markdown or orgmode), because sniprun gets the list of the positions of the code blocs once, before running & displaying once per code bloc
10 changes: 6 additions & 4 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ pub fn display_nvim_notify(
let res = match message {
Ok(result) => nvim.lock().unwrap().command(&format!(
"lua require\"sniprun.display\".display_nvim_notify(\"{}\", true)",
no_output_wrap(result, data, &DisplayType::Terminal),
no_output_wrap(result, data, &DisplayType::NvimNotify).replace("\n", "\\\n"),
)),
Err(result) => nvim.lock().unwrap().command(&format!(
"lua require\"sniprun.display\".display_nvim_notify(\"{}\", false)",
no_output_wrap(&result.to_string(), data, &DisplayType::Terminal),
no_output_wrap(&result.to_string(), data, &DisplayType::NvimNotify)
.replace("\n", "\\\n"),
)),
};
info!("display notify res = {:?}", res);
Expand All @@ -112,14 +113,14 @@ pub fn send_api(
let mut nvim_instance = nvim.lock().unwrap();
nvim_instance.command(&format!(
"lua require\"sniprun.display\".send_api(\"{}\", true)",
no_output_wrap(result, data, &DisplayType::Terminal),
no_output_wrap(result, data, &DisplayType::Api).replace("\n", "\\\n"),
))
}
Err(result) => {
let mut nvim_instance = nvim.lock().unwrap();
nvim_instance.command(&format!(
"lua require\"sniprun.display\".send_api(\"{}\", false)",
no_output_wrap(&result.to_string(), data, &DisplayType::Terminal),
no_output_wrap(&result.to_string(), data, &DisplayType::Api).replace("\n", "\\\n"),
))
}
};
Expand All @@ -136,6 +137,7 @@ pub fn display_virtual_text(
data: &DataHolder,
is_ok: bool,
) {
info!("range is : {:?}", data.range);
let namespace_id = nvim.lock().unwrap().create_namespace("sniprun").unwrap();
if is_ok != result.is_ok() {
if let Err(SniprunError::InterpreterLimitationError(_)) = result {
Expand Down
5 changes: 5 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ pub enum SniprunError {
///custom error for advanced interpreters, the error will be displayed as-is
#[error("{0}")]
CustomError(String),

/// Divide one sniprun into many. Useful for markup language, when several
/// code blocs are to be run from 1 'sniprun' command
#[error("")]
ReRunRanges(Vec<(usize, usize)>),
}
Loading

0 comments on commit 711873d

Please sign in to comment.