Skip to content

Commit

Permalink
Version 0.3.0
Browse files Browse the repository at this point in the history
Merge pull request #4 from speelbarrow/v0.3.0
  • Loading branch information
speelbarrow authored May 24, 2024
2 parents d8fca8e + 670d239 commit 9102635
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### [0.3.0](https://github.com/speelbarrow/spLauncher.nvim/tree/v0.3.0)
- Only call `nvim_win_close` when `window.persist = "force"`, otherwise just delete the buffer as done before v0.2.2
([c9c87b7](https://github.com/speelbarrow/spLauncher.nvim/commit/c9c87b7cdfe51a1351400413769c611ed701a485))

### [0.2.2](https://github.com/speelbarrow/spLauncher.nvim/tree/v0.2.2)
- Add call to `nvim_win_close` when `window.persist` is off ([e712684](
https://github.com/speelbarrow/spLauncher.nvim/commit/e7126848219d2e49d0d3f8031203f0322e25145f))
Expand All @@ -15,6 +19,5 @@ https://github.com/speelbarrow/spLauncher.nvim/commit/9d21203f95d9a1065faa18d607
https://github.com/speelbarrow/spLauncher.nvim/commit/08952bd39ae91f3df444a3d8f1f121ebacfa35ea))
- Minor documentation updates


### [0.1.0](https://github.com/speelbarrow/spLauncher.nvim/tree/v0.1.0)
- Initial release
13 changes: 7 additions & 6 deletions doc/spLauncher.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,13 @@ table/VimScript dictionary):
behaviors.

- `persist` (default: `true`)
spLauncher uses the Neovim |terminal| to execute command-line actions. By
default, the window will stay open after the program has exited until
input is attempted. To override this (i.e. close the window immediately
after the program exits), set `persist` to `false`. Note this this will
close ALL WINDOWS where the terminal buffer is open.

spLauncher uses the Neovim |terminal| to execute command-line actions. By
default, the window will stay open after the program has exited until
input is attempted (this is the default behaviour of the Neovim terminal).
There are two available override options: set this field to `false` and
the *buffer* will close when the program exits, or set the value to
`"force"` and ALL windows displaying the buffer will close when the
program exits.

- `position` (default: `"below"`)
Defines which area of the screen should hold the new
Expand Down
13 changes: 11 additions & 2 deletions lua/spLauncher/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ function M.direct_spLaunch(command, config)
end
end

-- Configure auto-closing when `config.window.persist` is false or if `silent` is on (i.e. the window is not open)
if (not config.window.persist) or config.silent then
if config.window.persist == "force" then
-- Configure auto-closing when `config.window.persist` is "force" (closes windows instead of buffers)
vim.api.nvim_create_autocmd("TermClose", {
buffer = term_buf,
once = true,
Expand All @@ -141,6 +141,15 @@ function M.direct_spLaunch(command, config)
vim.api.nvim_buf_delete(term_buf, {})
end),
})
elseif not config.window.persist or config.silent then
-- Configure auto-closing when `config.window.persist` is false or if `silent` is on (i.e. the window is not open)
vim.api.nvim_create_autocmd("TermClose", {
buffer = term_buf,
once = true,
callback = function()
vim.schedule_wrap(vim.api.nvim_buf_delete)(term_buf, {})
end,
})
end

-- Configure keymaps
Expand Down
7 changes: 4 additions & 3 deletions lua/spLauncher/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
---@field focus? boolean | "insert" Default: `true`
--- When `true`, moves the focus to the terminal window upon opening. When set to `"insert"`, moves the focus to the
--- terminal window AND enters 'Insert' mode upon opening. Set to `false` to disable both of these behaviors.
---@field persist? boolean Default: `true`
---@field persist? boolean | "force" Default: `true`
--- spLauncher uses the Neovim terminal to execute command-line actions. By default, the window will stay open after the
--- program has exited until input is attempted. To override this (i.e. close the window immediately after the program
--- exits), set `persist` to `false`. Note this this will close ALL WINDOWS where the terminal buffer is open.
--- program has exited until input is attempted. There are two available override options: set this field to `false` and
--- the *buffer* will close when the program exits, or set the `window.persist` field to `"force"` and ALL windows
--- displaying the buffer will close when the program exits.
---@field position? "below" | "above" | "left" | "right" Default: `"below"`
--- Defines which area of the screen should hold the new window when spLauncher opens a terminal. `"above"` and
--- `"below"` will result in horizontal splits, and `"left"` and `"right"` result in vertical splits. See
Expand Down

0 comments on commit 9102635

Please sign in to comment.