Skip to content

Commit

Permalink
chore: add filetypes doc to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh committed Jan 28, 2024
1 parent 5e6585f commit 5379d81
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Navigate your [Kitty](https://sw.kovidgoyal.net/kitty/) scrollback buffer to qui
- [Plugin Configuration](#plugin-configuration)
- [Nerd Fonts](#nerd-fonts)
- 🧬 [Environment Variables](#-environment-variables)
- 📄 [Filetypes](#-filetypes)
- 🫡 [Commands](#-commands)
- ⌨️ [Keymaps](#-keymaps)
- 👏 [Recommendations](#-recommendations)
Expand Down Expand Up @@ -544,6 +545,38 @@ if vim.env.KITTY_SCROLLBACK_NVIM == 'true' then
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.

```lua
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.

```lua
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')`

Expand Down

0 comments on commit 5379d81

Please sign in to comment.