Skip to content

Commit

Permalink
feat: add the env variable KITTY_SCROLLBACK_NVIM (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh authored Jan 20, 2024
1 parent 681a520 commit c598ff9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,16 @@ use ASCII instead, set the option `status_window.style_simple` to `true`.

<!-- panvimdoc-ignore-end -->

## 🧬 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.
```lua
if vim.env.KITTY_SCROLLBACK_NVIM == 'true' then
-- kitty-scrollback.nvim specific configuration
end
```

## 🫡 Commands and Lua API
The API is available via the `kitty-scrollback.api` module. e.g., `require('kitty-scrollback.api')`

Expand Down
17 changes: 17 additions & 0 deletions doc/kitty-scrollback.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Table of Contents *kitty-scrollback.nvim-table-of-contents*
- Quickstart |kitty-scrollback.nvim-quickstart|
- Installation |kitty-scrollback.nvim-installation|
- Configuration |kitty-scrollback.nvim-configuration|
- Environment Variables |kitty-scrollback.nvim-environment-variables|
- Commands and Lua API |kitty-scrollback.nvim-commands-and-lua-api|
- Keymaps and Lua API |kitty-scrollback.nvim-keymaps-and-lua-api|
- Recommendations |kitty-scrollback.nvim-recommendations|
Expand Down Expand Up @@ -429,6 +430,22 @@ in the status window. If you would like to use ASCII instead, set the option
`status_window.style_simple` to `true`.


ENVIRONMENT VARIABLES *kitty-scrollback.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.

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


COMMANDS AND LUA API *kitty-scrollback.nvim-commands-and-lua-api*

The API is available via the `kitty-scrollback.api` module. e.g.,
Expand Down
2 changes: 2 additions & 0 deletions python/kitty_scrollback_nvim.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def handle_result(args: List[str],

kitty_args = (
'--copy-env',
'--env',
'KITTY_SCROLLBACK_NVIM=true',
'--type',
'overlay',
'--title',
Expand Down
16 changes: 16 additions & 0 deletions tests/kitty-scrollback/kitty_scrollback_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,20 @@ $
{ pattern = 'Error' }
)
end)

it('should have environment variable set', function()
h.assert_screen_match(
h.feed_kitty({
h.open_kitty_scrollback_nvim(),
h.with_pause_seconds_before([[:=vim.env.KITTY_SCROLLBACK_NVIM]], 1),
}),
{
pattern = [[
.*
:=vim.env.KITTY_SCROLLBACK_NVIM
true
Press ENTER or type command to continue.*]],
}
)
end)
end)

0 comments on commit c598ff9

Please sign in to comment.