Skip to content

Commit

Permalink
Merge pull request #194 from michaelb/dev
Browse files Browse the repository at this point in the history
v1.2.8
  • Loading branch information
michaelb authored Nov 5, 2022
2 parents 48a12c2 + fcf764a commit eb2f981
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 58 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## v1.2.8
- remove SnipTerminate
- Python_fifo3 fixes for indentation issues
- HTML doc deployed from github pages
- Composable/filterable display options
- Different display modes for live mode
Expand Down
116 changes: 65 additions & 51 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.7"
version = "1.2.8"
authors = ["michaelb <[email protected]>"]
rust-version="1.55"
edition = "2018"
Expand Down
4 changes: 0 additions & 4 deletions lua/sniprun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,10 @@ function M.configure_keymaps()
vim.api.nvim_set_keymap("v", "<Plug>SnipRun", ":lua require'sniprun'.run('v')<CR>", {silent=true})
vim.api.nvim_set_keymap("n", "<Plug>SnipRun", ":lua require'sniprun'.run()<CR>",{silent=true})
vim.api.nvim_set_keymap("n", "<Plug>SnipRunOperator", ":set opfunc=SnipRunOperator<CR>g@",{silent=true})
vim.api.nvim_set_keymap("n", "<Plug>SnipRTerminate", ":lua require'sniprun'.terminate() ; print('warning: SnipTerminate will be deprecated in the next release. Use SnipReset instead') <CR>",{silent=true})
vim.api.nvim_set_keymap("n", "<Plug>SnipReset", ":lua require'sniprun'.reset()<CR>",{silent=true})
vim.api.nvim_set_keymap("n", "<Plug>SnipInfo", ":lua require'sniprun'.info()<CR>",{})
vim.api.nvim_set_keymap("n", "<Plug>SnipReplMemoryClean", ":lua require'sniprun'.clear_repl()<CR>",{silent=true})
vim.api.nvim_set_keymap("n", "<Plug>SnipClose", ":lua require'sniprun.display'.close_all()<CR>",{silent=true})

vim.cmd("command! SnipTerminate :lua require'sniprun'.terminate() ; print('warning: SnipTerminate will be deprecated in the next release. Use SnipReset instead') ")
vim.cmd("command! SnipReset :lua require'sniprun'.reset()")
vim.cmd("command! SnipReplMemoryClean :lua require'sniprun'.clear_repl()")
vim.cmd("function! SnipRunOperator(...) \n lua require'sniprun'.run('n') \n endfunction")
vim.cmd("command! SnipClose :lua require'sniprun.display'.close_all()")
Expand Down
17 changes: 17 additions & 0 deletions src/interpreters/Python3_fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,23 @@ impl ReplLikeInterpreter for Python3_fifo {
.join("\n")
.replace("#\n#", "\n");

// add empty lines (only containing correct indentation) to code when indentation decreases
let mut lines = vec![];
for i in 0..(self.code.lines().count() - 1) {
let l1 = self.code.lines().skip(i).next().unwrap();
let l2 = self.code.lines().skip(i+1).next().unwrap();
let nw1 = l1.len() - l1.trim_start().len();
let nw2 = l2.len() - l2.trim_start().len();
lines.push(l1);
if nw1 > nw2 {
lines.push(&l2[0..nw2]);
}
}
lines.push(self.code.lines().last().unwrap());

self.code = lines.join("\n");


let mut run_ion = String::new();
let mut run_ioff = String::new();
if self.imports.contains("pyplot") {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Sniprun is a neovim plugin that run parts of code.
use dirs::cache_dir;
pub use display::{display, display_floating_window, DisplayType, DisplayFilter::*};
pub use display::{display, display_floating_window, DisplayFilter::*, DisplayType};
use log::{info, LevelFilter};
use neovim_lib::{Neovim, NeovimApi, Session, Value};
use simple_logging::log_to_file;
Expand Down Expand Up @@ -545,7 +545,7 @@ pub fn start() {
&event_handler2.nvim,
&event_handler.data,
false,
Both
Both,
);
}
}
Expand Down

0 comments on commit eb2f981

Please sign in to comment.