Skip to content
Mike edited this page Oct 31, 2023 · 26 revisions

Warning

wiki is a work in progress


ksb_builtin_get_text_all

(click for video)

ksb_example_get_text_all_plain

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'all',
      ansi = false,
    },
  }
end

ksb_builtin_last_cmd_output

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'last_cmd_output',
      ansi = true,
    },
  }
end

ksb_example_get_text_last_cmd_output_plain

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'last_cmd_output',
      ansi = false,
    },
  }
end

ksb_builtin_last_visited_cmd_output

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'last_visited_cmd_output',
      ansi = true,
    },
  }
end

ksb_example_last_visited_cmd_output_plain

(click for video)

ksb_example_callbacks

(click for video)

Configuration

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

ksb_example_status_win_autoclose

(click for video)

Configuration

function()
  return {
    status_window = {
      autoclose = true,
    },
  }
end

ksb_example_status_win_show_timer

(click for video)

Configuration

function()
  return {
    status_window = {
      show_timer = true,
    },
    callbacks = {
      after_setup = function()
        vim.loop.sleep(4000)
      end,
    },
  }
end

ksb_example_status_win_simple

(click for video)

Configuration

function()
  return {
    status_window = {
      style_simple = true,
    },
  }
end

ksb_example_status_win_try_detect_nerd_fonts

(click for video)

Configuration

function()
  return {
    status_window = {
      style_simple = not require('kitty-scrollback.kitty_commands').try_detect_nerd_font(),
    },
  }
end

ksb_example_get_text_first_cmd_output_on_screen

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'first_cmd_output_on_screen',
      ansi = true,
    },
  }
end

ksb_example_get_text_first_cmd_output_on_screen_plain

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'first_cmd_output_on_screen',
      ansi = false,
    },
  }
end

ksb_example_get_text_last_non_empty_output

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'last_non_empty_output',
      ansi = true,
    },
  }
end

ksb_example_get_text_last_non_empty_output_plain

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'last_non_empty_output',
      ansi = false,
    },
  }
end

ksb_example_get_text_screen

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'screen',
      ansi = true,
    },
  }
end

ksb_example_get_text_screen_plain

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'screen',
      ansi = false,
    },
  }
end

ksb_example_get_text_selection

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'selection',
      ansi = true,
    },
  }
end

ksb_example_get_text_selection_plain

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'selection',
      ansi = false,
    },
  }
end

ksb_example_get_text_selection_keep_selection

(click for video)

Configuration

function()
  return {
    kitty_get_text = {
      extent = 'selection',
      ansi = true,
      clear_selection = false,
    },
  }
end

ksb_example_highlight_overrides

(click for video)

Configuration

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

ksb_example_keymaps_custom

(click for video)

Configuration

function()
  vim.keymap.set({ 'v' }, 'sY', '<Plug>(KsbVisualYankLine)', {})
  vim.keymap.set({ 'v' }, 'sy', '<Plug>(KsbVisualYank)', {})
  vim.keymap.set({ 'n' }, 'sY', '<Plug>(KsbNormalYankEnd)', {})
  vim.keymap.set({ 'n' }, 'sy', '<Plug>(KsbNormalYank)', {})
  vim.keymap.set({ 'n' }, 'syy', '<Plug>(KsbYankLine)', {})

  vim.keymap.set({ 'n' }, 'q', '<Plug>(KsbCloseOrQuitAll)', {})
  vim.keymap.set({ 'n', 't', 'i' }, 'ZZ', '<Plug>(KsbQuitAll)', {})

  vim.keymap.set({ 'n' }, '<tab>', '<Plug>(KsbToggleFooter)', {})
  vim.keymap.set({ 'n', 'i' }, '<cr>', '<Plug>(KsbExecuteCmd)', {})
  vim.keymap.set({ 'n', 'i' }, '<c-v>', '<Plug>(KsbPasteCmd)', {})
end

ksb_example_keymaps_disabled

(click for video)

Configuration

function()
  return {
    keymaps_enabled = false,
  }
end

ksb_example_paste_win_filetype

(click for video)

Configuration

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

ksb_example_paste_win_hide_mappings

(click for video)

Configuration

function()
  return {
    paste_window = {
      hide_footer = true,
    },
  }
end

ksb_example_paste_win_highlight_as_float

(click for video)

Configuration

function()
  return {
    paste_window = {
      highlight_as_normal_win = function()
        return false
      end,
    },
  }
end

ksb_example_paste_win_register_disabled

(click for video)

Configuration

function()
  return {
    paste_window = {
      yank_register_enabled = false,
    },
  }
end

ksb_example_paste_win_register

(click for video)

Configuration

function()
  return {
    paste_window = {
      yank_register = '*',
    },
  }
end

ksb_example_paste_win_winblend

(click for video)

Configuration

function()
  return {
    paste_window = {
      winblend = 50,
    },
  }
end

ksb_example_paste_win_winopts

(click for video)

Configuration

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

ksb_example_restore_opts

(click for video)

Configuration

function()
  vim.o.termguicolors = true
  vim.o.number = true
  return {
    restore_options = true,
  }
end

ksb_example_status_win_disabled

(click for video)

Configuration

function()
  return {
    status_window = {
      enabled = false,
    },
  }
end

ksb_example_env_nvim_appname

(click for video)

ksb_example_nvim_args_tokyonight

(click for video)

ksb_example_nvim_args_cellular_automation

(click for video)

ksb_builtin_checkhealth

(click for video)

Configuration

function()
  return {
    checkhealth = true,
  }
end

Clone this wiki locally