Skip to content

Commit

Permalink
Merge pull request #261 from michaelb/dev
Browse files Browse the repository at this point in the history
v1.3.8
  • Loading branch information
michaelb committed Nov 11, 2023
2 parents 0ad9356 + 518e5e2 commit 7a8bc30
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 64 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v1.3.8
- Fix Python3_jupyter
- Allow opening terminal in horizontal split
- Compiles locally by default (when on dev branch)

## v1.3.7
- Fix issue in multiple languages when last line is a comment
- Install instructions for lazy.nvim/Lunarvim
Expand Down
2 changes: 1 addition & 1 deletion CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# Prepare the release

## on dev branch
- update Cargo.lock: `cargo update` (but do not break MSRV, so do it package by package and check with MSRV toolchain)
- check compilation success
- cargo fmt --all / cargo check / cargo clippy
- update the changelog
- remove the 'beta' from the version field in Cargo.toml
- `cargo update --offline` # update sniprun's versino in committed Cargo.lock

## Merge process
- create a PR dev -> master
Expand Down
57 changes: 34 additions & 23 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.3.7"
version = "1.3.8"
authors = ["michaelb <[email protected]>"]
rust-version = "1.65"
edition = "2018"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@




# Introduction
Sniprun is a code runner plugin for neovim written in Lua and Rust. It aims to provide stupidly fast partial code testing for interpreted **and compiled** [languages](https://michaelb.github.io/sniprun/sources/README.html#support-levels-and-languages). Sniprun blurs the line between standard save/run workflow, jupyter-like notebook, and REPL/interpreters.

Expand Down
6 changes: 4 additions & 2 deletions doc/sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Sniprun will then:
use { 'michaelb/sniprun', run = 'sh ./install.sh'}
```

(or likewise, `'sh ./install.sh 1'` to get the bleeding edge aka compile yourself the latest commit of sniprun)
(if you target the 'dev' branch, the installer will try to compile manually sniprun on your computer, which will require the rust toolchain)

</p>
</details>
Expand Down Expand Up @@ -275,7 +275,9 @@ require'sniprun'.setup({
terminal_line_number = false, --# whether show line number in terminal window
terminal_signcolumn = false, --# whether show signcolumn in terminal window
terminal_persistence = true, --# always keep the terminal open (true) or close it at every occasion (false)
terminal_width = 45, --# change the terminal display option width
terminal_position = "vertical", --# or "horizontal", to open as horizontal split instead of vertical split
terminal_width = 45, --# change the terminal display option width (if vertical)
terminal_height = 20, --# change the terminal display option height (if horizontal)
notification_timeout = 5 --# timeout for nvim_notify output
},
Expand Down
4 changes: 3 additions & 1 deletion doc/sources/display_modes.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ require'sniprun'.setup({
terminal_scrollback = vim.o.scrollback, -- change terminal display scrollback lines
terminal_line_number = false, -- whether show line number in terminal window
terminal_signcolumn = false, -- whether show signcolumn in terminal window
terminal_width = 45,
terminal_position = "vertical", --# or "horizontal", to open as horizontal split instead of vertical split
terminal_width = 45, --# change the terminal display option width (if vertical)
terminal_height = 20, --# change the terminal display option height (if horizontal)
},
})
EOF
Expand Down
19 changes: 18 additions & 1 deletion doc/sources/interpreters/Generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ require'sniprun'.setup({
compiler = "",
exe_name = "",
boilerplate = ""
boilerplate_pre = ""
boilerplate_post = ""
},
my_super_c_config = {
Expand All @@ -68,6 +69,22 @@ require'sniprun'.setup({
})
```

### How the generic interpreter works

#### For interpreted languages ("interpreter" is set)

1. Sniprun receive a snippet of code to run
2. The snippet gets surrounded by boilerplate_pre and boilerplate_post
3. The whole thing is written to a file with the given extension, named `<exe_name>_src.<extension>`
4. Sniprun runs `<interpreter> <file>.<extension>` and displays the stdout/stderr

#### For compiled languages ("compiler" is set)

1. Sniprun receive a snippet of code to run
2. The snippet gets surrounded by boilerplate_pre and boilerplate_post
3. The whole thing is written to a temporary file with the given extension, named `<exe_name>_src.<extension>`
4. Sniprun runs `<compiler> <exe_name>_src.<extension>` , and if this has a non-success status, displays the stderr
5. Sniprun runs `./<exe_name>` and displays the stdout/stderr


### Community examples for non-officially supported languages
Expand Down
3 changes: 3 additions & 0 deletions doc/sources/interpreters/Python3_jupyter.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Python3 jupyter

Unless you really really need this (for Ipython), I would strongly advise for the Python3_fifo interpreter which has
way less potential issues

### Dependencies
- jupyter

Expand Down
16 changes: 11 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

echo "Runnning Sniprun Installer"
local_version="v$(grep ^version Cargo.toml | cut -d "\"" -f 2)"

force_build=$1
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" == "dev" ]; then
force_build=1
fi

arch=$(uname)
if [ "$arch" != "Linux" ] && [ "$force_build" != 1 ]; then
echo "Looks you are not running Linux: Mac users have to compile sniprun themselves and thus need the Rust toolchain"
force_build=1
fi

cargo_build() {
if command -v cargo >/dev/null; then
Expand Down Expand Up @@ -39,11 +50,6 @@ fetch_prebuilt_binary() {
fi
}

arch=$(uname)
if [ "$arch" != "Linux" ] && [ "$force_build" != 1 ]; then
echo "Looks you are not running Linux: Mac users have to compile sniprun themselves and thus need the Rust toolchain"
force_build=1
fi

remote_version=$(get_latest_release)

Expand Down
4 changes: 3 additions & 1 deletion lua/sniprun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ M.config_values = {
terminal_scrollback = vim.o.scrollback, -- change terminal display scrollback lines
terminal_line_number = false, -- whether show line number in terminal window
terminal_signcolumn = false, -- whether show signcolumn in terminal window
terminal_width = 45, -- change the terminal display option width
terminal_position = "vertical", -- or "horizontal"
terminal_width = 45, -- change the terminal display option width (if vertical)
terminal_height = 20, -- change the terminal display option heigth (if horizontal)
terminal_persistence = true, -- always keep the terminal open (true) or close it at every occasion (false)
notification_timeout = 5 -- timeout for nvim_notify output
},
Expand Down
10 changes: 8 additions & 2 deletions lua/sniprun/display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ function M.term_set_window_handle()
local winid = vim.fn.bufwinid(M.term.buffer)
if winid ~= -1 then return end

local width = require("sniprun").config_values.display_options.terminal_width
vim.cmd(":rightb " .. width .. "vsplit")
local location = require("sniprun").config_values.display_options.terminal_position
if location == "horizontal" then
local height = require("sniprun").config_values.display_options.terminal_height or 20
vim.cmd(":rightb " .. height .. "split")
else
local width = require("sniprun").config_values.display_options.terminal_width or 45
vim.cmd(":rightb " .. width .. "vsplit")
end
M.term.window_handle = vim.api.nvim_get_current_win()

-- return to doc buffer
Expand Down
2 changes: 1 addition & 1 deletion src/interpreters/Generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Interpreter for Generic {
.create(&rwd)
.expect("Could not create directory for generic/<config_name>");
let exe_path = rwd.clone() + "/" + &exe_name;
let main_file_path = exe_path.clone() + "_src123456789src" + &extension; // this way, virtually impossible for the user for have exe & main file with same name by accident
let main_file_path = exe_path.clone() + "_src" + &extension; // this way, impossible for the user for have exe & main file with same name by accident
Box::new(Generic {
data,
support_level,
Expand Down
Loading

0 comments on commit 7a8bc30

Please sign in to comment.