Giter VIP home page Giter VIP logo

kitty-scrollback.nvim's Introduction

kitty-scrollback

๐Ÿ˜ฝ kitty-scrollback.nvim

Navigate your Kitty scrollback buffer to quickly search, copy, and execute commands in Neovim.

neovim: v0.9+ kitty v0.29+ semantic-release: angular test status nightly test status

kitty-scrollback.nvim demo
(click for video)

๐Ÿ“– Contents

โœจ Features

Tip

Expand each section under the Features section to see a demo.

Check out the wiki for detailed demos of each configuration option, useful configurations, and more.

๐Ÿ˜ป Navigate Kitty's scrollback buffer with Neovim
  • Open Kitty's scrollback history (default mapping <C-S-h>)
  • That's it! You are in Neovim, navigate the scrollback buffer.
๐Ÿฑ Copy scrollback contents to system clipboard

copy_visual_selection_to_clipboard

  • Open Kitty's scrollback history (default mapping <C-S-h>)
  • Search backward for a pattern in Neovim ?{pattern}<CR>
  • Enter Visual mode v and select desired text
  • Copy selection to clipboard (default mapping <leader>y)
  • kitty-scrollback.nvim automatically closes
๐Ÿ˜บ Paste visual selection to Kitty

kitty_scrollback_screencapture_03_should_paste_visual_selection_to_kitty.gif

  • Open Kitty's scrollback history (default mapping <C-S-h>)
  • Search backward for a pattern in Neovim ?{pattern}<CR>
  • Enter Visual mode v and select desired text
  • Paste visual selection to Kitty (default mapping <S-CR>)
  • kitty-scrollback.nvim automatically closes and pastes the contents for further editing
๐Ÿ™€ Execute visual selection in Kitty

kitty_scrollback_screencapture_05_should_execute_visual_selection_in_kitty.mov

  • Open Kitty's scrollback history (default mapping <C-S-h>)
  • Search backward for a pattern in Neovim ?{pattern}<CR>
  • Enter Visual mode v and select desired text
  • Execute visual selection in Kitty (default mapping <C-CR>)
  • kitty-scrollback.nvim automatically closes and executes the visual selection
๐Ÿ˜ธ Modify and send content from paste window to Kitty

kitty_scrollback_screencapture_02_should_paste_paste_window_text_to_kitty.gif

  • Open Kitty's scrollback history (default mapping <C-S-h>)
  • Search backward for a pattern in Neovim ?{pattern}<CR>
  • Enter Visual mode v and select desired text
  • Copy selection to the paste window in kitty-scrollback.nvim for further edits
    • Alternatively, you could just enter Insert mode (i or a) to open an empty floating window (similar to <C-x><C-e> in Bash)
  • Modify the content in the paste window
  • Paste the content of the paste window to Kitty (default mapping <S-CR>)
  • kitty-scrollback.nvim automatically closes and pastes the contents for further editing
๐Ÿ˜ผ Modify and execute content from paste window to Kitty

kitty_scrollback_screencapture_04_should_execute_paste_window_text_in_kitty.gif

  • Open Kitty's scrollback history (default mapping <C-S-h>)
  • Search backward for a pattern in Neovim ?{pattern}<CR>
  • Enter Visual mode v and select desired text
  • Copy selection to the paste window in kitty-scrollback.nvim for further edits
    • Alternatively, you could just enter Insert mode (i or a) to open an empty floating window (similar to <C-x><C-e> in Bash)
  • Modify the content in the paste window
  • Execute the content of the paste window in Kitty (default mapping <C-CR>)
  • kitty-scrollback.nvim automatically closes and executes the content of the paste window
๐Ÿ˜พ tmux support (๐Ÿงช experimental )
  • Open a tmux pane's scrollback history (default mapping <C-b>[)
  • That's it! You are in Neovim, navigate the scrollback buffer.

๐Ÿš€ Migrating to v4.0.0

Important

v4.0.0 has breaking changes and requires steps to properly migrate from v3.X.X.

You can ignore this section if you have not previously installed any version of kitty-scrollback.nvim

Migration Steps

If you have any problems or questions migrating to v4.0.0, please open an issue or discussion.

sad-kitty-thumps-up
  • Previously, kitty-scrollback.nvim did not open Neovim with your Neovim configuration by default. This has changed to loading your Neovim configuration by default, with the ability to opt out. If you prefer to continue not loading your Neovim configuration, then follow the steps at No Configuration.
  • If you previously used the flag --no-nvim-args, then delete it from your configuration because it no longer has any effect. The flag --nvim-args remains unchanged and can still be used.
  • ksb_example configurations have been removed and can no longer be referenced by name. If you were previously referencing an example configuration by name, then you can manually copy it from ./tests/example.lua into your kitty-scrollback.nvim configuration. See Plugin Configuration for detailed instructions on configuration kitty-scrollback.nvim.
  • The command KittyScrollbackGenerateKittens and api generate_kittens no longer have an option to generate ksb_example configurations.
    • The command KittyScrollbackGenerateKittens no longer accepts the bang ! modifier
    • The api generate_kittens signature removed the all parameter
  • The reserved global configuration name has been removed and global options are now configured by the first element of the options table without a key. See Global Configuration for more details.
  • The undocumented reserved default configuration name has been removed. kitty-scrollback.nvim defaults to ksb_builtin_get_text_all if no configuration is provided.

๐Ÿ“š Prerequisites

๐Ÿƒ Quickstart

To quickly test this plugin without changing your configuration run the command:

sh -c "$(curl -s https://raw.githubusercontent.com/mikesmithgh/kitty-scrollback.nvim/main/scripts/mini.sh)"

Note

It is good practice to first read the script before running sh -c directly from the web

๐Ÿ“ฆ Installation

Using lazy.nvim
  {
    'mikesmithgh/kitty-scrollback.nvim',
    enabled = true,
    lazy = true,
    cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth' },
    event = { 'User KittyScrollbackLaunch' },
    -- version = '*', -- latest stable version, may have breaking changes if major version changed
    -- version = '^4.0.0', -- pin major version, include fixes and features that do not have breaking changes
    config = function()
      require('kitty-scrollback').setup()
    end,
  }
Using packer.nvim
  use({
    'mikesmithgh/kitty-scrollback.nvim',
    disable = false,
    opt = true,
    cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth' },
    event = { 'User KittyScrollbackLaunch' },
    -- tag = '*', -- latest stable version, may have breaking changes if major version changed
    -- tag = 'v4.0.0', -- pin specific tag
    config = function()
      require('kitty-scrollback').setup()
    end,
  })
Using Neovim's built-in package support pack
mkdir -p "$HOME/.local/share/nvim/site/pack/mikesmithgh/start/"
cd $HOME/.local/share/nvim/site/pack/mikesmithgh/start
git clone [email protected]:mikesmithgh/kitty-scrollback.nvim.git
nvim -u NONE -c "helptags kitty-scrollback.nvim/doc" -c q
mkdir -p "$HOME/.config/nvim"
echo "require('kitty-scrollback').setup()" >> "$HOME/.config/nvim/init.lua"

๐Ÿ› ๏ธ Setup

This section outlines the required configuration for kitty-scrollback.nvim.

  • Enable allow_remote_control in kitty.conf

    • Valid values are yes, socket, socket-only
    • If kitty-scrollback.nvim is the only application controlling Kitty then socket-only is preferred to continue denying TTY requests.
  • Set listen_on to a Unix socket in kitty.conf

    • For example, listen_on unix:/tmp/kitty
  • Enable shell_integration in kitty.conf

    • Set shell_integration to enabled
    • Do not add the option no-prompt-mark
  • Generate the default kitty-scrollback.nvim Kitten mappings and add them to kitty.conf

    nvim --headless +'KittyScrollbackGenerateKittens'
  • Completely close and reopen Kitty

  • Check the health of kitty-scrollback.nvim

    nvim +'KittyScrollbackCheckHealth'
    • Follow the instructions of any ERROR or WARNINGS reported during the healthcheck
  • Test kitty-scrollback.nvim is working as expected by pressing kitty_mod+h to open the scrollback history in Neovim

    • kitty_mod is a special modifier key alias for default shortcuts. You can change the value of this option to alter all default shortcuts that use kitty_mod. The default value of kitty_mod is ctrl+shift. In this example, kitty_mod+h represents ctrl+shift+h.
  • See example kitty.conf for reference.

    allow_remote_control yes
    listen_on unix:/tmp/kitty
    shell_integration enabled
    
    # kitty-scrollback.nvim Kitten alias
    action_alias kitty_scrollback_nvim kitten /path/to/your/install/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py
    
    # Browse scrollback buffer in nvim
    map kitty_mod+h kitty_scrollback_nvim
    # Browse output of the last shell command in nvim
    map kitty_mod+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 ksb_builtin_last_visited_cmd_output

โš™๏ธ Configuration

This section provides details on how to customize your kitty-scrollback.nvim configuration.

Kitten Arguments

Arguments that can be passed to the kitty_scrollback_nvim Kitten defined in kitty.conf. You can provide the arguments to the action_alias kitty_scrollback_nvim or each individual mapping referencing kitty_scrollback_nvim.

The following examples show you how you could reference a kitty-scrollback.nvim user configuration by name (.e.g, myconfig), set the environment variable NVIM_APPNAME for Neovim, and pass the argument -n to Neovim to disable swap files.

  • Example of adding arguments to action_alias in kitty.conf.

    • This will apply the arguments to all the mappings of kitty_scrollback_nvim.
    action_alias kitty_scrollback_nvim kitten /path/to/your/install/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --env NVIM_APPNAME=mynvim --config myconfig --nvim-args -n
    
  • Example of adding arguments to a map in kitty.conf.

    • This will apply the arguments only to the kitty_mod+h mappings of kitty_scrollback_nvim.
    map kitty_mod+h kitty_scrollback_nvim --env NVIM_APPNAME=mynvim --config myconfig --nvim-args -n
    
Argument Description
--config The name of the kitty-scrollback.nvim plugin configuration. The configuration can be defined during plugin setup (i.e., require('kitty-scrollback').setup({ ... })).
--nvim-args All arguments after this flag are passed to Neovim. This must be the last of the kitty_scrollback_nvim Kitten arguments. Otherwise, you may unintentionally send the wrong arguments to Neovim.
--env Environment variable that is passed to Neovim. Format is --env var_name=var_value. You may specify multiple config files that will merge all configuration options. Useful for setting NVIM_APPNAME.
--cwd The current working directory of the Neovim

Plugin Configuration

kitty-scrollback.nvim is configured using the require('kitty-scrollback').setup() function. setup() accepts an options table in the form of table<string, KsbOpts|fun(KsbKittyData):KsbOpts>. The structure of KsbOpts is defined in lua/kitty-scrollback/configs/defaults.lua.

The key for an entry in the options table is the name of a configuration that you wish to define. The key can be referenced as the name of the configuration that is passed to the Kitten argument --config. For example, with a configuration named myconfig that disables ANSI colors:

require('kitty-scrollback').setup({
    myconfig = {
      kitty_get_text = {
        ansi = false,
      },
    }
})

You can reference this specific configuration as follows in kitty.conf to disable ANSI colors for the kitty_mod+h mapping.

map kitty_mod+h kitty_scrollback_nvim --config myconfig

The value of an entry in the options table can either be a table (KsbOpts) or a function (fun(KsbKittyData):KsbOpts). KsbKittyData contains metadata about Kitty and the scrollback buffer that may be useful when defining a configuration. The structure of KsbKittyData is defined in lua/kitty-scrollback/launch.lua. For example, you could add an additional configuration named myfnconfig ๐Ÿ˜‚ that only loads the entire scrollback history if the user scrolled past the number of lines on the screen.

require('kitty-scrollback').setup({
    myconfig = {
      kitty_get_text = {
        ansi = false,
      },
    },
    myfnconfig = function(kitty_data)
      return {
        kitty_get_text = {
          extent = (kitty_data.scrolled_by > kitty_data.lines) and 'all' or 'screen',
        },
      }
    end,
})

If you update the reference in kitty.conf to myfnconfig then the kitty_mod+h mapping will use the configuration returned by the function defined by myfnconfig.

map kitty_mod+h kitty_scrollback_nvim --config myfnconfig

Overriding Builtin Configurations

The key for an entry in the options table can be any string. However, if the key matches a builtin name (prefixed with ksb_builtin_) then the configuration will be merged with the builtin configuration. All of the builtin configurations are defined in lua/kitty-scrollback/configs/builtin.lua. The user defined configuration will take precedence and override any fields that are defined in both the builtin and user defined configuration.

Having the ability to merge a user defined configuration with the builtin in configuration is useful for scenarios that you wish to keep the default kitten mappings generated by the :KittyScrollbackGenerateKittens command.

For example, imagine a scenario where you wish to modify the configuration for the ksb_builtin_get_text_all but do not wish to provide you own configuration name myconfig and have to update the reference in kitty.conf to map kitty_mod+h kitty_scrollback_nvim --config myconfig. In this scenario, the default mapping is defined in kitty.conf as

map kitty_mod+h kitty_scrollback_nvim

Note

When no explicit configuration is passed to kitty_scrollback_nvim, the config ksb_builtin_get_text_all is used. Effectively, the command becomes map kitty_mod+h kitty_scrollback_nvim --config ksb_builtin_get_text_all

You can achieve this by creating a user defined configuration with the key ksb_builtin_get_text_all as follows.

  ksb_builtin_get_text_all = {
    kitty_get_text = {
      ansi = false,
    },
  }

The builtin configuration for ksb_builtin_get_text_all is

  ksb_builtin_get_text_all = {
    kitty_get_text = {
      extent = 'all',
    },
  },

The user and builtin configurations will be merged resulting in

  ksb_builtin_get_text_all = {
    kitty_get_text = {
      ansi = false,
      extent = 'all',
    },
  },

This approach can be used to modify the builtin configuration (e.g., ksb_builtin_get_text_all, ksb_builtin_last_cmd_output, and ksb_builtin_last_visited_cmd_output). But, if you have a common configuration that you wish to have applied to all of configurations, then it is better to use a global configuration.

Global Configuration

So far, all entries in the options table have been in the form a key/value pair where the key is a string representing the name of the configuration. There is an additional reserved entry for the global configuration which is the first element of the options table without a key (technically the key is 1 but it does not have to be defined).

If you would like to provide a global configuration to automatically hide the status window, this can be achieved as follows. Notice the first entry in the options table does not define a key, this will be considered global options and applied to all builtin and user defined configurations.

require('kitty-scrollback').setup({
    -- global configuration
    {
      status_window = {
        autoclose = true,
      },
    },
    -- builtin configuration override
    ksb_builtin_get_text_all = {
      kitty_get_text = {
        ansi = false,
      },
    },
    -- user defined configuration table
    myconfig = {
      kitty_get_text = {
        ansi = false,
      },
    },
    -- user defined configuration function
    myfnconfig = function(kitty_data)
      return {
        kitty_get_text = {
          extent = (kitty_data.scrolled_by > kitty_data.lines) and 'all' or 'screen',
        },
      }
    end,
})

Configuration Precedence

The configuration precedence is default > global > builtin > user where default has the lowest and user has the highest precedence.

Type Description
default Standard options defined by kitty-scrollback.nvim and can be found in the file lua/kitty-scrollback/configs/defaults.lua.
global Global options that apply to all builtin and user defined configurations. The first element in the options table without a key is considered the global options.
builtin Options defined by kitty-scrollback.nvim for each kitty_scrollback_nvim kitten command generated by :KittyScrollbackGenerateKittens (e.g., ksb_builtin_get_text_all, ksb_builtin_last_cmd_output, and ksb_builtin_last_visited_cmd_output). The builtin options can be found in the file lua/kitty-scrollback/configs/builtin.lua.
user Options defined by the user in the options table with a string name that is referenced in kitty.conf using the --config flag when defining a mapping for the kitty_scrollback_nvim kitten (e.g., map kitty_mod+h kitty_scrollback_nvim --config myconfig). User defined options can be any string and will merge with builtin options if they share the same key such as ksb_builtin_get_text_all.

Configuration Options

{
  -- KsbCallbacks? fire and forget callback functions
  callbacks = {
    -- fun(kitty_data: KsbKittyData, opts: KsbOpts)? callback executed after initializing kitty-scrollback.nvim
    after_setup = nil,
    -- fun(kitty_data: KsbKittyData, opts: KsbOpts)? callback executed after launch started to process the scrollback buffer
    after_launch = nil,
    -- fun(kitty_data: KsbKittyData, opts: KsbOpts)?  callback executed after scrollback buffer is loaded and cursor is positioned
    after_ready = nil,
    -- fun(paste_window_data: KsbPasteWindowData, kitty_data: KsbKittyData, opts: KsbOpts)? callback executed after the paste window is opened or resized
    after_paste_window_ready = nil,
  },
  -- boolean? if true, enabled all default keymaps
  keymaps_enabled = true,
  -- boolean? if true, restore options that were modified while processing the scrollback buffer
  restore_options = false,
  -- KsbHighlights? highlight overrides
  highlight_overrides = {
    -- table? status window Normal highlight group
    KittyScrollbackNvimStatusWinNormal = {},
    -- table? status window heart icon highlight group
    KittyScrollbackNvimStatusWinHeartIcon = {},
    -- table? status window spinner icon highlight group 
    KittyScrollbackNvimStatusWinSpinnerIcon = {},
    -- table? status window ready icon highlight group
    KittyScrollbackNvimStatusWinReadyIcon = {},
    -- table? status window kitty icon highlight group
    KittyScrollbackNvimStatusWinKittyIcon = {},
    -- table? status window vim icon highlight group
    KittyScrollbackNvimStatusWinNvimIcon = {},
    -- table? paste window Normal highlight group
    KittyScrollbackNvimPasteWinNormal = {},
    -- table? paste window FloatBorder highlight group
    KittyScrollbackNvimPasteWinFloatBorder = {},
    -- table? paste window FloatTitle highlight group
    KittyScrollbackNvimPasteWinFloatTitle = {},
    -- table? scrollback buffer window Visual selection highlight group
    KittyScrollbackNvimVisual = {},
    -- table? scrollback buffer window Normal highlight group
    KittyScrollbackNvimNormal = {},
  },
  -- KsbStatusWindowOpts? options for status window indicating that kitty-scrollback.nvim is ready
  status_window = {
    -- boolean If true, show status window in upper right corner of the screen
    enabled = true,
    -- boolean If true, use plaintext instead of nerd font icons
    style_simple = false,
    -- boolean If true, close the status window after kitty-scrollback.nvim is ready
    autoclose = false,
    -- boolean If true, show a timer in the status window while kitty-scrollback.nvim is loading
    show_timer = false,
    -- KsbStatusWindowIcons? Icons displayed in the status window
    icons = {
      -- string kitty status window icon
      kitty = '๓ฐ„›',
      -- string heart string heart status window icon
      heart = '๓ฐฃ', -- variants ๓ฐฃ | ๏€„ | ๎ฌ… | โ™ฅ | ๏‚Š | ๓ฑข  | ๏“ก
      -- string nvim status window icon
      nvim = '๎šฎ', -- variants ๎šฎ | ๏ฏ | ๎˜ซ | ๎Ÿ…
    },
  },

  -- KsbPasteWindowOpts? options for paste window that sends commands to Kitty
  paste_window = {
    --- BoolOrFn? If true, use Normal highlight group. If false, use NormalFloat
    highlight_as_normal_win = nil,
    -- string? The filetype of the paste window
    filetype = nil,
    -- boolean? If true, hide mappings in the footer when the paste window is initially opened
    hide_footer = false,
    -- integer? The winblend setting of the window, see :help winblend
    winblend = 0,
    -- KsbWinOptsOverride? Paste float window overrides, see nvim_open_win() for configuration
    winopts_overrides = nil,
    -- KsbFooterWinOptsOverride? Paste footer window overrides, see nvim_open_win() for configuration
    footer_winopts_overrides = nil,
    -- string? register used during yanks to paste window, see :h registers
    yank_register = '',
    -- boolean? If true, the yank_register copies content to the paste window. If false, disable yank to paste window
    yank_register_enabled = true,
  },

  -- KsbKittyGetText? options passed to get-text when reading scrollback buffer, see kitty @ get-text --help
  kitty_get_text = {
    -- boolean If true, the text will include the ANSI formatting escape codes for colors, bold, italic, etc.
    ansi = true,
    -- string What text to get. The default of screen means all text currently on the screen. all means all the screen+scrollback and selection means the currently selected text. first_cmd_output_on_screen means the output of the first command that was run in the window on screen. last_cmd_output means the output of the last command that was run in the window. last_visited_cmd_output means the first command output below the last scrolled position via scroll_to_prompt. last_non_empty_output is the output from the last command run in the window that had some non empty output. The last four require shell_integration to be enabled. Choices: screen, all, first_cmd_output_on_screen, last_cmd_output, last_non_empty_output, last_visited_cmd_output, selection
    extent = 'all',
    -- boolean If true, clear the selection in the matched window, if any.
    clear_selection = true,
  },
  -- boolean? if true execute :checkhealth kitty-scrollback and skip setup
  checkhealth = false,
  -- string? Sets the mode for coloring the Visual highlight group in the scrollback buffer window. darken uses a darkened version of the Normal highlight group to improve readability. kitty uses the colors defined for selection_foreground and selection_background in your Kitty configuration. nvim uses the default colors defined in the Visual highlight group. reverse reverses the foreground and background colors of the visual selection.
  visual_selection_highlight_mode = 'darken',
}

Nerd Fonts

By default, kitty-scrollback.nvim uses Nerd Fonts 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 v3.1.0+ opts.status_window.icons.nvim = '๎šฎ' opts.status_window.style_simple = false
status-win-icon-nvim
  • Status window with Nerd Fonts < v3.1.0 opts.status_window.icons.nvim = '๎˜ซ' opts.status_window.style_simple = false
status-win-icon-vim
  • Status window with ASCII text opts.status_window.style_simple = true
status-win-icon-simple

Separate Neovim Configuration

By default, kitty-scrollback.nvim uses your default Neovim configuration. The benefit of this, is that all of your commands, keymaps, and plugins are available to use. However, depending on your setup, having all of your configuration load may be overkill and slow the start time of kitty-scrollback.nvim. There are a couple approaches that can be taken to separate kitty-scrollback.nvim's Neovim configuration from the default Neovim configuration.

No Configuration

If you prefer not to load any Neovim configuration, the arguments --nvim-args --clean --noplugin -n are recommended to be passed to the kitty_scrollback_nvim kitten

Details on these flags can be found by running the command :help startup-options.

--clean     Mimics a fresh install of Nvim.
--noplugin  Skip loading plugins.  
-n          No swap-file will be used.  

To provide this configuration to kitty-scrollback.nvim, pass the --nvim-args flag to the kitty_scrollback_nvim kitten defined in kitty.conf. See Kitten Arguments for more details on configuration the kitty_scrollback_nvim kitten. The following is an example of what the configuration should look like in your kitty.conf.

action_alias kitty_scrollback_nvim kitten /path/to/your/install/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --nvim-args --clean --noplugin -n

User Configuration

If you prefer to load only a few simple configurations, creating a minimal vimrc (.e.g, init.lua or init.vim) and passing the -u argument to the kitty_scrollback_nvim kitten is recommended.

First, start off by creating your vimrc file. In this example, I will create the file kitty-scrollback-nvim-kitten-config.lua at /path/to/your/config/ with the contents:

-- kitty-scrollback-nvim-kitten-config.lua

-- put your general Neovim configurations here
vim.g.mapleader = ' '
vim.g.maplocalleader = ','

vim.keymap.set({ 'n' }, '<C-e>', '5<C-e>', {})
vim.keymap.set({ 'n' }, '<C-y>', '5<C-y>', {})

-- add kitty-scrollback.nvim to the runtimepath to allow us to require the kitty-scrollback module
-- pick a runtimepath that corresponds with your package manager, if you are not sure leave them all it will not cause any issues
vim.opt.runtimepath:append(vim.fn.stdpath('data') .. '/lazy/kitty-scrollback.nvim') -- lazy.nvim
vim.opt.runtimepath:append(vim.fn.stdpath('data') .. '/site/pack/packer/opt/kitty-scrollback.nvim') -- packer
vim.opt.runtimepath:append(vim.fn.stdpath('data') .. '/site/pack/mikesmithgh/start/kitty-scrollback.nvim') -- pack
require('kitty-scrollback').setup({
  -- put your kitty-scrollback.nvim configurations here
})

In this example, I added a few keymaps before calling require('kitty-scrollback').setup(). You can add your desired configuration, the important part of this configuration are the lines related to runtimepath. Pick the line that corresponds to your package manager, if you are not sure it is safe to leave all the lines. If you have a custom or unique installation of kitty-scrollback.nvim, update the runtimepath to append that location so that Neovim can find the module when calling require('kitty-scrollback').

If you would like to confirm that the runtimepath in kitty-scrollback-nvim-kitten-config.lua is correct, run the following command.

nvim -u /path/to/your/config/kitty-scrollback-nvim-kitten-config.lua

If Neovim opens without any errors, then the runtimepath is configured correctly. If there are errors, you may need to manually find your kitty-scrollback.nvim and append that directory to runtimepath in kitty-scrollback-nvim-kitten-config.lua

Second, after your vimrc file is created (e.g., kitty-scrollback-nvim-kitten-config.lua), pass the file to Neovim using the -u flag in kitty.conf. The following is an example of what the configuration should look like in your kitty.conf.

action_alias kitty_scrollback_nvim kitten /path/to/your/install/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --nvim-args -u /path/to/your/config/kitty-scrollback-nvim-kitten-config.lua

Use KITTY_SCROLLBACK_NVIM Environment Variable

If you want to use your default Neovim configuration but only have a few minors differences, then using the environment variable KITTY_SCROLLBACK_NVIM is recommended. See the Environment Variables section for an example of how this can be used.

NVIM_APPNAME With Separate Configuration

If you prefer to have a completely separate Neovim configuration for kitty-scrollback.nvim, then using the environment variable NVIM_APPNAME is recommended.

First, start off by creating your Neovim configuration directory. In this example, I will create the directory ~/.config/ksb-nvim and add the file init.lua with the contents:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath, })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  "mikesmithgh/kitty-scrollback.nvim",
  enabled = true,
  lazy = true,
  cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" },
  event = { "User KittyScrollbackLaunch" },
  config = function()
    require("kitty-scrollback").setup({
      {
        callbacks = {
          after_ready = vim.defer_fn(function()
            vim.fn.confirm(vim.env.NVIM_APPNAME .. " kitty-scrollback.nvim example!")
          end, 1000),
        },
      },
    })
  end,
})

In this example, we have a completely separate Neovim configuration with lazy.nvim as the package manager. kitty-scrollback.nvim is a configured package and has a global configuration to print a message a second after kitty-scrollback.nvim loads.

Second, after your Neovim configuration directory is created (e.g., ~/.config/ksb-nvim), set the environment variable NVIM_APPNAME to your directory in kitty.conf. The following is an example of what the configuration should look like in your kitty.conf.

action_alias kitty_scrollback_nvim kitten /path/to/your/install/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --env NVIM_APPNAME=ksb-nvim

๐Ÿงฌ Environment Variables

The environment variable KITTY_SCROLLBACK_NVIM is set to true while kitty-scrollback.nvim is active.

This can be used to in your Neovim configuration to provide kitty-scrollback.nvim specific behavior that may differ from a regular Neovim instance.

if vim.env.KITTY_SCROLLBACK_NVIM == 'true' then
    -- kitty-scrollback.nvim specific configuration
end

๐Ÿ“„ Filetypes

The scrollback buffer's filetype is set to kitty-scrollback after kitty-scrollback.nvim has finished loading.

This can be used in you Neovim configuration to setup an autocommand to trigger when kitty-scrollback.nvim has finished loading the scrollback buffer.

vim.api.nvim_create_autocmd({ 'FileType' }, {
  group = vim.api.nvim_create_augroup('KittyScrollbackNvimFileType', { clear = true }),
  pattern = { 'kitty-scrollback' },
  callback = function()
    -- add your logic here
    vim.print('kitty-scrollback.nvim is open!')
    return true
  end,
})

The approach of using the filetype autocommand is similar to using the option callbacks.after_ready. One key differences, is that the callback receives metadata about kitty as an argument. The following example is similar to the autocommand and is a just a matter of user preference.

require('kitty-scrollback').setup({
  {
    callbacks = {
      after_ready = function(kitty_data)
        vim.print(kitty_data)
      end,
    },
  },
})

๐Ÿซก Commands

The API is available via the kitty-scrollback.api module. e.g., require('kitty-scrollback.api')

Command API Description
:KittyScrollbackGenerateKittens [generate_modes] generate_kittens(table<string|'commands'|'maps'>)? Generate Kitten commands used as reference for configuring kitty.conf
:KittyScrollbackCheckHealth checkhealth() Run :checkhealth kitty-scrollback in the context of Kitty

โŒจ๏ธ Keymaps

The API is available via the kitty-scrollback.api module. e.g., require('kitty-scrollback.api')

<Plug> Mapping Default Mapping Mode API Description
<Plug>(KsbExecuteCmd) <C-CR> n,i execute_command() Execute the contents of the paste window in Kitty
<Plug>(KsbPasteCmd) <S-CR> n,i paste_command() Paste the contents of the paste window to Kitty without executing
<Plug>(KsbExecuteVisualCmd) <C-CR> v execute_visual_command() Execute the contents of visual selection in Kitty
<Plug>(KsbPasteVisualCmd) <S-CR> v paste_visual_command() Paste the contents of visual selection to Kitty without executing
<Plug>(KsbToggleFooter) g? n toggle_footer() Toggle the paste window footer that displays mappings
<Plug>(KsbCloseOrQuitAll) <Esc> n close_or_quit_all() If the current buffer is the paste buffer, then close the window. Otherwise quit Neovim
<Plug>(KsbQuitAll) <C-c> n,i,t quit_all() Quit Neovim
<Plug>(KsbVisualYankLine) <Leader>Y v Maps to "+Y
<Plug>(KsbVisualYank) <Leader>y v Maps to "+y
<Plug>(KsbNormalYankEnd) <Leader>Y n Maps to "+y$
<Plug>(KsbNormalYank) <Leader>y n Maps to "+y
<Plug>(KsbNormalYankLine) <Leader>yy n Maps to "+yy

๐Ÿช› Optional Setup

tmux (๐Ÿงช experimental )

Warning

๐Ÿงช tmux support is currently experimental If you have questions or encounter any issues using tmux, please comment on #115

Setup instructions to integrate kitty-scrollback.nvim with tmux. These steps are optional and only necessary if you wish to add tmux support to kitty-scrollback.nvim.

  • Generate the tmux kitty-scrollback.nvim mappings and add them to $HOME/.tmux.conf or $XDG_CONFIG_HOME/tmux/tmux.conf
nvim --headless +'KittyScrollbackGenerateKittens tmux'
  • You may need to source your tmux configuration for these changes to be reflected in a current tmux session.
tmux source $HOME/.tmux.conf 
# or 
tmux source $XDG_CONFIG_HOME/tmux/tmux.conf
  • By default, kitty-scrollback.nvim overrides the default key binding [ for opening copy-mode. If you use the default prefix key <C-b> and the default key binding [, then test opening a tmux's pane scrollback history with kitty-scrollback.nvim by pressing <C-b>[.

    • You can still access Kitty's scrollback history (default mapping <C-S-h>) in a tmux session. However, this is scoped to Kitty and it will only show the current screen. When you open the tmux pane's scrollback history (default mapping <C-b>[), this is scoped to tmux and will display all of the scrollback history for that tmux session.
  • See example .tmux.conf for reference.

# Browse tmux pane in nvim
bind [ run-shell 'kitty @ kitten /path/to/your/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --env "TMUX=$TMUX" --env "TMUX_PANE=#{pane_id}"'

๐Ÿ‘ Recommendations

Developing kitty-scrollback.nvim NeovimConf 2023

  • The following plugins are nice additions to your Neovim and Kitty setup.
    • vim-kitty - Syntax highlighting for Kitty terminal config files
    • smart-splits.nvim - Seamless navigation between Neovim and Kitty split panes

๐Ÿค Acknowledgements

๐Ÿถ Alternatives

scared cat

kitty-scrollback.nvim's People

Contributors

github-actions[bot] avatar gutenye avatar jackielii avatar mikesmithgh avatar ofseed avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kitty-scrollback.nvim's Issues

Nushell compatibility

Having your default shell set to nu causes issues due to the use of && in kitty_commands.lua. Could those be replaced with ; (my workaround) or the full_cmd be wrapped in echo "..." | sh? Or is there a more elegant solution for letting commands be interpreted by dash?

feat: add tmux support

tmux support

Important

๐Ÿงช tmux support is currently experimental
This issue is used to track all tmux related issues or questions. Please comment on this issue instead of created a new issue while tmux support is considered experimental.

The following checklist is planned to be completed before moving these feature to stable.

  • add tests checking env var and kitty_data.tmux
  • add multipane test
  • check positioning of paste window
    • status line impacts this, look into tmux set-option status on tmux set-option status 3 etc . check with tmux show-options status
    • adjust cursor pos for split panes (tmux display-message -p '#{cursor_x} #{cursor_y} #{pane_width} #{pane_height} #{window_visible_layout}')
    • idea, check if zoomed, if not toggle zoom before hand. tmux resize-pane -Z need to figure out command to check if already zoomed ( try #{window_zoomed_flag} )
  • check positioning for scrolled window
  • add command to generate config
  • copy to clipboard, add/modify option to copy to tmux buffer with set-buffer command
  • look into history-limit configuration and document preferred settings
  • doc differences between tmux copy mode, e.g., one pane full screen instead of split panes
  • if get-extent all, -S - -E -, if screen remove -S and -E options. see tmux capture-pane help
  • review all options in capture-pane https://man7.org/linux/man-pages/man1/tmux.1.html
       capture-pane [-aAepPqCJN] [-b buffer-name] [-E end-line] [-S
               start-line] [-t target-pane]
                     (alias: capturep)
               Capture the contents of a pane.  If -p is given, the
               output goes to stdout, otherwise to the buffer specified
               with -b or a new buffer if omitted.  If -a is given, the
               alternate screen is used, and the history is not
               accessible.  If no alternate screen exists, an error will
               be returned unless -q is given.  If -e is given, the
               output includes escape sequences for text and background
               attributes.  -C also escapes non-printable characters as
               octal \xxx.  -T ignores trailing positions that do not
               contain a character.  -N preserves trailing spaces at
               each line's end and -J preserves trailing spaces and
               joins any wrapped lines; -J implies -T.  -P captures only
               any output that the pane has received that is the
               beginning of an as-yet incomplete escape sequence.

               -S and -E specify the starting and ending line numbers,
               zero is the first line of the visible pane and negative
               numbers are lines in the history.  โ€˜-โ€™ to -S is the start
               of the history and to -E the end of the visible pane.
               The default is to capture only the visible contents of
               the pane.
  • doc required tmux version
  • nice to have? maybe? add tmux nerd font icon to status when in tmux mode
  • doc doesn't work over ssh
  • investigate if tmux_capture_last_command_output or alternatives are a viable option for getting the last command output. or create a follow up issue for this

This issue has been modified. See details on the original issue below.

Original issue below

Hello,
First of all, I wanted to express my admiration for your plugin, which I had the pleasure of discovering after attending your talk at the nvim conference.

While experimenting with your plugin, I encountered a specific issue related to its compatibility with tmux. It appears that the kitty_get_text.extent setting do not seem to function as expected when used in conjunction with tmux. It has come to my attention that this setting, regardless of the value chosenโ€”be it (all, first_cmd_output_on_screen, last_cmd_output, last_non_empty_output, last_visited_cmd_output, selection), โ€”seems to consistently yield the same result. In essence, it consistently displays only the content visible on the screen, akin to the behavior one would expect when setting the setting to screen.

The root cause of this behavior lies in the fact that the kitty @ get-text command consistently retrieves only the content visible on the current screen. Unfortunately, tmux retains all text within its internal buffer, which remains inaccessible to the kitty scrollback history.

I understand that some of these modes, such as last_visited_cmd_output, are inherently dependent on kitty-specific features that tmux lacks. However, I wonder if there might be a way to at least make the full mode compatible with tmux.

I'd like to offer a couple of suggestions that might help in achieving this compatibility:

  • Detecting tmux: You could consider checking if tmux is running, which can be accomplished by checking if the $TMUX environment variable is set. This step would allow the plugin to identify when it is operating within a tmux session.
  • Accessing the buffer content: To access the buffer content in tmux, the following command could be utilized:

tmux capture-pane -p -S - -E -

The -p flag directs the output to stdout.

The -S and -E options specify the starting and ending line numbers for the capture. For instance, '0' represents the first line of the visible pane, and negative numbers refer to lines in the history. The use of '-' with -S denotes the start of the history, and '-' with -E indicates the end of the visible pane.

While I lack the confidence to submit a pull request myself, I sincerely hope that these suggestions prove useful in enhancing the compatibility of your plugin with tmux. I believe that such compatibility would greatly benefit users like me who rely on both tools in their development workflow.

feat: support dim opacity

printf "%s\033[2;39m%s" "hi" "bye"

SGR (Select Graphic Rendition) parameters (see https://en.wikipedia.org/wiki/ANSI_escape_code)

2 | Faint, decreased intensity,ย orย dim | May be implemented as a lightย font weightย like bold.[39]
2 Faint, decreased intensity, or dim May be implemented as a light font weight like bold.[39]

kitty.conf

# dim_opacity 0.4

#: How much to dim text that has the DIM/FAINT attribute set. One
#: means no dimming and zero means fully dimmed (i.e. invisible).

kitty with default dim_opacity 0.4
Screenshot 2023-11-09 at 3 52 00โ€ฏPM

kitty-scrollback.nvim

Screenshot 2023-11-09 at 3 52 34โ€ฏPM

Determine CSI 2 (faint) color based on kitty.conf dim_opacity, calculate via faint() (See
https://github.com/kovidgoyal/kitty/blob/master/kittens/tui/operations.py#L204).

If too hard to automatically convert, then add documentations and workaround steps.

attempt to call field 'system' (a nil value)

Hello, I'm getting the following error when healthchecking kitty-scrollback from neovim (KittyScrollbackCheckHealth):

kitty-scrollback: require("kitty-scrollback.health").check()

- ERROR Failed to run healthcheck for "kitty-scrollback" plugin. Exception:
  function health#check, line 25
  Vim(eval):E5108: Error executing lua ...pt/kitty-scrollback.nvim/lua/kitty-scrollback/health.lua:246: attempt to call field 'system' (a nil value)
  stack traceback:
  ...pt/kitty-scrollback.nvim/lua/kitty-scrollback/health.lua:246: in function 'check_kitty_scrollback_nvim_version'
  ...pt/kitty-scrollback.nvim/lua/kitty-scrollback/health.lua:280: in function 'check'
  [string "luaeval()"]:1: in main chunk
  [C]: in function 'checkhealth'
  ...r/opt/kitty-scrollback.nvim/lua/kitty-scrollback/api.lua:155: in function ''
  vim/_editor.lua: in function <vim/_editor.lua:0>

I tried to follow the installation steps but can't make it through...

Let me know if you need more info.

Thanks in advance!

bug: module 'kitty-scrollback.launch' not found

followed the instruction to the letter, healthcheck was all good, the kitten, kitty config, etc, all of it was copy pasted from the readme (except for the file paths, which I changed to match mine), pressing ctrl+shift+h runs neovim, but the following error happens

Error detected while processing VimEnter Autocommands for "*":
Error executing lua callback: [string ":lua"]:1: module 'kitty-scrollback.launch' not found:
        no field package.preload['kitty-scrollback.launch']
        no file './kitty-scrollback/launch.lua'
        no file '/usr/share/luajit-2.1/kitty-scrollback/launch.lua'
        no file '/usr/local/share/lua/5.1/kitty-scrollback/launch.lua'
        no file '/usr/local/share/lua/5.1/kitty-scrollback/launch/init.lua'
        no file '/usr/share/lua/5.1/kitty-scrollback/launch.lua'
        no file '/usr/share/lua/5.1/kitty-scrollback/launch/init.lua'
        no file './kitty-scrollback/launch.so'
        no file '/usr/local/lib/lua/5.1/kitty-scrollback/launch.so'
        no file '/usr/lib/lua/5.1/kitty-scrollback/launch.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './kitty-scrollback.so'
        no file '/usr/local/lib/lua/5.1/kitty-scrollback.so'
        no file '/usr/lib/lua/5.1/kitty-scrollback.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        [string ":lua"]:1: in function <[string ":lua"]:1>
Press ENTER or type command to continue

if it's of any difference, I'm using lazy.nvim, distro is garuda linux (arch based) meaning I have all the latest packages
thanks to anyone who takes the time to read this, and I'm sorry if I forgot to add something important

feat: add configs in `setup`

See #12 (comment)

Thanks, that's interesting, I didn't realize that the plugin uses a separate config file. Are there any plans to go with the conventional require("kitty-scrollback").setup(...) configuration method? That'd make configuration a lot easier.

I originally used separate config files because the kitten (written in python) starts Nvim and passes kitty specific info as arguments. I did some experimenting and think I could get the conventional setup method to work and agree it would be cleaner.

require('kitty-scrollback').setup({
  default = function(kitty_data)
    return { ... default config here ... }
  end,
  another = function(kitty_data)
    return { ... another config here ... }
  end,
  ...
})

Then the kitten would be called like kitty.conf

map ctrl+shift+h kitty_scrollback_nvim --config default
map f1 kitty_scrollback_nvim --config another

That way you could centralize all your configs in the setup and then specify the particular config by key. @musjj Does that sound like a good approach to you or do you have any other ideas?

Yes, it would be nice if there's an option to configure this too!

Nice, I'll add an issue for that

attempt to index field 'advice' - On Nix

Error detected while processing VimEnter Autocommands for "*":
Error executing lua callback: ...-scrollback.nvim/lua/kitty-scrollback/kitty_commands.lua:61: attempt to index field 'advice' (a function value)
stack traceback:
        ...-scrollback.nvim/lua/kitty-scrollback/kitty_commands.lua:61: in function 'system_handle_error'
        ...-scrollback.nvim/lua/kitty-scrollback/kitty_commands.lua:158: in function 'get_kitty_colors'
        ...itty-scrollback.nvim/lua/kitty-scrollback/highlights.lua:87: in function 'setup'
        ...zy/kitty-scrollback.nvim/lua/kitty-scrollback/launch.lua:296: in function 'setup'
        ...zy/kitty-scrollback.nvim/lua/kitty-scrollback/launch.lua:457: in function 'setup_and_launch'
        [string ":lua"]:1: in function <[string ":lua"]:1>

I get the following error when trying to use ""
Running check health results in this :


kitty-scrollback: Kitty version 0.29+ ~
- ERROR Failed to run healthcheck for "kitty-scrollback" plugin. Exception:
  ...zy/kitty-scrollback.nvim/lua/kitty-scrollback/health.lua:193: attempt to index upvalue 'p' (a nil value)
  

My config:

# Generated by Home Manager.
# See https://sw.kovidgoyal.net/kitty/conf.html
font_family JetBrainsMono NF
font_size 12

include /nix/store/sl4nhldh28ks5csxnvdjg9phymqkrxqz-kitty-themes-unstable-2023-06-01/share/kitty-themes/themes/OneHalfDark.conf

# Shell integration is sourced and configured manually
shell_integration no-rc enabled

allow_remote_control socket-only
background_opacity 1
bell_on_tab no
copy_on_select yes
disable_ligatures cursor
enable_audio_bell no
window_alert_on_bell no
window_margin_width 0

map kitty_mod+s paste_from_clipboard
map kitty_mod+v paste_from_selection


modify_font underline_position 2
modify_font underline_thickness 200%

modify_font cell_width 100%
modify_font cell_height -1px

# kitty-scrollback.nvim Kitten alias
action_alias kitty_scrollback_nvim kitten /home/inferno/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --cwd /home/inferno/.local/share/nvim/lazy/kitty-scrollback.nvim/lua/kitty-scrollback/configs
# 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
# 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

kitty 0.29.2 created by Kovid Goyal
โฏ nv --version
NVIM v0.10.0-dev-c68c121
Build type: Release
LuaJIT 2.1.1693350652
Run "nvim -V1 -v" for more info

feat: deprecate v0.9 support

There are no plans to deprecate v0.9 support at this time. This ticket is a placeholder if deprecation occurs in the future.

  • Remove lines in the code with the comment:
  -- NOTE(#58): nvim v0.9 support
  • Remove backport directory and files.

  • Update README for supported versions

  • Pin a tag and add instructions for users to pin the deprecated kitty-scrollback.nvim version for compatibility.

Add an example of how to configure the plugin in lua

Everything is great so far. But some keymap are either don't work or just a bad UX for me, so I tried to customize stuff. Unfortunately nothing works. And the most annoying part, that I think I did everything right, but there is no example that I can compare to or copy+paste to see if/how it works. There are only each and every part of a configuration spread across the readme file. That's why I spend about an hour trying many different way to configure the plugin through lazy.nvim opts or config and it just doesn't work.

And I'm supposed to be a "smart" guy after knowing how to do stuff in Lua, how lazy.nvim config spec works, configuring NvChad and generally feeling pretty good (not great) about knowing how to configure Neovim things in Lua. Sometimes I do skip something from the doc which has a plain answer, but I don't think this is the case (I hope so).

Here is what I consider the almost 100% correct config:

lazy.nvim
  {
    "mikesmithgh/kitty-scrollback.nvim",
    enabled = true,
    lazy = true,
    cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" },
    event = { "User KittyScrollbackLaunch" },
    version = "^2.0.0",
    config = function()
      require("kitty-scrollback").setup {
        custom = function()
          return {
            callbacks = {
              after_ready = function()
                vim.keymap.set("n", "q", ":q<CR>")
                vim.cmd [[quit]]
              end,
            },
          }
        end,
      }
    end,
  },
kitty.conf
allow_remote_control yes
listen_on unix:/tmp/kitty
shell_integration enabled
action_alias kitty_scrollback_nvim kitten ~/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py
map kitty_mod+h kitty_scrollback_nvim --config custom
map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
mouse_map kitty_mod+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output

This config should both add q keymap and exit nvim. Neither is done after Ctrl+Shift+h.

feat: portable kitty.conf without hardcoded path

Hello,

Regrettably, Kitty doesn't natively support the expansion of environment variables within its configuration file. This limitation necessitates specifying hard-coded paths when creating the alias for the KSN kitten. In my case:

action_alias kitty-scrollback_nvim kitten /Users/jonas/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py

This approach leads to a configuration that is neither generic nor portable, which is not ideal. However, I've discovered a workaround that I'd like to share: When using lazy.nvim, you can create a symbolic link within the build function:

build = function()
    local source = vim.fn.stdpath('data') .. '/lazy/kitty-scrollback.nvim'
    local target = vim.env.XDG_CONFIG_HOME .. '/kitty'
    local command = string.format("ln -s '%s' '%s'", source, target)
    os.execute(command)
end,

With this setup, the alias in kitty.conf can be simplified, since Kitty automatically looks in its configuration directory when specifying relative paths:

action_alias kitty-scrollback_nvim kitten kitty-scrollback.nvim/python/kitty_scrollback_nvim.py

This modification results in a Kitty configuration that is both portable and more versatile.

bug: checkhealth attempt to index upvalue 'p' (a nil value)

Add validation for attempt to index upvalue 'p' (a nil value) when running

:checkhealth kitty-scrollback

It should not error out, instead it should run and warn user of incomplete checkhealth with the recommended method of :KittyScrollbackCheckHealth

chore: add nightly cron to check `backport-sha.json` sha256 checksums

backport-sha.json maintains a list of filename and sha256 checksums for backported features from nvim v0.10 to v0.9.

Add a nightly cron that checks the sha256sum of the files in neovim and compares against backport-sha.json. The job should fail and/or alert if there is a different to force us to review the new changes.

bug: terminal colors differ from kitty terminal colors

printf "\033[1;90m%s" "vim.g.terminal_color_8 -> color8"
nvim                   -> kitty
vim.g.terminal_color_0 -> color0
vim.g.terminal_color_1 -> color1
...
vim.g.terminal_color_15 -> color15

solution: set vim.g.terminal_colors to match kitty get-colors

Problem with rendering unicode symbols

Hi,
I'm having an issue with proper unicode rendering. All symbols are displayed properly in kitty
image
but not in scrollback buffer
image

Output from: nvim +'KittyScrollbackCheckHealth'

==============================================================================
kitty-scrollback: require("kitty-scrollback.health").check()

kitty-scrollback: kitty-scrollback.nvim version ~
- OK        `|`\___/`|`       *kitty-scrollback.nvim* @ `v1.1.2`
           =) `^`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 and              
            |     |       provide the `KittyScrollbackCheckHealth` report.                               
           /| | | |\                                                                                    
           \| | `|`_`|`/\
            /_// ___/     *Bonus* *points* *for* *cat* *memes*
               \_)       

kitty-scrollback: Neovim version 0.10+ ~
- OK NVIM 0.10.0-dev+ga66b0fdfaa

kitty-scrollback: Kitty remote control ~
- OK `kitty @ ls` exited with code *0*

kitty-scrollback: Kitty data ~
- OK Kitty data available
  >lua
  {
    columns = 138,
    config_files = { "/home/alteriks/.local/share/nvim/lazy/kitty-scrollback.nvim/lua/kitty-scrollback/configs/checkhealth.lua" },
    cursor_x = 7,
    cursor_y = 1,
    kitty_config_dir = "/home/alteriks/.config/kitty",
    kitty_opts = {
      allow_remote_control = "socket-only",
      listen_on = "unix:/tmp/kitty",
      scrollback_fill_enlarged_window = false,
      scrollback_lines = 2000,
      scrollback_pager = { "less", "--chop-long-lines", "--RAW-CONTROL-CHARS", "+INPUT_LINE_NUMBER" },
      scrollback_pager_history_size = 0,
      shell_integration = { "enabled" }
    },
    kitty_version = { 0, 29, 2 },
    ksb_dir = "/home/alteriks/.local/share/nvim/lazy/kitty-scrollback.nvim",
    lines = 65,
    scrolled_by = 0,
    window_id = 1
  }
  

kitty-scrollback: Kitty version 0.29+ ~
- OK kitty 0.29.2

kitty-scrollback: clipboard ~
- OK Clipboard tool found: *wl-copy*

kitty-scrollback: Kitty shell integration ~
- OK Kitty shell integration is enabled

kitty-scrollback: sed ~
- OK `sed -E -e s/$//g -e s/[\?25.[.*;.*H[.*//g` exited with code *0* and stdout `expected`
     `sed: /usr/bin/sed`

kitty-scrollback: Kitty debug config ~
- OK kitty 0.29.2 created by Kovid Goyal
     Linux moar 6.1.52-1-lts #1 SMP PREEMPT_DYNAMIC Thu, 07 Sep 2023 05:17:41 +0000 x86_64
     Arch Linux 6.1.52-1-lts (/dev/tty)
     
     DISTRIB_ID="Arch"
     DISTRIB_RELEASE="rolling"
     DISTRIB_DESCRIPTION="Arch Linux"
     Running under: `WaylandFrozen:` False
     `Paths:  kitty:` /usr/bin/kitty
     `  base dir:` /usr/lib/kitty
     `  extensions dir:` /usr/lib/kitty/kitty
     `  system shell:` /bin/zsh
     `Loaded config files:`
       /home/alteriks/.config/kitty/kitty.conf
     
     Config options different from defaults:
     allow_remote_control       socket-only
     background_opacity         0.7
     bold_font                  Caskaydia Cove Nerd Font Complete Mono Bold
     bold_italic_font           Caskaydia Cove Nerd Font Complete Mono SemiLight Italic
     click_interval             0.5
     clipboard_control          ('write-clipboard', 'write-primary', 'read-clipboard', 'read-primary')
     cursor_beam_thickness      2.8
     cursor_blink_interval      0.5
     dynamic_background_opacity True
     enable_audio_bell          False
     font_family                CaskaydiaCove Nerd Font Mono
     font_size                  12.5
     input_delay                2
     italic_font                Caskaydia Cove Nerd Font Complete Mono Italic
     listen_on                  unix:/tmp/kitty
     mouse_hide_wait            0.0
     repaint_delay              5
     select_by_word_characters  :@-./_~?&=%+#
     `symbol_map:`
     	U+23fb - U+23fe โ†’ 3270 Nerd Font
     	U+2665 - U+2665 โ†’ 3270 Nerd Font
     	U+26a1 - U+26a1 โ†’ 3270 Nerd Font
     	U+2b58 - U+2b58 โ†’ 3270 Nerd Font
     	U+e000 - U+e00a โ†’ 3270 Nerd Font
     	U+e0a0 - U+e0a3 โ†’ 3270 Nerd Font
     	U+e0b0 - U+e0bf โ†’ 3270 Nerd Font
     	U+e0c0 - U+e0c8 โ†’ 3270 Nerd Font
     	U+e0cc - U+e0cf โ†’ 3270 Nerd Font
     	U+e0d0 - U+e0d2 โ†’ 3270 Nerd Font
     	U+e0d4 - U+e0d4 โ†’ 3270 Nerd Font
     	U+e200 - U+e2a9 โ†’ 3270 Nerd Font
     	U+e5fa - U+e62b โ†’ 3270 Nerd Font
     	U+e700 - U+e7c5 โ†’ 3270 Nerd Font
     	U+f000 - U+f2e0 โ†’ 3270 Nerd Font
     	U+f300 - U+f313 โ†’ 3270 Nerd Font
     	U+f400 - U+f4a8 โ†’ 3270 Nerd Font
     	U+f67c - U+f67c โ†’ 3270 Nerd Font
     sync_to_monitor            False
     window_border_width        (1.0, 'pt')
     `Added shortcuts:`
     	ctrl+f โ†’  launch --type=overlay --stdin-source=@screen_scrollback sh -c 'nvim -c "lua local baleia = require(\"baleia\").setup({}); baleia.once(0)" -c "map <silent> q :qa!<CR>"'
     `Removed shortcuts:`
     	kitty_mod+0 โ†’  tenth_window
     	kitty_mod+1 โ†’  first_window
     	kitty_mod+2 โ†’  second_window
     	kitty_mod+3 โ†’  third_window
     	kitty_mod+4 โ†’  fourth_window
     	kitty_mod+5 โ†’  fifth_window
     	kitty_mod+6 โ†’  sixth_window
     	kitty_mod+7 โ†’  seventh_window
     	kitty_mod+8 โ†’  eighth_window
     	kitty_mod+9 โ†’  ninth_window
     	kitty_mod+backspace โ†’  change_font_size all 0
     	kitty_mod+j โ†’  scroll_line_down
     	kitty_mod+k โ†’  scroll_line_up
     	kitty_mod+left โ†’  previous_tab
     	kitty_mod+right โ†’  next_tab
     	kitty_mod+w โ†’  close_window
     `Changed shortcuts:`
     	kitty_mod+- โ†’  decrease_font_size
     	kitty_mod+= โ†’  increase_font_size
     	kitty_mod+f โ†’  launch --type=overlay --stdin-source=@screen_scrollback /usr/bin/fzf --no-sort --no-mouse --exact -i --tac
     	kitty_mod+g โ†’  kitty_scrollback_nvim --config-file get_text_last_cmd_output.lua
     	shift+insert โ†’  paste_from_clipboard
     `Colors`:
     	background                 #24283b 
     	color0                     #1d202f 
     	color1                     #dc322f 
     	color10                    #9ece6a 
     	color11                    #e0af68 
     	color12                    #7aa2f7 
     	color13                    #bb9af7 
     	color14                    #7dcfff 
     	color15                    #c0caf5 
     	color16                    #ff9e64 
     	color17                    #db4b4b 
     	color2                     #9ece6a 
     	color3                     #e0af68 
     	color4                     #7aa2f7 
     	color5                     #bb9af7 
     	color6                     #7dcfff 
     	color7                     #a9b1d6 
     	color8                     #414868 
     	color9                     #cb4b16 
     	cursor                     #ffffff 
     	cursor_text_color          #24283b 
     	foreground                 #c0caf5 
     	selection_background       #2e3c64 
     	selection_foreground       #c0caf5 
     	url_color                  #73daca 
     
     `Important environment variables seen by the kitty process:`
     	PATH                                `/usr/local/sbin:/usr/local/bin:/usr/bin`
     	LANG                                `en_US.UTF-8`
     	EDITOR                              `nvim`
     	SHELL                               `/bin/zsh`
     	DISPLAY                             `:0`
     	WAYLAND_DISPLAY                     `wayland-1`
     	USER                                `alteriks`
     	XCURSOR_SIZE                        `24`
     	LC_ADDRESS                          `en_US.UTF-8`
     	XDG_BIN_HOME                        `/home/alteriks/.local/bin`
     	LC_NAME                             `en_US.UTF-8`
     	XDG_DATA_HOME                       `/home/alteriks/.local/share`
     	XDG_CONFIG_HOME                     `/home/alteriks/.config`
     	LC_MONETARY                         `en_US.UTF-8`
     	XDG_SEAT                            `seat0`
     	XDG_SESSION_DESKTOP                 `sway`
     	XDG_SESSION_TYPE                    `wayland`
     	LC_PAPER                            `en_US.UTF-8`
     	XDG_CURRENT_DESKTOP                 `sway`
     	XDG_LIB_HOME                        `/home/alteriks/.local/lib`
     	XDG_CACHE_HOME                      `/home/alteriks/.cache`
     	XDG_SESSION_CLASS                   `user`
     	LC_IDENTIFICATION                   `en_US.UTF-8`
     	LC_TELEPHONE                        `en_US.UTF-8`
     	LC_MESSAGES                         `en_US.UTF-8`
     	LC_MEASUREMENT                      `en_US.UTF-8`
     	XDG_VTNR                            `1`
     	XDG_SESSION_ID                      `2`
     	XDG_RUNTIME_DIR                     `/run/user/1000`
     	LC_TIME                             `pl_PL.UTF-8`
     	LC_COLLATE                          `en_US.UTF-8`
     	XDG_DATA_DIRS                       `/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/`
     	LC_NUMERIC                          `pl_PL.UTF-8`

chore: create github action and docs for vnc troubleshooting

# github runner

# secrets
NGROK_TOKEN='whoops'

# ## start working

export DISPLAY=':1'

# desktop env
sudo apt update
sudo apt upgrade
sudo apt install -y xfce4 xfce4-goodies libxcb-xkb1

# nvim
sudo snap install nvim --classic

# kitty
curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin \
	launch=n
export PATH="$HOME/.local/kitty.app/bin:$PATH"

# install turbovnc - uncomment for testing
mkdir -p "$GITHUB_WORKSPACE/tmp"
curl -s -L https://github.com/TurboVNC/turbovnc/releases/download/3.1/turbovnc_3.1_amd64.deb -o "$GITHUB_WORKSPACE/tmp/turbovnc.deb"
cd "$GITHUB_WORKSPACE/tmp" || exit 1
sudo dpkg -i turbovnc.deb
sudo apt update
sudo apt install -f
export PATH="/opt/TurboVNC/bin:$PATH"
vncserver -SecurityTypes None

cd "$GITHUB_WORKSPACE" || exit 1
make test

# ## end working

# # install ngrok
# mkdir -p "$GITHUB_WORKSPACE/tmp/bin"
# curl -s -L https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz -o "$GITHUB_WORKSPACE/tmp/ngrok.tgz"
# tar -xvf ngrok.tgz -C "$GITHUB_WORKSPACE/tmp/bin"
# export PATH="$GITHUB_WORKSPACE/tmp/bin:$PATH"
# ngrok config add-authtoken "$NGROK_TOKEN"
# ngrok tcp 22

# # local machine - uncomment for testing
# # note: without ngrok, connecting to tmate
# # ssh -L 59000:localhost:5901 -C -N -l Xu6NC2hpx8STzqbRW3knGhrwt nyc1.tmate.io
# # channel 2: open failed: administratively prohibited:
# # this works ssh -p 14369 [email protected]
# ssh -L 59000:localhost:5901 -C -N -p 13843 -l runner 8.tcp.ngrok.io
# # connect via vnc client

# useful commands
# vncserver -kill :1

Don't override vim keybinds

Is there a config option so that the plugin doesn't override the default vim yank keybinds? A more granular way to customize the keybinds would also be nice.

feat: distinguish actual scrollback newlines vs vim.o.columns hardwrapped newlines

Steps to reproduce:

Generate extremely long newline, for example:

for t in {1..100}; do echo -ne eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeemmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm;

There is only one long string here, but it's impossible to select with pager as the single line. In the same time with the mouse it remains be possible via kitty scroll-back.
Is there any way to get around this problem?

This can often be seen in practice when parsing absurdly large log lines. After this, they are very inconvenient to copy using the keyboard, which adds manual work. The problem can be worked around using tmux, but it increase overall latency.

Kitty + Fish + kitty-scrollback.nvim

Hi there,

I'm using fish, when I try ctrl+shift+h I see the following error:

fish: $/ is not a valid variable in fish.
kitty @ get-text --match="id:8" --ansi --clear-selection --add-cursor --extent=all | sed -e "s/$/\x1b[0m/g" -e "s/\x1b\[\?25.\x1b\[.*;.*H\x1b\[.*//g"
CleanShot 2023-09-18 at 10 08 31@2x

feat: redesign configuring kitty-scrollback.nvim

Important

If you have had any pain points configuring kitty-scrollback.nvim, please add a comment or suggestion.

Warning

Breaking change

  • Remove nvim defaults --clean --noplugin -n

    • By defaulting to no config, it is confusing to the user why their configurations are not picked up by kitty-scrollback.nvim. Current state: specify --no-nvim-args or --nvim-args <args> to read the kitty-scrollback.nvim configuration.
    • Remove --no-nvim-args since it no longer applies
      • Document the new behavior and detail how the user can continue using --clean --noplugin -n if desired. This is a breaking change and requires the user to configure if they want the existing functionality.
  • Different configuration options:

    -u <user-config>.lua
    --env NVIM_APPNAME=user-config
  • Revisit reserved config names, global, default, ksb_builtin_*, ksb_example_*

- Consider creating a symlink or copying the kitty_scrollback_nvim.py kitten to Kitty's configuration directory to avoid absolute path in action_alias kitty_scrollback_nvim. See #114
- Option: add to bootstrapping logic, try to do it in a generic way to support lazy/packer/pack/etc
- Option: Add to the :KittyScrollbackGenerateKittens command.
- Option: Create a wrapper kitten that resolves the path and calls kitty_scrollback_nvim.py
-Investigate: user uses environment variable or kitty --config could change path of kitty config directory?

  • Consider making config options either a table of function instead of just a function

  • Related issues or discussions around configuring kitty-scrollback.nvim

feat: add support for neovim v0.9

Important

Please like or comment on this ticket if this is something you would like implemented (I'm trying to gauge interest)

v0.9 is currently the stable version of Neovim.

There have been multiple discussions asking around why v0.10 is required.

Depending on availability and the next stable release of Neovim, make kitty-scrollback.nvim compatible with v0.9

feat: apply paste_command and execute_command to visual selection

Apply paste_command and execute_command to visual selection.

  vim.keymap.set({ 'n', 'i' }, '<Plug>(KsbExecuteCmd)', ksb_api.execute_command, { buffer = bufid })
  vim.keymap.set({ 'n', 'i' }, '<Plug>(KsbPasteCmd)', ksb_api.paste_command, { buffer = bufid })

e.g., user visually selects content in scrollback buffer and presses <S-CR> should paste the visual selection to Kitty.

This removes an extra step of yanking to the paste window and then pressing <S-CR>

Output gets cut off towards the bottom

With a huge scrollback, (try running ls -R on a big directory), this scrollback displayed by this plugin will get cut off towards the bottom. I noticed the same issue happening with homebrew kitty pager scripts I've found in the wild.

Overzealous in its shell integration validation

is_valid_extent_keyword incorrectly marks a manual shell integration setup as invalid.

I configured my setup as instructed in the README, and when I tried to get a scrollback of the last commandm, I got 'ERROR: Kitty shell integration is disabled and/or no-prompt-mark is set', from validate_extent. I suspected that the validation check was a false positive and it only checked for the automated shell integration, so I disabled the check and everything worked fine. I was able to get a scrollback of the last command.

I suspect that is_valid_extent_keyword should also check for signs of manual shell integration although I don't yet how to do this. KITTY_SHELL_INTEGRATION environment variable gets cleared, for instance.

Thank you for this plugin. It's an amazing achievement to integrate the scrollback with Neovim so well. I'm looking forward to continued development of this plugin to make it even more seemless and flexible.

[Feature Request] Changing colors

It would be nice if we could change colors.

In current state, the grey color when selecting in visual mode isn't very readable sometimes on my end.

  • Regular selection in kitty with selection_foreground none and selection_background none:
    01

  • Selection in visual mode with kitty-scrollback.nvim:
    02

Search results (just for the sake of consistency):

  • In Neovim:
    image

  • With kitty-scrollback.nvim:
    image

feat: default to nvim icon instead of vim icon

#38 adds the ability to configure the status window icons

Default to use the nvim icon and provide instructions on how to configuring the icon as vim if desired.

Nerd Fonts v3.1.0 released the new nvim icon. Wait until the next release of Nerd Fonts or a breaking change in kitty-scrollback.nvim to release this change.

chore: create ISSUE template

bugs:

Steps:
Run :KittyScrollbackCheckHealth

If :KittyScrollbackCheckHealth fails, please provide

  • Kitty version
  • Neovim version

Questions:

  • Are you running within a terminal multiplexer (.e.g, tmux, screen). If so, which one?

    • tmux
    • screen
    • other (please specify)
  • What shell are you using? (e.g., bash, ksh, fish, nushell, etc)

  • What version of the shell? // TODO: possible add this to KittyScrollbackCheckHealth

Health check doesn't pass in neovim 0.10+

Getting this when try to run check health

kitty-scrollback: Neovim version 0.10+ ~
- ERROR Failed to run healthcheck for "kitty-scrollback" plugin. Exception:
  ...lazy/kitty-scrollback.nvim/lua/kitty-scrollback/util.lua:84: attempt to concatenate field 'prerelease' (a boolean value)

My neovim version

~ 44s โฏ vim --version 
NVIM v0.10.0-dev-3050+g38b0bb3c9-Homebrew
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/HEAD-38b0bb3/share/nvim"

bug: `E5113: Error while calling lua chunk: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:103: no parser for 'vimdoc' language`

When entering Kitty's scrollback history with <C-S-h> and either: yanking, pressing i or a, I keep getting the following error:

Error detected while processing FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20]..script /usr/share/nvim/runtime/ftplugin/help.lua:
E5113: Error while calling lua chunk: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:103: no parser for 'vimdoc' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:103: in function 'add'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:113: in function 'new'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:64: in function '_create_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:468: in function 'start'
        /usr/share/nvim/runtime/ftplugin/help.lua:2: in main chunk
        [C]: in function 'nvim_set_option_value'
        ...itty-scrollback.nvim/lua/kitty-scrollback/footer_win.lua:60: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Then the yanked content appears in kitty-scrollback window and I can perform the regular actions (Execute / Paste). If toggling mappings twice with g?, the error occurs again.

Note that I can't reproduce on my Arch Linux VM with similar setup (NVIM v0.10.0-dev-1988+g1ef60ea65-dirty, same Kitty and kitty-scrollback.nvim config). Only occurs on my main system with Gentoo.

Could it be an issue with dev-libs/tree-sitter package specifically on Gentoo?

Maybe this has nothing to do but I do have the vimdoc parser installed:

  • :checkhealth nvim-treesitter
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v20.6.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (Gentoo 13.2.1_p20230826 p7) 13.2.1 20230826
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.1.67-gentoo-custom",
  sysname = "Linux",
  version = "#11 SMP PREEMPT_DYNAMIC Tue Dec 26 18:38:12 CET 2023"
} ~

Parser/Features         H L F I J
[...]
  - vimdoc              โœ“ . . . โœ“

I tried to reinstall it with :TSInstall vimdoc but it doesn't make any difference, the error persits.

  • :KittyScrollbackCheckHealth:
==============================================================================
kitty-scrollback: require("kitty-scrollback.health").check()

kitty-scrollback: Neovim version 0.9+ ~
- OK NVIM 0.10.0-dev+dirty

kitty-scrollback: kitty-scrollback.nvim version ~
- OK        `|`\___/`|`       *kitty-scrollback.nvim* @ `v3.0.0`
           =) `^`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 and
            |     |       provide the `KittyScrollbackCheckHealth` report.
           /| | | |\
           \| | `|`_`|`/\
            /_// ___/     *Bonus* *points* *for* *cat* *memes*
               \_)

kitty-scrollback: Kitty remote control ~
- OK `kitty @ ls` exited with code *0*

kitty-scrollback: Kitty data ~
- OK Kitty data available
  >lua
  {
    columns = 157,
    cursor_x = 13,
    cursor_y = 25,
    kitty_config_dir = "/home/xfzv/.config/kitty",
    kitty_opts = {
      allow_remote_control = "yes",
      listen_on = "unix:/tmp/kitty",
      scrollback_fill_enlarged_window = false,
      scrollback_lines = 2000,
      scrollback_pager = { "less", "--chop-long-lines", "--RAW-CONTROL-CHARS", "+INPUT_LINE_NUMBER" },
      scrollback_pager_history_size = 0,
      shell_integration = { "enabled" }
    },
    kitty_path = "/usr/bin/kitty",
    kitty_scrollback_config = "ksb_builtin_checkhealth",
    kitty_version = { 0, 31, 0 },
    ksb_dir = "/home/xfzv/.local/share/nvim/lazy/kitty-scrollback.nvim",
    lines = 35,
    scrolled_by = 0,
    window_id = 1,
    window_title = "nvim"
  }


kitty-scrollback: Kitty version 0.29+ ~
- OK kitty 0.31.0

kitty-scrollback: clipboard ~
- OK Clipboard tool found: *xsel*

kitty-scrollback: sed ~
- OK `sed -E -e s/$/๏ฟฝ[0m/g -e s/๏ฟฝ\[\?25.๏ฟฝ\[.*;.*H๏ฟฝ\[.*//g` exited with code *0* and stdout `expected`
     `sed: /usr/bin/sed`

kitty-scrollback: Kitty debug config ~
- OK `kitty0.31.0` created by ``Kovid Goyal``
     Linux gentoo-desktop 6.1.67-gentoo-custom #11 SMP PREEMPT_DYNAMIC Tue Dec 26 18:38:12 CET 2023 x86_64

     This is gentoo-desktop (Linux x86_64 6.1.67-gentoo-custom) 18:08:52

     DISTRIB_ID="Gentoo"
     Running under: `X11Frozen:` False
     `Paths:  kitty:` /usr/bin/kitty
     `  base dir:` /usr/lib64/kitty
     `  extensions dir:` /usr/lib64/kitty/kitty
     `  system shell:` /bin/zsh
     `Loaded config files:`
       /home/xfzv/.config/kitty/kitty.conf

     Config options different from defaults:
     allow_remote_control       yes
     bell_path                  /usr/share/sounds/freedesktop/stereo/service-login.oga
     bold_font                  JetBrainsMono NF Bold
     bold_italic_font           JetBrainsMono NF Bold Italic
     close_on_child_death       True
     copy_on_select             clipboard
     cursor                     None
     cursor_beam_thickness      1.0
     cursor_shape               2
     cursor_stop_blinking_after 0
     disable_ligatures          1
     enabled_layouts            ['splits']
     font_family                JetBrainsMono NF Medium
     font_size                  10.5
     italic_font                JetBrainsMono NF Italic
     listen_on                  unix:/tmp/kitty
     `modify_font:`
         underline_position 18
         underline_thickness 1
     mouse_hide_wait            0.0
     paste_actions              frozenset({'quote-urls-at-prompt'})
     selection_background       None
     selection_foreground       None
     shell_integration          frozenset({'enabled'})
     strip_trailing_spaces      smart
     tab_bar_edge               1
     tab_bar_margin_height      TabBarMarginHeight(outer=1.0, inner=1.0)
     tab_bar_margin_width       1.0
     tab_bar_style              powerline
     tab_powerline_style        slanted
     url_style                  1
     visual_bell_duration       1.5
     window_margin_width        FloatEdges(left=1.0, top=1.0, right=1.0, bottom=1.0)
     window_padding_width       FloatEdges(left=1.0, top=1.0, right=1.0, bottom=1.0)
     `Added mouse actions:`
     	ctrl+left release grabbed โ†’  mouse_handle_click link
     	ctrl+left release ungrabbed โ†’  mouse_handle_click link
     `Changed mouse actions:`
     	ctrl+shift+right press ungrabbed โ†’  combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output
     `Added shortcuts:`
     	alt+0x01000000 โ†’  scroll_page_down
     	alt+end โ†’  scroll_end
     	alt+home โ†’  scroll_home
     	ctrl+c โ†’  copy_or_interrupt
     	ctrl+kp_add โ†’  change_font_size all +2.0
     	ctrl+kp_subtract โ†’  change_font_size all -2.0
     	ctrl+v โ†’  paste_from_clipboard
     	ctrl+w โ†’  close_tab
     	f2 โ†’  set_tab_title
     `Changed shortcuts:`
     	kitty_mod+g โ†’  kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
     	kitty_mod+h โ†’  kitty_scrollback_nvim
     	kitty_mod+j โ†’  move_tab_forward
     	kitty_mod+k โ†’  move_tab_backward
     	kitty_mod+w โ†’  detach_tab
     `Colors`:
     	active_border_color        #a6e3a1
     	active_tab_background      #505052
     	active_tab_foreground      #cdd6f4
     	background                 #1e1e20
     	color0                     #45475a
     	color1                     #f38ba8
     	color10                    #a6e3a1
     	color11                    #f9e2af
     	color12                    #89b4fa
     	color13                    #b4befe
     	color14                    #94e2d5
     	color15                    #a6adc8
     	color2                     #a6e3a1
     	color3                     #f9e2af
     	color4                     #89b4fa
     	color5                     #b4befe
     	color6                     #94e2d5
     	color7                     #bac2de
     	color8                     #585b70
     	color9                     #f38ba8
     	foreground                 #cdd6f4
     	inactive_border_color      #a6adc8
     	inactive_tab_background    #262626
     	inactive_tab_foreground    #cdd6f4
     	url_color                  #89b4fa

     `Important environment variables seen by the kitty process:`
     	PATH                                `/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/16/bin`
     	LANG                                `en_US.UTF-8`
     	EDITOR                              `/bin/nano`
     	SHELL                               `/bin/zsh`
     	DISPLAY                             `:0`
     	USER                                `xfzv`
     	XDG_CONFIG_DIRS                     `/etc/xdg`
     	LC_ADDRESS                          `en_US.UTF-8`
     	LC_NAME                             `en_US.UTF-8`
     	XDG_DATA_HOME                       `/home/xfzv/.local/share`
     	XDG_CONFIG_HOME                     `/home/xfzv/.config`
     	LC_MONETARY                         `en_US.UTF-8`
     	XDG_SEAT                            `seat0`
     	XDG_SESSION_TYPE                    `tty`
     	LC_PAPER                            `en_US.UTF-8`
     	XDG_CACHE_HOME                      `/home/xfzv/.cache`
     	XDG_SESSION_CLASS                   `user`
     	LC_IDENTIFICATION                   `en_US.UTF-8`
     	LC_TELEPHONE                        `en_US.UTF-8`
     	LC_MESSAGES                         `en_US.UTF-8`
     	LC_MEASUREMENT                      `en_US.UTF-8`
     	XDG_VTNR                            `1`
     	XDG_SESSION_ID                      `1`
     	XDG_STATE_HOME                      `/home/xfzv/.local/state`
     	XDG_RUNTIME_DIR                     `/run/user/1000`
     	LC_TIME                             `en_US.UTF-8`
     	LC_COLLATE                          `C.UTF-8`
     	XDG_DATA_DIRS                       `/usr/local/share:/usr/share`
     	LC_NUMERIC                          `en_US.UTF-8`

Nvim 0.9.4 Attempt to index 'p' a nil value at line 194 api.lua

I guess this issue arises when it is unable to connect to Kitty via socket but while running this command in a normal terminal
kittty --listen-on=unix:/tmp/kitty it's working

Running Nvim: 0.9.4
Screenshot 2023-12-10 at 6 54 20 PM

Here is my kitty.conf

allow_remote_control yes
listen_on unix:/tmp/kitty
shell_integration enabled

action_alias kitty_scrollback_nvim kitten /Users/yashjajoo/.local/share/nvim/site/pack/packer/opt/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py

map kitty_mod+h kitty_scrollback_nvim

map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output

mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output

feat: do not select text that is pasted to Kitty via bracketed_paste_mode

See screenshot after or :w from the paste window
bracketed-paste

Probably add an OSC sequence to move cursor like:

  cmd_str = esc .. '[200~' .. cmd_str .. esc .. '[201~' .. esc .. '[C' -- see https://cirw.in/blog/bracketed-paste

See https://github.com/mikesmithgh/kitty-scrollback.nvim/blob/main/lua/kitty-scrollback/kitty_commands.lua#L234

The selection highlighting is using kitty's colors in reverse:

  • foreground
  • background

e.g., foreground = background and background = foreground

Check if that highlighting may be a bug in Kitty because I would expect it to have selection_foreground and selection_background highlights

chore: investigate why `vim.fn.getreg` does not work on Github runner

The demo should_copy_visual_selection_to_clipboard pastes content via the function vim.fn.getreg('+'). This is inconsistent on the Github runners. Some workflows pass, but it fails more times than not.

This is just for a demo and not functionality with kitty-scrollback.nvim itself. Currently, I am hardcoded the paste result to README.md when it is runs via a Github action as a workaround.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.