diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..30e715b9
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,13 @@
+# kitty-scrollback.nvim
+
+## Generating demos and wiki content (requires MacOS)
+
+- `git clone git@github.com/mikesmithgh/kitty-scrollback.nvim.wiki.git`
+- `cd kitty-scrollback.nvim.wiki`
+- `./scripts/record_demo_videos.lua`
+- `ls -1 assets/*.mov | xargs -I {} scripts/mov_to_gif.sh {}`
+- Upload all `mov` files in the `assets` directory to Github by dragging them to a markdown file in the browser
+- Copy all the generated embeded video urls and paste in `uploaded_movs` array in the `make_video_markdown_files.sh` script
+- `./scripts/make_video_markdown_files.sh`
+- `./scripts/make_adv_config_markdown_file.lua &> Advanced-Configuration.md`
+
diff --git a/README.md b/README.md
index 2c38be3a..b00fab15 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,101 @@ Navigate your Kitty scrollback buffer to quickly search, copy, and execute comma
+## π Migrating to v2.0.0
+> [!IMPORTANT]\
+> v2.0.0 has breaking changes and requires steps to properly migrate from v1.X.X.
+>
+> You can ignore this section if you have not previously installed any verions of kitty-scrollback.nvim
+
+
+
+ Migration Steps
+
+
+
+ - If you are using the lazy.nvim or packer.nvim package manager, then
+ add the custom `User` event `KittyScrollbackLaunch` as a trigger for lazy loading. See [Installation](#-installation) for additional details.
+
+ ```lua
+ event = { 'User KittyScrollbackLaunch' }
+ ```
+
+ - Regenerate default Kitten mappings and add to `kitty.conf`
+
+ ```sh
+ nvim --headless +'KittyScrollbackGenerateKittens' +'set nonumber' +'set norelativenumber' +'%print' +'quit!' 2>&1
+ ```
+ - Remove previous kitty-scrollback.nvim Kitten mappings in `kitty.conf`
+
+ - Migrate any customized configurations to the new format
+ - When you define your kitty-scrollback.nvim Kitten configuration, do not use `--config-file` `yourconfigfile.lua`. Instead,
+ move the contents of `yourconfigfile.lua` to an entry in the configuration passed to the kitty-scrollback.nvim setup function.
+ ```lua
+ require('kitty-scrollback').setup({
+ yourconfig = function()
+ ...
+ end,
+ })
+ ```
+ Update your Kitten to use the name of the configuration defined in the setup function. In this example,
+ `--config-file yourconfigfile.lua` changes to `--config yourconfig`
+
+ Real example
+
+ The configuration to view the last command output now references a builtin configuration instead of a file. The
+ new configuation can be viewed by running `:KittyScrollbackGenerateKittens`.
+
+ - Old configuration
+ The Kitten defined in `kitty.conf` references the configuration file `get_text_last_cmd_output.lua`
+
+ ```kitty
+ # Browse output of the last shell command in nvim
+ map ctrl+shift+g kitty_scrollback_nvim --config-file get_text_last_cmd_output.lua
+ ```
+
+ ```lua
+ -- get_text_last_cmd_output.lua
+ local M = {}
+ M.config = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_visited_cmd_output',
+ ansi = true,
+ },
+ }
+ end
+
+ return M
+ ```
+
+ - New configuration
+ The Kitten defined in `kitty.conf` references the builtin configuration name `ksb_builtin_last_cmd_output`
+
+ ```kitty
+ # Browse output of the last shell command in nvim
+ map ctrl+shift+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
+ ```
+
+ ```lua
+ require('kitty-scrollback').setup({
+ ksb_builtin_last_cmd_output = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_visited_cmd_output',
+ ansi = true,
+ },
+ }
+ end
+ })
+ ```
+
+
+
+
+
+
+
+
## β¨ Features
- π» Navigate Kitty's scrollback buffer with Neovim
- π± Copy contents from Neovim to system clipboard
@@ -97,6 +192,7 @@ sh -c "$(curl -s https://raw.githubusercontent.com/mikesmithgh/kitty-scrollback.
enabled = true,
lazy = true,
cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth' },
+ event = { 'User KittyScrollbackLaunch' },
-- version = '*', -- latest stable version, may have breaking changes if major version changed
-- version = '^1.0.0', -- pin major version, include fixes and features that do not have breaking changes
config = function()
@@ -116,6 +212,7 @@ sh -c "$(curl -s https://raw.githubusercontent.com/mikesmithgh/kitty-scrollback.
disable = false,
opt = true,
cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth' },
+ event = { 'User KittyScrollbackLaunch' },
-- tag = '*', -- latest stable version, may have breaking changes if major version changed
-- tag = 'v1.0.0', -- pin specific tag
config = function()
@@ -142,6 +239,10 @@ echo "require('kitty-scrollback').setup()" >> "$HOME/.config/nvim/init.lua"
## βοΈ Configuration
+> [!NOTE]\
+> The [Advanced Configuration](https://github.com/mikesmithgh/kitty-scrollback.nvim/wiki/Advanced-Configuration) section of the Wiki provides
+> detailed demos of each configuration option.
+
### Kitty
The following steps outline how to properly configure [kitty.conf](https://sw.kovidgoyal.net/kitty/conf/)
@@ -204,14 +305,14 @@ listen_on unix:/tmp/kitty
shell_integration enabled
# kitty-scrollback.nvim Kitten alias
-action_alias kitty_scrollback_nvim kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --cwd /Users/mike/gitrepos/kitty-scrollback.nvim/lua/kitty-scrollback/configs
+action_alias kitty_scrollback_nvim kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py
# Browse scrollback buffer in nvim
map ctrl+shift+h kitty_scrollback_nvim
# Browse output of the last shell command in nvim
-map ctrl+shift+g kitty_scrollback_nvim --config-file get_text_last_cmd_output.lua
+map ctrl+shift+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
# Show clicked command output in nvim
-mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config-file get_text_last_visited_cmd_output.lua
+mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output
```
@@ -221,7 +322,7 @@ Arguments that can be passed to the `kitty_scrollback_nvim` Kitten defined in [k
| Argument | Description |
| :--------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `--config-file` | `kitty-scrollback.nvim` plugin configuration file. The configuration file must return a Lua table with the function `config(kitty_data): table`. You may specify multiple config files that will merge all configuration options. |
+| `--config` | The name of the `kitty-scrollback.nvim` plugin configuration. The configuration can be defined during plugin setup (i.e., `require('kitty-scrollback').setup({ ... })`). |
| `--no-nvim-args` | Do not provide any arguments to the Neovim instance that displays the scrollback buffer. The default arguments passed to Neovim are `--clean --noplugin -n`. This flag removes those options. |
| `--nvim-args` | All arguments after this flag are passed to the Neovim instance that displays the scrollback buffer. This must be the last of the `kitty-scrollback.nvim` Kitten arguments that are configured. Otherwise, you may unintentionally send the wrong arguments to Neovim. The default arguments passed to Neovim are `--clean --noplugin -n`. This flag removes those options. |
| `--env` | Environment variable that is passed to the Neovim instance that displays the scrollback buffer. Format is `--env var_name=var_value`. You may specify multiple config files that will merge all configuration options. Useful for setting `NVIM_APPNAME` |
@@ -255,11 +356,11 @@ Arguments that can be passed to the `kitty_scrollback_nvim` Kitten defined in [k
| paste_window | `KsbPasteWindowOpts?` | options for paste window that sends commands to Kitty |
| paste_window.highlight_as_normal_win | `fun(): boolean?` | If function returns true, use Normal highlight group. If false, use NormalFloat |
| paste_window.filetype | `string?` | The filetype of the paste window |
-| paste_window.hide_footer | `boolean?` | If true, hide the footer when the paste window is initially opened |
+| paste_window.hide_footer | `boolean?` | If true, hide mappings in the footer when the paste window is initially opened |
| paste_window.winblend | `integer?` | The winblend setting of the window, see :help winblend |
| paste_window.winopts_overrides | `fun(paste_winopts: KsbWinOpts): table?` | Paste float window overrides, see nvim_open_win() for configuration |
| paste_window.footer_winopts_overrides | `fun(footer_winopts: KsbWinOpts, paste_winopts: KsbWinOpts): table?` | Paste footer window overrides, see nvim_open_win() for configuration |
-| paste_window.yank_register | `string?` | register used during yanks to paste window, see `:h registers` |
+| paste_window.yank_register | `string?` | register used during yanks to paste window, see `:h registers` |
| paste_window.yank_register_enabled | `boolean?` | If true, the `yank_register` copies content to the paste window. If false, disable yank to paste window |
| kitty_get_text | `KsbKittyGetText?` | options passed to get-text when reading scrollback buffer, see `kitty @ get-text --help` |
| kitty_get_text.ansi | `boolean` | If true, the text will include the ANSI formatting escape codes for colors, bold, italic, etc. |
@@ -272,26 +373,20 @@ Arguments that can be passed to the `kitty_scrollback_nvim` Kitten defined in [k
By default, `kitty-scrollback.nvim` uses [Nerd Fonts](https://www.nerdfonts.com) in the status window. If you would like to
use ASCII instead, set the option `status_window.style_simple` to `true`.
-
- Status window with Nerd Fonts opts.status_window.style_simple = false
-
- https://github.com/mikesmithgh/kitty-scrollback.nvim/assets/10135646/4cf5b303-5061-43da-a857-c99daea82332
-
-
-
- Status window with ASCII text opts.status_window.style_simple = true
-
- https://github.com/mikesmithgh/kitty-scrollback.nvim/assets/10135646/a0e1b574-59ab-4abf-93a1-f314c7cd47b3
-
-
+- Status window with Nerd Fonts opts.status_window.style_simple = false
+![style_simple_false](https://github.com/mikesmithgh/kitty-scrollback.nvim/assets/10135646/662bf132-0b39-4028-b69f-eb85fbb69b60)
+
+- Status window with ASCII text opts.status_window.style_simple = true
+![style_simple_true](https://github.com/mikesmithgh/kitty-scrollback.nvim/assets/10135646/c19a1869-e4e4-40fd-b619-fed771d0153f)
+
## π«‘ Commands and Lua API
The API is available via the `kitty-scrollback.api` module. e.g., `require('kitty-scrollback.api')`
-| Command | API | Description |
-| :----------------------------------- | :------------------------------- | :---------------------------------------------------------------------- |
-| `:KittyScrollbackGenerateKittens[!]` | `generate_kittens(boolean?)` | Generate Kitten commands used as reference for configuring `kitty.conf` |
-| `:KittyScrollbackCheckHealth` | `checkhealth()` | Run `:checkhealth kitty-scrollback` in the context of Kitty |
+| Command | API | Description |
+| :---------------------------------------------------- | :--------------------------------------------------------------- | :---------------------------------------------------------------------- |
+| `:KittyScrollbackGenerateKittens[!] [generate_modes]` | `generate_kittens(boolean?, table)?` | Generate Kitten commands used as reference for configuring `kitty.conf` |
+| `:KittyScrollbackCheckHealth` | `checkhealth()` | Run `:checkhealth kitty-scrollback` in the context of Kitty |
## β¨οΈ Keymaps and Lua API
The API is available via the `kitty-scrollback.api` module. e.g., `require('kitty-scrollback.api')`
diff --git a/doc/kitty-scrollback.nvim.txt b/doc/kitty-scrollback.nvim.txt
index 4a844158..4c96079d 100644
--- a/doc/kitty-scrollback.nvim.txt
+++ b/doc/kitty-scrollback.nvim.txt
@@ -1,9 +1,10 @@
-*kitty-scrollback.nvim.txt* For NVIM v0.10+ Last change: 2023 October 31
+*kitty-scrollback.nvim.txt* For NVIM v0.10+ Last change: 2023 November 01
==============================================================================
Table of Contents *kitty-scrollback.nvim-table-of-contents*
1. kitty-scrollback.nvim |kitty-scrollback.nvim-kitty-scrollback.nvim|
+ - Migrating to v2.0.0 |kitty-scrollback.nvim-migrating-to-v2.0.0|
- Features |kitty-scrollback.nvim-features|
- Example use cases |kitty-scrollback.nvim-example-use-cases|
- Prerequisites |kitty-scrollback.nvim-prerequisites|
@@ -25,6 +26,88 @@ Navigate your Kitty scrollback buffer to quickly search, copy, and execute
commands in Neovim.
+MIGRATING TO V2.0.0 *kitty-scrollback.nvim-migrating-to-v2.0.0*
+
+
+ `IMPORTANT` v2.0.0 has breaking changes and requires steps to properly migrate
+ from v1.X.X.
+ You can ignore this section if you have not previously installed any verions of
+ kitty-scrollback.nvim
+- Migration Steps
+
+
+
+- If you are using the packer.nvim
+ package manager, then add the custom `User` event `KittyScrollbackLaunch` as a
+ trigger for lazy loading. See |kitty-scrollback.nvim-installation| for
+ additional details.
+ >lua
+ event = { 'User KittyScrollbackLaunch' }
+ <
+- Regenerate default Kitten mappings and add to `kitty.conf`
+ >sh
+ nvim --headless +'KittyScrollbackGenerateKittens' +'set nonumber' +'set norelativenumber' +'%print' +'quit!' 2>&1
+ <
+- Remove previous kitty-scrollback.nvim Kitten mappings in `kitty.conf`
+- Migrate any customized configurations to the new format
+ - When you define your kitty-scrollback.nvim Kitten configuration, do not use
+ `--config-file` `yourconfigfile.lua`. Instead, move the contents of
+ `yourconfigfile.lua` to an entry in the configuration passed to the
+ kitty-scrollback.nvim setup function.
+ >lua
+ require('kitty-scrollback').setup({
+ yourconfig = function()
+ ...
+ end,
+ })
+ <
+ Update your Kitten to use the name of the configuration defined in the setup
+ function. In this example, `--config-file yourconfigfile.lua` changes to
+ `--config yourconfig`
+ - Real example
+ The configuration to view the last command output now references a builtin
+ configuration instead of a file. The new configuation can be viewed by running
+ `:KittyScrollbackGenerateKittens`.
+ - Old configuration
+ The Kitten defined in `kitty.conf` references the configuration file `get_text_last_cmd_output.lua`
+ >kitty
+ # Browse output of the last shell command in nvim
+ map ctrl+shift+g kitty_scrollback_nvim --config-file get_text_last_cmd_output.lua
+ <
+ >lua
+ -- get_text_last_cmd_output.lua
+ local M = {}
+ M.config = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_visited_cmd_output',
+ ansi = true,
+ },
+ }
+ end
+
+ return M
+ <
+ - New configuration
+ The Kitten defined in `kitty.conf` references the builtin configuration name `ksb_builtin_last_cmd_output`
+ >kitty
+ # Browse output of the last shell command in nvim
+ map ctrl+shift+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
+ <
+ >lua
+ require('kitty-scrollback').setup({
+ ksb_builtin_last_cmd_output = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_visited_cmd_output',
+ ansi = true,
+ },
+ }
+ end
+ })
+ <
+
+
FEATURES *kitty-scrollback.nvim-features*
- Navigate Kittyβs scrollback buffer with Neovim
@@ -91,6 +174,7 @@ INSTALLATION *kitty-scrollback.nvim-installation*
enabled = true,
lazy = true,
cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth' },
+ event = { 'User KittyScrollbackLaunch' },
-- version = '*', -- latest stable version, may have breaking changes if major version changed
-- version = '^1.0.0', -- pin major version, include fixes and features that do not have breaking changes
config = function()
@@ -107,6 +191,7 @@ INSTALLATION *kitty-scrollback.nvim-installation*
disable = false,
opt = true,
cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth' },
+ event = { 'User KittyScrollbackLaunch' },
-- tag = '*', -- latest stable version, may have breaking changes if major version changed
-- tag = 'v1.0.0', -- pin specific tag
config = function()
@@ -130,6 +215,10 @@ INSTALLATION *kitty-scrollback.nvim-installation*
CONFIGURATION *kitty-scrollback.nvim-configuration*
+ `NOTE` The Advanced Configuration
+
+ section of the Wiki provides detailed demos of each configuration option.
+
KITTY ~
The following steps outline how to properly configure kitty.conf
@@ -176,14 +265,14 @@ The following steps outline how to properly configure kitty.conf
shell_integration enabled
# kitty-scrollback.nvim Kitten alias
- action_alias kitty_scrollback_nvim kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --cwd /Users/mike/gitrepos/kitty-scrollback.nvim/lua/kitty-scrollback/configs
+ action_alias kitty_scrollback_nvim kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py
# Browse scrollback buffer in nvim
map ctrl+shift+h kitty_scrollback_nvim
# Browse output of the last shell command in nvim
- map ctrl+shift+g kitty_scrollback_nvim --config-file get_text_last_cmd_output.lua
+ map ctrl+shift+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
# Show clicked command output in nvim
- mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config-file get_text_last_visited_cmd_output.lua
+ mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output
<
@@ -195,10 +284,9 @@ kitty.conf .
-------------------------------------------------------------------------------------
Argument Description
---------------- --------------------------------------------------------------------
- --config-file kitty-scrollback.nvim plugin configuration file. The configuration
- file must return a Lua table with the function
- config(kitty_data): table. You may specify multiple config files
- that will merge all configuration options.
+ --config The name of the kitty-scrollback.nvim plugin configuration. The
+ configuration can be defined during plugin setup (i.e.,
+ require('kitty-scrollback').setup({ ... })).
--no-nvim-args Do not provide any arguments to the Neovim instance that displays
the scrollback buffer. The default arguments passed to Neovim are
@@ -281,8 +369,8 @@ KITTY-SCROLLBACK.NVIM CONFIGURATION FILE ~
paste_window.filetype string? The filetype of the paste window
- paste_window.hide_footer boolean? If true, hide the footer when the paste window is initially
- opened
+ paste_window.hide_footer boolean? If true, hide mappings in the footer when the paste window
+ is initially opened
paste_window.winblend integer? The winblend setting of the window, see :help winblend
@@ -332,10 +420,7 @@ in the status window. If you would like to use ASCII instead, set the option
`status_window.style_simple` to `true`.
- Status window with Nerd Fonts opts.status_window.style_simple = false
- https://github.com/mikesmithgh/kitty-scrollback.nvim/assets/10135646/4cf5b303-5061-43da-a857-c99daea82332
-
- Status window with ASCII text opts.status_window.style_simple = true
- https://github.com/mikesmithgh/kitty-scrollback.nvim/assets/10135646/a0e1b574-59ab-4abf-93a1-f314c7cd47b3
COMMANDS AND LUA API *kitty-scrollback.nvim-commands-and-lua-api*
@@ -343,15 +428,17 @@ COMMANDS AND LUA API *kitty-scrollback.nvim-commands-and-lua-api*
The API is available via the `kitty-scrollback.api` module. e.g.,
`require('kitty-scrollback.api')`
- ------------------------------------------------------------------------------------------------------
- Command API Description
- ------------------------------------ ---------------------------- ------------------------------------
- :KittyScrollbackGenerateKittens[!] generate_kittens(boolean?) Generate Kitten commands used as
- reference for configuring kitty.conf
+ ------------------------------------------------------------------------------------------------------------------------------------------------------
+ Command API Description
+ ----------------------------------------------------- ---------------------------------------------------------------- -------------------------------
+ :KittyScrollbackGenerateKittens[!] [generate_modes] generate_kittens(boolean?, table)? Generate Kitten commands used
+ as reference for configuring
+ kitty.conf
- :KittyScrollbackCheckHealth checkhealth() Run :checkhealth kitty-scrollback in
- the context of Kitty
- ------------------------------------------------------------------------------------------------------
+ :KittyScrollbackCheckHealth checkhealth() Run
+ :checkhealth kitty-scrollback
+ in the context of Kitty
+ ------------------------------------------------------------------------------------------------------------------------------------------------------
KEYMAPS AND LUA API *kitty-scrollback.nvim-keymaps-and-lua-api*
@@ -421,6 +508,12 @@ ALTERNATIVES *kitty-scrollback.nvim-alternatives*
- kitty_grab - Keyboard-driven screen grabber for Kitty
- kitty-kitten-search - Kitten for the kitty terminal emulator providing live incremental search in the terminal history.
+==============================================================================
+2. Links *kitty-scrollback.nvim-links*
+
+1. *style_simple_false*: https://github.com/mikesmithgh/kitty-scrollback.nvim/assets/10135646/662bf132-0b39-4028-b69f-eb85fbb69b60
+2. *style_simple_true*: https://github.com/mikesmithgh/kitty-scrollback.nvim/assets/10135646/c19a1869-e4e4-40fd-b619-fed771d0153f
+
Generated by panvimdoc
vim:tw=78:ts=8:noet:ft=help:norl:
diff --git a/doc/kitty-scrollback.nvim_spec.txt b/doc/kitty-scrollback.nvim_spec.txt
index 5424ace0..080ad267 100644
--- a/doc/kitty-scrollback.nvim_spec.txt
+++ b/doc/kitty-scrollback.nvim_spec.txt
@@ -16,15 +16,18 @@ KsbKittyOpts *kitty-scrollback.launch.KsbKittyOpts*
KsbKittyData *kitty-scrollback.launch.KsbKittyData*
Fields: ~
- {scrolled_by} (integer) the number of lines currently scrolled in kitty
- {cursor_x} (integer) position of the cusor in the column in kitty
- {cursor_y} (integer) position of the cursor in the row in kitty
- {lines} (integer) the number of rows of the screen in kitty
- {columns} (integer) the number of columns of the screen in kitty
- {window_id} (integer) the id of the window to get scrollback text
- {window_title} (string) the title of the window to get scrollback text
- {ksb_dir} (string) the base runtime path of kitty-scrollback.nvim
- {config_files} (table)
+ {scrolled_by} (integer) the number of lines currently scrolled in kitty
+ {cursor_x} (integer) position of the cusor in the column in kitty
+ {cursor_y} (integer) position of the cursor in the row in kitty
+ {lines} (integer) the number of rows of the screen in kitty
+ {columns} (integer) the number of columns of the screen in kitty
+ {window_id} (integer) the id of the window to get scrollback text
+ {window_title} (string) the title of the window to get scrollback text
+ {ksb_dir} (string) the base runtime path of kitty-scrollback.nvim
+ {kitty_scrollback_config} (string) the config name of user config options
+ {kitty_opts} (KsbKittyOpts) relevent kitty configuration values
+ {kitty_config_dir} (string) kitty configuration directory path
+ {kitty_version} (table) kitty version
KsbPrivate *kitty-scrollback.launch.KsbPrivate*
@@ -94,7 +97,7 @@ KsbPasteWindowOpts
Fields: ~
{highlight_as_normal_win} (nil|fun():boolean) If function returns true, use Normal highlight group. If false, use NormalFloat
{filetype} (string|nil) The filetype of the paste window
- {hide_footer} (boolean|nil) If true, hide the footer when the paste window is initially opened
+ {hide_footer} (boolean|nil) If true, hide mappings in the footer when the paste window is initially opened
{winblend} (integer|nil) The winblend setting of the window, see :help winblend
{winopts_overrides} (KsbWinOptsOverrideFunction|nil) Paste float window overrides, see nvim_open_win() for configuration
{footer_winopts_overrides} (KsbFooterWinOptsOverrideFunction|nil) Paste footer window overrides, see nvim_open_win() for configuration
@@ -164,6 +167,12 @@ M.toggle_footer() *kitty-scrollback.api.toggle_footer*
open or closed. Otherwise, no operation
+KsbGenKittenModes *kitty-scrollback.api.KsbGenKittenModes*
+
+ Type: ~
+ string|"maps"|"commands"
+
+
M.generate_kittens() *kitty-scrollback.api.generate_kittens*
diff --git a/lua/kitty-scrollback/api.lua b/lua/kitty-scrollback/api.lua
index 535e6edc..4e365abc 100644
--- a/lua/kitty-scrollback/api.lua
+++ b/lua/kitty-scrollback/api.lua
@@ -68,89 +68,133 @@ M.toggle_footer = function()
end
end
-M.generate_kittens = function(all)
+---@alias KsbGenKittenModes string | 'maps' | 'commands'
+
+---Generate Kitten commands used as reference for configuring `kitty.conf`
+---@param all boolean|nil
+---@param generate_modes table|nil
+M.generate_kittens = function(all, generate_modes)
+ generate_modes = (generate_modes and next(generate_modes)) and generate_modes or { 'maps' }
+ local target_gen_modes = {}
+ for _, gen_mode in pairs(generate_modes) do
+ target_gen_modes[gen_mode] = true
+ end
+
local kitty_scrollback_kitten =
vim.api.nvim_get_runtime_file('python/kitty_scrollback_nvim.py', false)[1]
- local kitty_scrollback_configs =
- vim.api.nvim_get_runtime_file('lua/kitty-scrollback/configs', false)[1]
+ local example_path =
+ vim.api.nvim_get_runtime_file('lua/kitty-scrollback/configs/example.lua', false)[1]
- local ksb_configs = { '' }
local action_alias = 'kitty_scrollback_nvim'
- local top_ksb_configs = {
+ local alias_config = {
'# kitty-scrollback.nvim Kitten alias',
- 'action_alias '
- .. action_alias
- .. ' kitten '
- .. kitty_scrollback_kitten
- .. ' --cwd '
- .. kitty_scrollback_configs,
+ 'action_alias ' .. action_alias .. ' kitten ' .. kitty_scrollback_kitten,
'',
+ }
+
+ local builtin_map_configs = {
'# Browse scrollback buffer in nvim',
'map ctrl+shift+h ' .. action_alias,
- }
- for _, c in pairs(vim.api.nvim_get_runtime_file('lua/kitty-scrollback/configs/*.lua', true)) do
- local name = vim.fn.fnamemodify(c, ':t:r')
- local ksb_config = require('kitty-scrollback.configs.' .. name).config() or {}
- local keymap = ksb_config.kitty_keymap
- local config = (keymap or 'map f1')
- .. ' '
+ '# Browse output of the last shell command in nvim',
+ 'map ctrl+shift+g ' .. action_alias .. ' --config ksb_builtin_last_cmd_output',
+ '# Show clicked command output in nvim',
+ 'mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : '
.. action_alias
- .. ' --config-file '
- .. name
- .. '.lua'
- table.insert(top_ksb_configs, ksb_config.kitty_keymap_description)
- if keymap then
- table.insert(top_ksb_configs, config)
- else
- table.insert(ksb_configs, config)
- end
- end
+ .. ' --config ksb_builtin_last_visited_cmd_output',
+ }
+
+ local ksb_example = require('kitty-scrollback.configs.example').configs
+ local example_configs = vim.tbl_map(
+ function(name)
+ if name == '' or name:match('^#.*') then
+ return name
+ end
+ return 'map f1 ' .. action_alias .. ' --config ' .. name
+ end,
+ vim.list_extend({
+ '',
+ '# Example kitty-scrollback.nvim config overrides',
+ '# See ' .. example_path .. ' for config details',
+ }, vim.tbl_keys(ksb_example))
+ )
local nvim_args = vim.tbl_map(function(c)
+ if c == '' or c:match('^#.*') then
+ return c
+ end
return 'map f1 ' .. action_alias .. ' ' .. c
end, {
+ [[]],
+ [[# Example kitty-scrollback.nvim nvim overrides]],
[[--no-nvim-args --env NVIM_APPNAME=ksb-nvim]],
[[--nvim-args +'colorscheme tokyonight']],
- [[--nvim-args +'lua vim.defer_fn(function() vim.api.nvim_set_option_value("filetype", "markdown", { buf = 0 }); vim.cmd("silent! CellularAutomaton make_it_rain") end, 1000)']],
+ [[--nvim-args +'lua vim.defer_fn(function() vim.api.nvim_set_option_value("filetype", "markdown", { buf = 0 }); vim.cmd("silent! CellularAutomaton make_it_rain") end, 6000)']],
})
- local kitten_configs = vim.list_extend(
- vim.list_extend(vim.tbl_extend('force', top_ksb_configs, {}), ksb_configs),
+ local kitten_map_configs = vim.list_extend(
+ vim.list_extend(vim.tbl_extend('force', builtin_map_configs, {}), example_configs),
nvim_args
)
+
+ local builtin_command_configs = vim.tbl_map(function(config)
+ return config:gsub(
+ '^.*map%s%S+.*kitty_scrollback_nvim',
+ 'kitty @ kitten ' .. kitty_scrollback_kitten
+ )
+ end, builtin_map_configs)
+
+ local kitten_command_configs = vim.tbl_map(function(config)
+ return config:gsub(
+ '^.*map%s%S+.*kitty_scrollback_nvim',
+ 'kitty @ kitten ' .. kitty_scrollback_kitten
+ )
+ end, kitten_map_configs)
+
+ local configs = {}
+
+ if all then
+ if target_gen_modes['maps'] then
+ vim.list_extend(configs, alias_config)
+ vim.list_extend(configs, kitten_map_configs)
+ table.insert(configs, '')
+ end
+ if target_gen_modes['commands'] then
+ vim.list_extend(configs, kitten_command_configs)
+ end
+ else
+ if target_gen_modes['maps'] then
+ vim.list_extend(configs, alias_config)
+ vim.list_extend(configs, builtin_map_configs)
+ table.insert(configs, '')
+ end
+ if target_gen_modes['commands'] then
+ vim.list_extend(configs, builtin_command_configs)
+ end
+ end
+
local bufid = vim.api.nvim_create_buf(true, true)
vim.api.nvim_set_option_value('filetype', 'kitty', {
buf = bufid,
})
vim.api.nvim_set_current_buf(bufid)
- if all then
- vim.api.nvim_buf_set_lines(bufid, 0, -1, false, kitten_configs)
- else
- vim.api.nvim_buf_set_lines(bufid, 0, -1, false, top_ksb_configs)
- end
+ vim.api.nvim_buf_set_lines(bufid, 0, -1, false, configs)
end
M.checkhealth = function()
local kitty_scrollback_kitten =
vim.api.nvim_get_runtime_file('python/kitty_scrollback_nvim.py', false)[1]
- local checkhealth_config =
- vim.api.nvim_get_runtime_file('lua/kitty-scrollback/configs/checkhealth.lua', false)[1]
- if
- not (
- vim.fn.has('nvim-0.10') > 0
- and vim
- .system({
- 'kitty',
- '@',
- 'kitten',
- kitty_scrollback_kitten,
- '--config-file',
- checkhealth_config,
- })
- :wait().code
- == 0
- )
- then
+ if vim.fn.has('nvim-0.10') > 0 then
+ vim
+ .system({
+ 'kitty',
+ '@',
+ 'kitten',
+ kitty_scrollback_kitten,
+ '--config',
+ 'ksb_builtin_checkhealth',
+ })
+ :wait()
+ else
-- fallback on checkhealth for earlier versions of nvim
vim.cmd.checkhealth('kitty-scrollback')
end
diff --git a/lua/kitty-scrollback/configs/builtin.lua b/lua/kitty-scrollback/configs/builtin.lua
new file mode 100644
index 00000000..e7d45053
--- /dev/null
+++ b/lua/kitty-scrollback/configs/builtin.lua
@@ -0,0 +1,35 @@
+local prefix = 'ksb_builtin_'
+
+return {
+ configs = {
+ [prefix .. 'get_text_all'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'all',
+ ansi = true,
+ },
+ }
+ end,
+ [prefix .. 'last_cmd_output'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_cmd_output',
+ ansi = true,
+ },
+ }
+ end,
+ [prefix .. 'last_visited_cmd_output'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_visited_cmd_output',
+ ansi = true,
+ },
+ }
+ end,
+ [prefix .. 'checkhealth'] = function()
+ return {
+ checkhealth = true,
+ }
+ end,
+ },
+}
diff --git a/lua/kitty-scrollback/configs/callbacks.lua b/lua/kitty-scrollback/configs/callbacks.lua
deleted file mode 100644
index 01edf69a..00000000
--- a/lua/kitty-scrollback/configs/callbacks.lua
+++ /dev/null
@@ -1,51 +0,0 @@
-local M = {}
-
-local msg = {}
-
-M.config = function(kitty_data)
- return {
- callbacks = {
- after_setup = function(kitty_data, opts)
- vim.defer_fn(function()
- table.insert(
- msg,
- '# kitty-scrollback after_setup callback triggered @ ' .. vim.fn.strftime('%c')
- )
- end, 1000)
- end,
- after_launch = function(kitty_data, opts)
- vim.defer_fn(function()
- table.insert(
- msg,
- '# kitty-scrollback after_launch callback triggered @ ' .. vim.fn.strftime('%c')
- )
- end, 2000)
- end,
- after_ready = function(kitty_data, opts)
- vim.defer_fn(function()
- table.insert(
- msg,
- '# kitty-scrollback after_ready callback triggered @ ' .. vim.fn.strftime('%c')
- )
- table.insert(msg, '# kitty_data:')
- table.insert(msg, '# ' .. vim.fn.json_encode(kitty_data))
- table.insert(msg, '# opts:')
- table.insert(msg, '# ' .. vim.fn.json_encode(vim.inspect(opts)))
- local curbuf = vim.api.nvim_get_current_buf()
- vim.cmd.startinsert()
- vim.fn.timer_start(250, function(t) ---@diagnostic disable-line: redundant-parameter
- if curbuf ~= vim.api.nvim_get_current_buf() then
- vim.fn.timer_stop(t)
- vim.api.nvim_buf_set_lines(0, 0, -1, false, msg)
- vim.cmd.stopinsert()
- end
- end, {
- ['repeat'] = 12,
- })
- end, 3000)
- end,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/checkhealth.lua b/lua/kitty-scrollback/configs/checkhealth.lua
deleted file mode 100644
index 1789f3ae..00000000
--- a/lua/kitty-scrollback/configs/checkhealth.lua
+++ /dev/null
@@ -1,9 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- checkhealth = true,
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/example.lua b/lua/kitty-scrollback/configs/example.lua
new file mode 100644
index 00000000..0cd10a58
--- /dev/null
+++ b/lua/kitty-scrollback/configs/example.lua
@@ -0,0 +1,349 @@
+local prefix = 'ksb_example_'
+
+return {
+ configs = {
+ --- Example configuration invoking callbacks with delays and prints timestamps
+ --- Includes after_setup, after_launch, and after_ready callback functions
+ --- and prints kitty_data and options that are passed to after_ready function
+ --- This example is not practical and only for demonstration purposes
+ ---@return KsbCallbacks
+ [prefix .. 'callbacks'] = function()
+ local msg = {}
+ return {
+ callbacks = {
+ after_setup = function()
+ vim.defer_fn(function()
+ table.insert(
+ msg,
+ '# kitty-scrollback after_setup callback triggered @ ' .. vim.fn.strftime('%c')
+ )
+ end, 1000)
+ end,
+ after_launch = function()
+ vim.defer_fn(function()
+ table.insert(
+ msg,
+ '# kitty-scrollback after_launch callback triggered @ ' .. vim.fn.strftime('%c')
+ )
+ end, 2000)
+ end,
+ after_ready = function(kitty_data, opts)
+ vim.defer_fn(function()
+ vim.cmd.startinsert()
+ table.insert(
+ msg,
+ '# kitty-scrollback after_ready callback triggered @ ' .. vim.fn.strftime('%c')
+ )
+ table.insert(msg, '# kitty_data:')
+ table.insert(msg, '# ' .. vim.fn.json_encode(kitty_data))
+ table.insert(msg, '# opts:')
+ table.insert(msg, '# ' .. vim.fn.json_encode(vim.inspect(opts)))
+ vim.api.nvim_buf_set_lines(0, 0, -1, false, msg)
+ vim.cmd.stopinsert()
+ end, 3000)
+ end,
+ },
+ }
+ end,
+ [prefix .. 'get_text_all_plain'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'all',
+ ansi = false,
+ },
+ }
+ end,
+ [prefix .. 'get_text_first_cmd_output_on_screen'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'first_cmd_output_on_screen',
+ ansi = true,
+ },
+ }
+ end,
+ [prefix .. 'get_text_first_cmd_output_on_screen_plain'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'first_cmd_output_on_screen',
+ ansi = false,
+ },
+ }
+ end,
+ [prefix .. 'get_text_last_cmd_output_plain'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_cmd_output',
+ ansi = false,
+ },
+ }
+ end,
+ [prefix .. 'get_text_last_non_empty_output'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_non_empty_output',
+ ansi = true,
+ },
+ }
+ end,
+ [prefix .. 'get_text_last_non_empty_output_plain'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_non_empty_output',
+ ansi = false,
+ },
+ }
+ end,
+ [prefix .. 'get_text_last_visited_cmd_output_plain'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_visited_cmd_output',
+ ansi = false,
+ },
+ }
+ end,
+ [prefix .. 'get_text_screen'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'screen',
+ ansi = true,
+ },
+ }
+ end,
+ [prefix .. 'get_text_screen_plain'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'screen',
+ ansi = false,
+ },
+ }
+ end,
+ [prefix .. 'get_text_selection'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'selection',
+ ansi = true,
+ },
+ }
+ end,
+ [prefix .. 'get_text_selection_keep_selection'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'selection',
+ ansi = true,
+ clear_selection = false,
+ },
+ }
+ end,
+ [prefix .. 'get_text_selection_plain'] = function()
+ return {
+ kitty_get_text = {
+ extent = 'selection',
+ ansi = false,
+ },
+ }
+ end,
+ [prefix .. 'highlight_overrides'] = function()
+ return {
+ highlight_overrides = {
+ KittyScrollbackNvimNormal = {
+ fg = '#ee82ee',
+ bg = '#ee82ee',
+ },
+ KittyScrollbackNvimHeart = {
+ fg = '#ff0000',
+ bg = '#4b0082',
+ },
+ KittyScrollbackNvimSpinner = {
+ fg = '#000099',
+ bg = '#4b0082',
+ },
+ KittyScrollbackNvimReady = {
+ fg = '#4b0082',
+ bg = '#ffa500',
+ },
+ KittyScrollbackNvimKitty = {
+ fg = '#ffa500',
+ bg = '#000099',
+ },
+ KittyScrollbackNvimVim = {
+ fg = '#008000',
+ bg = '#000099',
+ },
+ KittyScrollbackNvimPasteWinNormal = {
+ link = 'IncSearch',
+ },
+ KittyScrollbackNvimPasteWinFloatBorder = {
+ link = 'IncSearch',
+ },
+ KittyScrollbackNvimPasteWinFloatTitle = {
+ link = 'IncSearch',
+ },
+ },
+ }
+ end,
+ [prefix .. 'keymaps_custom'] = function()
+ vim.keymap.set({ 'v' }, 'sY', '(KsbVisualYankLine)', {})
+ vim.keymap.set({ 'v' }, 'sy', '(KsbVisualYank)', {})
+ vim.keymap.set({ 'n' }, 'sY', '(KsbNormalYankEnd)', {})
+ vim.keymap.set({ 'n' }, 'sy', '(KsbNormalYank)', {})
+ vim.keymap.set({ 'n' }, 'syy', '(KsbYankLine)', {})
+
+ vim.keymap.set({ 'n' }, 'q', '(KsbCloseOrQuitAll)', {})
+ vim.keymap.set({ 'n', 't', 'i' }, 'ZZ', '(KsbQuitAll)', {})
+
+ vim.keymap.set({ 'n' }, '', '(KsbToggleFooter)', {})
+ vim.keymap.set({ 'n', 'i' }, '', '(KsbExecuteCmd)', {})
+ vim.keymap.set({ 'n', 'i' }, '', '(KsbPasteCmd)', {})
+ end,
+ [prefix .. 'keymaps_disabled'] = function()
+ return {
+ keymaps_enabled = false,
+ }
+ end,
+ [prefix .. 'paste_win_filetype'] = function()
+ return {
+ paste_window = {
+ filetype = 'markdown',
+ },
+ callbacks = {
+ after_ready = vim.schedule_wrap(function()
+ local msg = {
+ '',
+ '\t',
+ '',
+ '# kitty-scrollback.nvim example',
+ '',
+ '## Change paste window filetype to `markdown`',
+ '',
+ '```lua',
+ 'paste_window = {',
+ ' filetype = "markdown", -- change this to your desired filetype',
+ '},',
+ '```',
+ }
+ local curbuf = vim.api.nvim_get_current_buf()
+ vim.cmd.startinsert()
+ vim.fn.timer_start(250, function(t) ---@diagnostic disable-line: redundant-parameter
+ if curbuf ~= vim.api.nvim_get_current_buf() then
+ vim.fn.timer_stop(t)
+ vim.api.nvim_buf_set_lines(0, 0, -1, false, msg)
+ vim.cmd.stopinsert()
+ vim.fn.setcursorcharpos(2, 4)
+ end
+ end, {
+ ['repeat'] = 12,
+ })
+ end),
+ },
+ }
+ end,
+ [prefix .. 'paste_win_hide_mappings'] = function()
+ return {
+ paste_window = {
+ hide_footer = true,
+ },
+ }
+ end,
+ [prefix .. 'paste_win_highlight_as_float'] = function()
+ return {
+ paste_window = {
+ highlight_as_normal_win = function()
+ return false
+ end,
+ },
+ }
+ end,
+ [prefix .. 'paste_win_register'] = function()
+ return {
+ paste_window = {
+ yank_register = '*',
+ },
+ }
+ end,
+ [prefix .. 'paste_win_register_disabled'] = function()
+ return {
+ paste_window = {
+ yank_register_enabled = false,
+ },
+ }
+ end,
+ [prefix .. 'paste_win_winblend'] = function()
+ return {
+ paste_window = {
+ winblend = 50,
+ },
+ }
+ end,
+ [prefix .. 'paste_win_winopts'] = function()
+ return {
+ paste_window = {
+ winblend = 10,
+ winopts_overrides = function()
+ local h = vim.o.lines - 5 -- TODO: magic number 3 for footer and 2 for border
+ return {
+ border = 'solid',
+ row = 0,
+ col = 0,
+ height = h < 1 and 3 or h, -- TODO: magic number 3 for footer
+ width = vim.o.columns,
+ }
+ end,
+ footer_winopts_overrides = function()
+ return {
+ border = 'single',
+ title = ' kitty-scrollback.nvim ',
+ title_pos = 'center',
+ }
+ end,
+ },
+ }
+ end,
+ [prefix .. 'restore_opts'] = function()
+ vim.o.termguicolors = true
+ vim.o.number = true
+ return {
+ restore_options = true,
+ }
+ end,
+ [prefix .. 'status_win_autoclose'] = function()
+ return {
+ status_window = {
+ autoclose = true,
+ },
+ }
+ end,
+ [prefix .. 'status_win_disabled'] = function()
+ return {
+ status_window = {
+ enabled = false,
+ },
+ }
+ end,
+ [prefix .. 'status_win_show_timer'] = function()
+ return {
+ status_window = {
+ show_timer = true,
+ },
+ callbacks = {
+ after_setup = function()
+ vim.loop.sleep(4000)
+ end,
+ },
+ }
+ end,
+ [prefix .. 'status_win_simple'] = function()
+ return {
+ status_window = {
+ style_simple = true,
+ },
+ }
+ end,
+ [prefix .. 'status_win_try_detect_nerd_fonts'] = function()
+ return {
+ status_window = {
+ style_simple = not require('kitty-scrollback.kitty_commands').try_detect_nerd_font(),
+ },
+ }
+ end,
+ },
+}
diff --git a/lua/kitty-scrollback/configs/get_text_all_plain.lua b/lua/kitty-scrollback/configs/get_text_all_plain.lua
deleted file mode 100644
index c0280975..00000000
--- a/lua/kitty-scrollback/configs/get_text_all_plain.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'all',
- ansi = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_first_cmd_output_on_screen.lua b/lua/kitty-scrollback/configs/get_text_first_cmd_output_on_screen.lua
deleted file mode 100644
index 7a23c094..00000000
--- a/lua/kitty-scrollback/configs/get_text_first_cmd_output_on_screen.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'first_cmd_output_on_screen',
- ansi = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_first_cmd_output_on_screen_plain.lua b/lua/kitty-scrollback/configs/get_text_first_cmd_output_on_screen_plain.lua
deleted file mode 100644
index 570fd510..00000000
--- a/lua/kitty-scrollback/configs/get_text_first_cmd_output_on_screen_plain.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'first_cmd_output_on_screen',
- ansi = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_last_cmd_output.lua b/lua/kitty-scrollback/configs/get_text_last_cmd_output.lua
deleted file mode 100644
index af918174..00000000
--- a/lua/kitty-scrollback/configs/get_text_last_cmd_output.lua
+++ /dev/null
@@ -1,14 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_keymap = 'map ctrl+shift+g',
- kitty_keymap_description = '# Browse output of the last shell command in nvim',
- kitty_get_text = {
- extent = 'last_cmd_output',
- ansi = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_last_cmd_output_plain.lua b/lua/kitty-scrollback/configs/get_text_last_cmd_output_plain.lua
deleted file mode 100644
index 6d255eb9..00000000
--- a/lua/kitty-scrollback/configs/get_text_last_cmd_output_plain.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'last_cmd_output',
- ansi = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_last_non_empty_output.lua b/lua/kitty-scrollback/configs/get_text_last_non_empty_output.lua
deleted file mode 100644
index 6f512f0a..00000000
--- a/lua/kitty-scrollback/configs/get_text_last_non_empty_output.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'last_non_empty_output',
- ansi = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_last_non_empty_output_plain.lua b/lua/kitty-scrollback/configs/get_text_last_non_empty_output_plain.lua
deleted file mode 100644
index 0ebcccf4..00000000
--- a/lua/kitty-scrollback/configs/get_text_last_non_empty_output_plain.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'last_non_empty_output',
- ansi = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_last_visited_cmd_output.lua b/lua/kitty-scrollback/configs/get_text_last_visited_cmd_output.lua
deleted file mode 100644
index 155e511d..00000000
--- a/lua/kitty-scrollback/configs/get_text_last_visited_cmd_output.lua
+++ /dev/null
@@ -1,14 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_keymap = 'mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output :',
- kitty_keymap_description = '# Show clicked command output in nvim',
- kitty_get_text = {
- extent = 'last_visited_cmd_output',
- ansi = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_last_visited_cmd_output_plain.lua b/lua/kitty-scrollback/configs/get_text_last_visited_cmd_output_plain.lua
deleted file mode 100644
index 3438409e..00000000
--- a/lua/kitty-scrollback/configs/get_text_last_visited_cmd_output_plain.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'last_visited_cmd_output',
- ansi = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_screen.lua b/lua/kitty-scrollback/configs/get_text_screen.lua
deleted file mode 100644
index 9d9c58ec..00000000
--- a/lua/kitty-scrollback/configs/get_text_screen.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'screen',
- ansi = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_screen_plain.lua b/lua/kitty-scrollback/configs/get_text_screen_plain.lua
deleted file mode 100644
index 3c620dae..00000000
--- a/lua/kitty-scrollback/configs/get_text_screen_plain.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'screen',
- ansi = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_selection.lua b/lua/kitty-scrollback/configs/get_text_selection.lua
deleted file mode 100644
index 1649740b..00000000
--- a/lua/kitty-scrollback/configs/get_text_selection.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'selection',
- ansi = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_selection_keep_selection.lua b/lua/kitty-scrollback/configs/get_text_selection_keep_selection.lua
deleted file mode 100644
index b9e17c88..00000000
--- a/lua/kitty-scrollback/configs/get_text_selection_keep_selection.lua
+++ /dev/null
@@ -1,13 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'selection',
- ansi = true,
- clear_selection = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/get_text_selection_plain.lua b/lua/kitty-scrollback/configs/get_text_selection_plain.lua
deleted file mode 100644
index 2ecb588c..00000000
--- a/lua/kitty-scrollback/configs/get_text_selection_plain.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- kitty_get_text = {
- extent = 'selection',
- ansi = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/highlight_overrides.lua b/lua/kitty-scrollback/configs/highlight_overrides.lua
deleted file mode 100644
index 197a9556..00000000
--- a/lua/kitty-scrollback/configs/highlight_overrides.lua
+++ /dev/null
@@ -1,43 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- highlight_overrides = {
- KittyScrollbackNvimNormal = {
- fg = '#ee82ee',
- bg = '#ee82ee',
- },
- KittyScrollbackNvimHeart = {
- fg = '#ff0000',
- bg = '#4b0082',
- },
- KittyScrollbackNvimSpinner = {
- fg = '#000099',
- bg = '#4b0082',
- },
- KittyScrollbackNvimReady = {
- fg = '#4b0082',
- bg = '#ffa500',
- },
- KittyScrollbackNvimKitty = {
- fg = '#ffa500',
- bg = '#000099',
- },
- KittyScrollbackNvimVim = {
- fg = '#008000',
- bg = '#000099',
- },
- KittyScrollbackNvimPasteWinNormal = {
- link = 'Pmenu',
- },
- KittyScrollbackNvimPasteWinFloatBorder = {
- link = 'Pmenu',
- },
- KittyScrollbackNvimPasteWinFloatTitle = {
- link = 'Title',
- },
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/keymaps_custom.lua b/lua/kitty-scrollback/configs/keymaps_custom.lua
deleted file mode 100644
index 8f760256..00000000
--- a/lua/kitty-scrollback/configs/keymaps_custom.lua
+++ /dev/null
@@ -1,18 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- vim.keymap.set({ 'v' }, 'sY', '(KsbVisualYankLine)', {})
- vim.keymap.set({ 'v' }, 'sy', '(KsbVisualYank)', {})
- vim.keymap.set({ 'n' }, 'sY', '(KsbNormalYankEnd)', {})
- vim.keymap.set({ 'n' }, 'sy', '(KsbNormalYank)', {})
- vim.keymap.set({ 'n' }, 'syy', '(KsbYankLine)', {})
-
- vim.keymap.set({ 'n' }, 'q', '(KsbCloseOrQuitAll)', {})
- vim.keymap.set({ 'n', 't', 'i' }, 'ZZ', '(KsbQuitAll)', {})
-
- vim.keymap.set({ 'n' }, '', '(KsbToggleFooter)', {})
- vim.keymap.set({ 'n', 'i' }, '', '(KsbExecuteCmd)', {})
- vim.keymap.set({ 'n', 'i' }, '', '(KsbPasteCmd)', {})
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/keymaps_disabled.lua b/lua/kitty-scrollback/configs/keymaps_disabled.lua
deleted file mode 100644
index 8b2fa82c..00000000
--- a/lua/kitty-scrollback/configs/keymaps_disabled.lua
+++ /dev/null
@@ -1,9 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- keymaps_enabled = false,
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/paste_win_filetype.lua b/lua/kitty-scrollback/configs/paste_win_filetype.lua
deleted file mode 100644
index def6b60a..00000000
--- a/lua/kitty-scrollback/configs/paste_win_filetype.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- paste_window = {
- filetype = 'fish',
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/paste_win_hide_footer.lua b/lua/kitty-scrollback/configs/paste_win_hide_footer.lua
deleted file mode 100644
index 6070bafa..00000000
--- a/lua/kitty-scrollback/configs/paste_win_hide_footer.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- paste_window = {
- hide_footer = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/paste_win_highlight_as_float.lua b/lua/kitty-scrollback/configs/paste_win_highlight_as_float.lua
deleted file mode 100644
index b9aa8ef7..00000000
--- a/lua/kitty-scrollback/configs/paste_win_highlight_as_float.lua
+++ /dev/null
@@ -1,13 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- paste_window = {
- highlight_as_normal_win = function()
- return false
- end,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/paste_win_register.lua b/lua/kitty-scrollback/configs/paste_win_register.lua
deleted file mode 100644
index 80eeeb7b..00000000
--- a/lua/kitty-scrollback/configs/paste_win_register.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- paste_window = {
- yank_register = '*',
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/paste_win_register_disabled.lua b/lua/kitty-scrollback/configs/paste_win_register_disabled.lua
deleted file mode 100644
index ecc5d270..00000000
--- a/lua/kitty-scrollback/configs/paste_win_register_disabled.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- paste_window = {
- yank_register_enabled = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/paste_win_winblend.lua b/lua/kitty-scrollback/configs/paste_win_winblend.lua
deleted file mode 100644
index ac8cca1b..00000000
--- a/lua/kitty-scrollback/configs/paste_win_winblend.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- paste_window = {
- winblend = 10,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/paste_win_winopts.lua b/lua/kitty-scrollback/configs/paste_win_winopts.lua
deleted file mode 100644
index 3ec30a8a..00000000
--- a/lua/kitty-scrollback/configs/paste_win_winopts.lua
+++ /dev/null
@@ -1,28 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- paste_window = {
- winblend = 10,
- winopts_overrides = function(paste_winopts)
- local h = vim.o.lines - 5 -- TODO: magic number 3 for footer and 2 for border
- return {
- border = 'solid',
- row = 0,
- col = 0,
- height = h < 1 and 3 or h, -- TODO: magic number 3 for footer
- width = vim.o.columns,
- }
- end,
- footer_winopts_overrides = function(footer_winopts, paste_winopts)
- return {
- border = 'single',
- title = ' kitty-scrollback.nvim ',
- title_pos = 'center',
- }
- end,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/restore_opts.lua b/lua/kitty-scrollback/configs/restore_opts.lua
deleted file mode 100644
index 4c73bc57..00000000
--- a/lua/kitty-scrollback/configs/restore_opts.lua
+++ /dev/null
@@ -1,9 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- restore_options = true,
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/status_win_autoclose.lua b/lua/kitty-scrollback/configs/status_win_autoclose.lua
deleted file mode 100644
index 8e2c3faf..00000000
--- a/lua/kitty-scrollback/configs/status_win_autoclose.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- status_window = {
- autoclose = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/status_win_disabled.lua b/lua/kitty-scrollback/configs/status_win_disabled.lua
deleted file mode 100644
index 5fbd7495..00000000
--- a/lua/kitty-scrollback/configs/status_win_disabled.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- status_window = {
- enabled = false,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/status_win_show_timer.lua b/lua/kitty-scrollback/configs/status_win_show_timer.lua
deleted file mode 100644
index ebe3d015..00000000
--- a/lua/kitty-scrollback/configs/status_win_show_timer.lua
+++ /dev/null
@@ -1,16 +0,0 @@
-local M = {}
-
-M.config = function()
- return {
- status_window = {
- show_timer = true,
- },
- callbacks = {
- after_setup = function()
- vim.loop.sleep(4000)
- end,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/status_win_simple.lua b/lua/kitty-scrollback/configs/status_win_simple.lua
deleted file mode 100644
index 7b1ffea0..00000000
--- a/lua/kitty-scrollback/configs/status_win_simple.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- status_window = {
- style_simple = true,
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/configs/status_win_try_detect_nerd_fonts.lua b/lua/kitty-scrollback/configs/status_win_try_detect_nerd_fonts.lua
deleted file mode 100644
index db840b7d..00000000
--- a/lua/kitty-scrollback/configs/status_win_try_detect_nerd_fonts.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local M = {}
-
-M.config = function(kitty_data)
- return {
- status_window = {
- style_simple = not require('kitty-scrollback.kitty_commands').try_detect_nerd_font(),
- },
- }
-end
-
-return M
diff --git a/lua/kitty-scrollback/health.lua b/lua/kitty-scrollback/health.lua
index 3c938084..18a83b25 100644
--- a/lua/kitty-scrollback/health.lua
+++ b/lua/kitty-scrollback/health.lua
@@ -67,15 +67,11 @@ local function check_has_kitty_data()
else
local kitty_scrollback_kitten =
vim.api.nvim_get_runtime_file('python/kitty_scrollback_nvim.py', false)[1]
- local checkhealth_config =
- vim.api.nvim_get_runtime_file('lua/kitty-scrollback/configs/checkhealth.lua', false)[1]
local checkhealth_command = '`kitty @ kitten '
.. kitty_scrollback_kitten
- .. ' --config-file '
- .. checkhealth_config
- .. '`'
+ .. ' --config ksb_builtin_checkhealth`'
vim.health.warn('No Kitty data available unable to perform a complete healthcheck', {
- 'Add the config options `checkhealth = true` to your *config-file* or execute the command `:KittyScrollbackCheckHealth` '
+ 'Add the config options `checkhealth = true` to your *config* or execute the command `:KittyScrollbackCheckHealth` '
.. 'to run `checkhealth` within the context of a Kitten',
checkhealth_command,
})
diff --git a/lua/kitty-scrollback/init.lua b/lua/kitty-scrollback/init.lua
index b415768f..faa54253 100644
--- a/lua/kitty-scrollback/init.lua
+++ b/lua/kitty-scrollback/init.lua
@@ -1,8 +1,14 @@
---@mod kitty-scrollback
local M = {}
+---@type table
+M.configs = {}
+
---Create commands for generating kitty-scrollback.nvim kitten configs
-M.setup = function()
+M.setup = function(configs)
+ if configs then
+ M.configs = configs
+ end
---@brief [[
---:KittyScrollbackGenerateKittens Generate Kitten commands used as reference for configuring `kitty.conf`
---
@@ -10,9 +16,13 @@ M.setup = function()
--- |kitty.api.generate_kittens|
---@brief ]]
vim.api.nvim_create_user_command('KittyScrollbackGenerateKittens', function(o)
- require('kitty-scrollback.api').generate_kittens(o.bang)
+ require('kitty-scrollback.api').generate_kittens(o.bang, o.fargs)
end, {
bang = true,
+ nargs = '*',
+ complete = function()
+ return { 'maps', 'commands' }
+ end,
})
---@brief [[
@@ -21,11 +31,15 @@ M.setup = function()
--- See: ~
--- |kitty.api.checkhealth|
---@brief ]]
- vim.api.nvim_create_user_command(
- 'KittyScrollbackCheckHealth',
- vim.schedule_wrap(require('kitty-scrollback.api').checkhealth),
- {}
- )
+ vim.api.nvim_create_user_command('KittyScrollbackCheckHealth', function()
+ require('kitty-scrollback.api').checkhealth()
+ end, {})
+
+ vim.api.nvim_create_autocmd('User', {
+ pattern = 'KittyScrollbackCheckLaunch',
+ once = true,
+ callback = function() end,
+ })
end
return M
diff --git a/lua/kitty-scrollback/launch.lua b/lua/kitty-scrollback/launch.lua
index 7feca1ea..9084be22 100644
--- a/lua/kitty-scrollback/launch.lua
+++ b/lua/kitty-scrollback/launch.lua
@@ -39,7 +39,7 @@ local M = {}
---@field window_id integer the id of the window to get scrollback text
---@field window_title string the title of the window to get scrollback text
---@field ksb_dir string the base runtime path of kitty-scrollback.nvim
----@field config_files table the file containing a config function with user defined options
+---@field kitty_scrollback_config string the config name of user config options
---@field kitty_opts KsbKittyOpts relevent kitty configuration values
---@field kitty_config_dir string kitty configuration directory path
---@field kitty_version table kitty version
@@ -84,7 +84,7 @@ local opts = {}
---@class KsbPasteWindowOpts
---@field highlight_as_normal_win nil|fun():boolean If function returns true, use Normal highlight group. If false, use NormalFloat
---@field filetype string|nil The filetype of the paste window
----@field hide_footer boolean|nil If true, hide the footer when the paste window is initially opened
+---@field hide_footer boolean|nil If true, hide mappings in the footer when the paste window is initially opened
---@field winblend integer|nil The winblend setting of the window, see :help winblend
---@field winopts_overrides KsbWinOptsOverrideFunction|nil Paste float window overrides, see nvim_open_win() for configuration
---@field footer_winopts_overrides KsbFooterWinOptsOverrideFunction|nil Paste footer window overrides, see nvim_open_win() for configuration
@@ -252,12 +252,16 @@ M.setup = function(kitty_data_str)
p.kitty_data = vim.fn.json_decode(kitty_data_str)
load_requires() -- must be after p.kitty_data initialized
- local user_opts = {}
- if p.kitty_data.config_files and next(p.kitty_data.config_files) then
- for _, config in pairs(p.kitty_data.config_files) do
- user_opts = vim.tbl_extend('keep', user_opts, dofile(config).config(p.kitty_data) or {})
- end
+ local config_name = p.kitty_data.kitty_scrollback_config or 'default'
+ local config_source = require('kitty-scrollback')
+ if config_name:match('^ksb_builtin_.*') then
+ config_source = require('kitty-scrollback.configs.builtin')
+ end
+ if config_name:match('^ksb_example_.*') then
+ config_source = require('kitty-scrollback.configs.example')
end
+ local config_fn = config_source.configs[config_name]
+ local user_opts = config_fn and config_fn(p.kitty_data) or {}
opts = vim.tbl_deep_extend('force', default_opts, user_opts)
ksb_health.setup(p, opts)
diff --git a/media/sad_kitty_thumbs_up.png b/media/sad_kitty_thumbs_up.png
new file mode 100644
index 00000000..89c34a6a
Binary files /dev/null and b/media/sad_kitty_thumbs_up.png differ
diff --git a/python/kitty_scroll_prompt.py b/python/kitty_scroll_prompt.py
new file mode 100755
index 00000000..e88ab35c
--- /dev/null
+++ b/python/kitty_scroll_prompt.py
@@ -0,0 +1,33 @@
+from typing import List
+from kitty.boss import Boss
+from kittens.tui.handler import result_handler
+from kitty.fast_data_types import click_mouse_cmd_output
+
+
+def main():
+ raise SystemExit('Must be run as kitten kitty_scroll_prompt')
+
+
+@result_handler(type_of_input=None, no_ui=True, has_ready_notification=False)
+def handle_result(args: List[str],
+ result: str,
+ target_window_id: int,
+ boss: Boss) -> None:
+ del args[0]
+ direction = -1 # default to one previous
+ if len(args) > 0:
+ direction = int(args[0])
+ select_cmd_output = False
+ if len(args) > 1:
+ select_cmd_output = (args[1].lower() == 'true')
+ w = boss.window_id_map.get(target_window_id)
+ if w is not None:
+ if direction == 0:
+ click_mouse_cmd_output(w.os_window_id,
+ w.tab_id,
+ w.id,
+ select_cmd_output)
+ w.mouse_handle_click('prompt')
+ else:
+ w.scroll_to_prompt(direction)
+ w.mouse_handle_click('prompt')
diff --git a/python/kitty_scrollback_nvim.py b/python/kitty_scrollback_nvim.py
index cb1146be..de5dd15a 100755
--- a/python/kitty_scrollback_nvim.py
+++ b/python/kitty_scrollback_nvim.py
@@ -30,10 +30,11 @@ def get_kitty_shell_integration(kitty_opts, w):
# based on kitty source window.py
-def pipe_data(w, target_window_id, ksb_dir, config_files):
+def pipe_data(w, target_window_id, ksb_dir, config):
kitty_opts = get_options()
kitty_shell_integration = get_kitty_shell_integration(kitty_opts, w)
- data = {
+ return {
+ 'kitty_scrollback_config': config,
'scrolled_by': w.screen.scrolled_by,
'cursor_x': w.screen.cursor.x + 1,
'cursor_y': w.screen.cursor.y + 1,
@@ -61,12 +62,9 @@ def pipe_data(w, target_window_id, ksb_dir, config_files):
'kitty_config_dir': config_dir,
'kitty_version': version,
}
- if config_files:
- data['config_files'] = config_files
- return data
-def parse_nvim_args(args):
+def parse_nvim_args(args=[]):
for idx, arg in enumerate(args):
if arg.startswith('--no-nvim-args'):
return ()
@@ -91,13 +89,16 @@ def parse_env(args):
return tuple(env_args)
-def parse_config_files(args):
+def parse_config(args):
config_args = []
for idx, arg in reversed(list(enumerate(args))):
- if arg.startswith('--config-file') and (idx - 1 < len(args)):
- config_args.append(args[idx + 1])
+ if arg.startswith('--config-file'):
+ return 'crying cat --config-file'
+ if arg.startswith('--config') and (idx + 1 < len(args)):
+ config_args = args[idx + 1]
del args[idx:idx + 2]
- return config_args
+ return config_args
+ return 'default'
def parse_cwd(args):
@@ -117,10 +118,43 @@ def handle_result(args: List[str],
del args[0]
w = boss.window_id_map.get(target_window_id)
if w is not None:
- config_files = parse_config_files(args)
+ config = parse_config(args)
+ if config == 'crying cat --config-file':
+ err_cmd = (
+ 'launch',
+ '--copy-env',
+ '--type',
+ 'overlay',
+ '--title',
+ 'kitty-scrollback.nvim',
+ 'nvim',
+ ) + parse_nvim_args() + (
+ '-c',
+ 'set laststatus=0',
+ '-c',
+ 'set fillchars=eob:\\ ',
+ '-c',
+ 'set filetype=checkhealth',
+ f'{ksb_dir}/scripts/breaking_change_config_file.txt',
+ )
+
+ err_winid = boss.call_remote_control(w, err_cmd)
+
+ set_logo_cmd = ('set-window-logo',
+ '--no-response',
+ '--alpha',
+ '0.5',
+ '--position',
+ 'bottom-right',
+ f'{ksb_dir}/media/sad_kitty_thumbs_up.png')
+
+ err_win = boss.window_id_map.get(err_winid)
+ err_winid = boss.call_remote_control(err_win, set_logo_cmd)
+ return
+
cwd = parse_cwd(args)
env = parse_env(args)
- kitty_data_str = pipe_data(w, target_window_id, ksb_dir, config_files)
+ kitty_data_str = pipe_data(w, target_window_id, ksb_dir, config)
kitty_data = json.dumps(kitty_data_str)
if w.title.startswith('kitty-scrollback.nvim'):
@@ -145,6 +179,7 @@ def handle_result(args: List[str],
' pattern = [[*]], '
' callback = function() '
f' vim.opt.runtimepath:append([[{ksb_dir}]])'
+ ' vim.api.nvim_exec_autocmds([[User]], { pattern = [[KittyScrollbackLaunch]], modeline = false })'
f' require([[kitty-scrollback.launch]]).setup_and_launch([[{kitty_data}]])'
' end, '
' })')
diff --git a/scripts/breaking_change_config_file.txt b/scripts/breaking_change_config_file.txt
new file mode 100644
index 00000000..78023547
--- /dev/null
+++ b/scripts/breaking_change_config_file.txt
@@ -0,0 +1,96 @@
+BREAKING CHANGE ~
+
+ERROR Sorry πΏ
+
+Release `v2.0.0` https://github.com/mikesmithgh/kitty-scrollback.nvim/releases/tag/v2.0.0
+removed configuring *kitty-scrollback.nvim* via configuration files in favor of defining your configuration during setup.
+
+Migrating to v2.0.0 ~
+
+See https://github.com/mikesmithgh/kitty-scrollback.nvim/tree/main#-migrating-to-v200 for migration steps.
+
+What does this mean? ~
+
+When you define your *kitty-scrollback.nvim* Kitten configuration, do not use `--config-file` `yourconfigfile.lua`. Instead,
+move the contents of `yourconfigfile.lua` to an entry in the configuration passed to the *kitty-scrollback.nvim* setup function.
+
+>lua
+ require('kitty-scrollback').setup({
+ yourconfig = function()
+ ...
+ end,
+ })
+<
+
+Update your Kitten to use the name of the configuration defined in the setup function. In this example,
+`--config-file yourconfigfile.lua` changes to `--config yourconfig`
+
+Real example ~
+
+The configuration to view the last command output now references a builtin configuration instead of a file. The
+new configuation can be viewed by running `:KittyScrollbackGenerateKittens`.
+
+*Old* *configuration*
+
+The Kitten defined in `kitty.conf` references the configuration file `get_text_last_cmd_output.lua`
+
+>kitty
+ # Browse output of the last shell command in nvim
+ map ctrl+shift+g kitty_scrollback_nvim --config-file get_text_last_cmd_output.lua
+<
+
+>lua
+ -- get_text_last_cmd_output.lua
+ local M = {}
+ M.config = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_visited_cmd_output',
+ ansi = true,
+ },
+ }
+ end
+
+ return M
+<
+
+*New* *configuration*
+
+The Kitten defined in `kitty.conf` references the builtin configuration name `ksb_builtin_last_cmd_output`
+
+>kitty
+ # Browse output of the last shell command in nvim
+ map ctrl+shift+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
+<
+
+>lua
+ require('kitty-scrollback').setup({
+ ksb_builtin_last_cmd_output = function()
+ return {
+ kitty_get_text = {
+ extent = 'last_visited_cmd_output',
+ ansi = true,
+ },
+ }
+ end
+ })
+<
+
+WARNING Do not explicitly define the builtin configurations in `setup` as shown
+above, this is for illustrative purposes. Only define, your customized configurations or
+overrides in `setup`.
+
+View the Wiki for more detailed information and advanced configurations ~
+https://github.com/mikesmithgh/kitty-scrollback.nvim/wiki
+
+ `|`\___/`|`
+ =) `^`Y`^` (=
+ \ *^* / If you have any issues or questions using *kitty-scrollback.nvim* then
+ ` )=*=( ` please create an issue at
+ / \ https://github.com/mikesmithgh/kitty-scrollback.nvim/issues
+ | |
+ /| | | |\
+ \| | `|`_`|`/\
+ /_// ___/
+ \_)
+
diff --git a/scripts/init.lua b/scripts/init.lua
index 57c835bc..6f4285f4 100644
--- a/scripts/init.lua
+++ b/scripts/init.lua
@@ -2,25 +2,24 @@ local plugin_name = 'kitty-scrollback.nvim'
-- add temp path from scripts/mini.sh in case this is running locally
local tempdir = vim.trim(vim.fn.system([[sh -c "dirname $(mktemp -u)"]]))
local packpath = os.getenv('PACKPATH') or tempdir .. '/' .. plugin_name .. '.tmp/nvim/site'
-
vim.cmd('set packpath=' .. packpath)
-require('kitty-scrollback').setup()
-local mini_config_file = vim.fn.fnamemodify(vim.fn.fnamemodify(packpath, ':h'), ':h')
- .. '/mini_config.lua'
-if vim.fn.filereadable(mini_config_file) == 0 then
- local style_mini = not require('kitty-scrollback.kitty_commands').try_detect_nerd_font()
- vim.cmd.edit(mini_config_file)
- vim.api.nvim_buf_set_lines(0, 0, -1, false, {
- [[return { ]],
- [[ config = function() ]],
- [[ return { ]],
- [[ status_window = { ]],
- [[ style_simple = ]] .. tostring(style_mini) .. [[,]],
- [[ } ]],
- [[ } ]],
- [[ end, ]],
- [[}]],
- })
- vim.cmd.write({ bang = true })
-end
+local mini_opts = {
+ status_window = {
+ style_simple = not require('kitty-scrollback.kitty_commands').try_detect_nerd_font(),
+ },
+}
+require('kitty-scrollback').setup({
+ default = function()
+ return mini_opts
+ end,
+ last_cmd_output = function()
+ local builtin = require('kitty-scrollback.configs.builtin').configs.ksb_builtin_last_cmd_output
+ return vim.tbl_deep_extend('force', builtin(), mini_opts)
+ end,
+ last_visited_cmd_output = function()
+ local builtin =
+ require('kitty-scrollback.configs.builtin').configs.ksb_builtin_last_visited_cmd_output
+ return vim.tbl_deep_extend('force', builtin(), mini_opts)
+ end,
+})
diff --git a/scripts/mini.sh b/scripts/mini.sh
index 1f339bcc..1ff495c2 100755
--- a/scripts/mini.sh
+++ b/scripts/mini.sh
@@ -10,7 +10,10 @@ trap 'echo "EXIT detected with exit status $?"' EXIT
# OS temp dir & script working dir
TEMPDIR=$(dirname "$(mktemp -u)")
-BASEDIR=$(cd "$(dirname "$0")" ; pwd -P)
+BASEDIR=$(
+ cd "$(dirname "$0")"
+ pwd -P
+)
nvim_bin=${NVIM:-nvim}
plug_name=kitty-scrollback.nvim
@@ -20,49 +23,48 @@ tmp_rtp="${tmp_dir}/nvim/site/pack/vendor/start"
packpath="${tmp_dir}/nvim/site"
usage() {
- echo "Usage $0"
+ echo "Usage $0"
}
if [ "${1:-}" = "reset" ]; then
- rm -rf "${tmp_dir}"
+ rm -rf "${tmp_dir}"
fi
download_plugin() {
- repo="https://github.com/${1}/${2}"
- folder="${tmp_rtp}/${2}"
- if [ "${1:-}" = "reset" ]; then
- rm -rf "${folder}"
- fi
- if [ ! -d "$folder" ]; then
- printf "Downloading %s into %s..." "${repo}" "${folder}"
- git clone --depth 1 "${repo}" "${folder}"
- else
- echo "Updating '${repo}' in ${folder}..."
- git -C "${folder}" pull --rebase
- fi
+ repo="https://github.com/${1}/${2}"
+ folder="${tmp_rtp}/${2}"
+ if [ "${1:-}" = "reset" ]; then
+ rm -rf "${folder}"
+ fi
+ if [ ! -d "$folder" ]; then
+ printf "Downloading %s into %s..." "${repo}" "${folder}"
+ git clone --depth 1 "${repo}" "${folder}"
+ else
+ echo "Updating '${repo}' in ${folder}..."
+ git -C "${folder}" pull --rebase
+ fi
}
mkdir -p "$tmp_rtp"
# if exists, link to local folder so we can test local changes
if [ -d "${plug_dir}" ]; then
- echo "Using local plugin ${plug_name} from '${plug_dir}'"
- ln -fs "${plug_dir}" "${tmp_rtp}"
+ echo "Using local plugin ${plug_name} from '${plug_dir}'"
+ ln -fs "${plug_dir}" "${tmp_rtp}"
else
- download_plugin "mikesmithgh" "$plug_name"
+ download_plugin "mikesmithgh" "$plug_name"
fi
tmp_plug_dir="${tmp_rtp}/${plug_name}"
-# write kitty keymappings
-HOME=${TEMPDIR} PACKPATH=${packpath} ${nvim_bin} --clean -n -u "${tmp_plug_dir}/scripts/init.lua" +KittyScrollbackGenerateKittens -c "write! ${tmp_dir}/kitty-map.conf" -c "silent! edit ${tmp_dir}/kitty-map.conf" +quit!
-
printf "\n\t\033[38;2;167;192;128mctrl-c to quit\033[0m\n"
# run kitty
-kitty --config="${tmp_rtp}/${plug_name}/scripts/kitty.conf" --config="${tmp_dir}/kitty-map.conf" \
- --override "action_alias=kitty_scrollback_nvim kitten ${tmp_plug_dir}/python/kitty_scrollback_nvim.py --config-file ${tmp_dir}/mini_config.lua --cwd ${tmp_plug_dir}/lua/kitty-scrollback/configs --env HOME=${TEMPDIR} --env PACKPATH=${packpath} --nvim-args -u ${tmp_plug_dir}/scripts/init.lua" \
- kitten @ launch --cwd="${tmp_dir}" --hold printf "\n\t \033[0m\033[38;2;167;192;128mkitty-scrollback.nvim\033[0m \033[38;2;150;140;129mmini.sh \033[0m\n\t\033[38;2;150;140;129mπ½βββββββββββββββββββββββββββββββββββββββββββββββπΎ\033[0m\033[38;2;150;140;129m\n\t\033[38;2;150;140;129mβ\033[0m\033[38;2;167;192;128mctrl+shift+h\033[0m \033[38;2;150;140;129mscrollback buffer β\033[0m\n\t\033[38;2;150;140;129mβ\033[0m\033[38;2;167;192;128mctrl+shift+g \033[0m \033[38;2;150;140;129mlast command ouput β\033[0m\n\t\033[38;2;150;140;129mβ\033[0m\033[38;2;167;192;128mctrl+shift+right-click\033[0m \033[38;2;150;140;129mselected command outputβ\033[0m\n\t\033[38;2;150;140;129mπΌβββββββββββββββββββββββββββββββββββββββββββββββπΏ\033[0m\n"
-
+kitty --config="${tmp_rtp}/${plug_name}/scripts/kitty.conf" \
+ --override "action_alias=kitty_scrollback_nvim kitten ${tmp_plug_dir}/python/kitty_scrollback_nvim.py --env HOME=${TEMPDIR} --env PACKPATH=${packpath} --nvim-args -u ${tmp_plug_dir}/scripts/init.lua" \
+ --override "map ctrl+shift+h kitty_scrollback_nvim" \
+ --override "map ctrl+shift+g kitty_scrollback_nvim --config last_cmd_output" \
+ --override "mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config last_visited_cmd_output" \
+ kitten @ launch --cwd="${tmp_dir}" --hold printf "\n\t \033[0m\033[38;2;167;192;128mkitty-scrollback.nvim\033[0m \033[38;2;150;140;129mmini.sh \033[0m\n\t\033[38;2;150;140;129mπ½βββββββββββββββββββββββββββββββββββββββββββββββπΎ\033[0m\033[38;2;150;140;129m\n\t\033[38;2;150;140;129mβ\033[0m\033[38;2;167;192;128mctrl+shift+h\033[0m \033[38;2;150;140;129mscrollback buffer β\033[0m\n\t\033[38;2;150;140;129mβ\033[0m\033[38;2;167;192;128mctrl+shift+g \033[0m \033[38;2;150;140;129mlast command ouput β\033[0m\n\t\033[38;2;150;140;129mβ\033[0m\033[38;2;167;192;128mctrl+shift+right-click\033[0m \033[38;2;150;140;129mselected command outputβ\033[0m\n\t\033[38;2;150;140;129mπΌβββββββββββββββββββββββββββββββββββββββββββββββπΏ\033[0m\n"
-printf "\n\tmini.sh was copied and modified from fzf-lua, https://github.com/ibhagwan/fzf-lua\n\t%s \033[0;31mβ₯\033[0m fzf-lua\n\n" "$plug_name"
+printf "\n\tmini.sh was copied and modified from fzf-lua, https://github.com/ibhagwan/fzf-lua\n\t%s \033[0;31mβ₯\033[0m fzf-lua\n\n" "$plug_name"