From 87b878af8232934aa59fb5ce6afde3a08123e2b9 Mon Sep 17 00:00:00 2001 From: Noah Friedman Date: Mon, 13 May 2024 11:26:12 -0400 Subject: [PATCH 1/2] Implement auto-scrolling and create an associated configuration parameter --- doc/spLauncher.txt | 4 ++++ lua/spLauncher/init.lua | 6 ++++++ lua/spLauncher/types.lua | 3 +++ 3 files changed, 13 insertions(+) diff --git a/doc/spLauncher.txt b/doc/spLauncher.txt index b9069ed..e5e7db8 100644 --- a/doc/spLauncher.txt +++ b/doc/spLauncher.txt @@ -166,6 +166,10 @@ table/VimScript dictionary): window when |spLauncher| opens a |terminal|. `"above"` and `"below"` will result in horizontal splits, and `"left"` and `"right"` result in vertical splits. See |nvim_open_win| for more information. + + - `scroll` (default: `"true"`) + When `true`, the terminal window will scroll to the bottom when it is + opened (and thus will stay "pinned" to the bottom of the terminal output). - `keymap` *spLauncher-config-keymap* diff --git a/lua/spLauncher/init.lua b/lua/spLauncher/init.lua index c70a9e4..866e48e 100644 --- a/lua/spLauncher/init.lua +++ b/lua/spLauncher/init.lua @@ -32,6 +32,7 @@ function M.setup(config) focus = true, persist = true, position = "below", + scroll = true, }, keymap = (config ~= nil and config.keymap ~= nil and config.keymap.merge == false) and nil or { @@ -173,6 +174,11 @@ function M.direct_spLaunch(command, config) end end }) + + -- Move cursor to the bottom of the terminal window to automatically scroll the output (unless `scroll` is false) + if config.window.scroll then + vim.schedule_wrap(vim.api.nvim_buf_call)(term_buf, function() vim.cmd "normal! G" end) + end end return M diff --git a/lua/spLauncher/types.lua b/lua/spLauncher/types.lua index 24c15d9..a73498e 100644 --- a/lua/spLauncher/types.lua +++ b/lua/spLauncher/types.lua @@ -45,6 +45,9 @@ --- 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 --- `nvim_open_win` for more information. +---@field scroll boolean? Default: `true` +--- When `true`, the terminal window will scroll to the bottom when it is opened (and thus will stay "pinned" to the +--- bottom of the terminal output). ---@class spLauncher.Config.Keymap See `:help spLauncher-config-keymap` ---@field merge boolean Default: `true` From 5644f693a53ffb273afa77028e170dd2b4b9e0ee Mon Sep 17 00:00:00 2001 From: Noah Friedman Date: Mon, 13 May 2024 11:28:22 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b77286d..0f63087 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### [0.2.1](https://github.com/speelbarrow/spLauncher.nvim/tree/v0.2.1) +- Implement auto-scrolling and create an associated configuration parameter ([87b878a]( +https://github.com/speelbarrow/spLauncher.nvim/commit/87b878af8232934aa59fb5ce6afde3a08123e2b9)) + ### [0.2.0](https://github.com/speelbarrow/spLauncher.nvim/tree/v0.2.0) - Add `hide` configuration parameter ([9d21203]( https://github.com/speelbarrow/spLauncher.nvim/commit/9d21203f95d9a1065faa18d607a5ca5643ea7a05))