mikesmithgh/kitty-scrollback.nvim

Not my config

10b14224cc opened this issue · 20 comments

Hello,

3.x worked fine.

I don't know what 4.0 is opening, but is almost certainly not my nvim default configuration.

Here is how I see a file with nvim:

image

There are line numbers, there is lua line, the background is fully transparent and the background of kitty is started.

Here is how I see it with kitty-scrollback.nvim:

image

The background is black. There is no lualine. There is still barbar though.

I re-did the setup from the beginning, same result.

In my kitty.conf I have:

# kitty-scrollback.nvim Kitten alias
action_alias kitty_scrollback_nvim kitten /home/USERNAME/.local/share/nvim/lazy/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

While checkhealth shows:


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

kitty-scrollback: Neovim version 0.9+ ~
- OK NVIM 0.9.5
- If you are using a version of nvim that is less than 0.10, then formatting on this checkhealth may be malformed

kitty-scrollback: kitty-scrollback.nvim version ~
- OK        `|`\___/`|`       *kitty-scrollback.nvim* @ `v4.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 = 127,
  cursor_x = 1,
  cursor_y = 1,
  kitty_config_dir = "/home/USERNAME/.config/kitty",
  kitty_opts = {
  allow_remote_control = "yes",
  listen_on = "unix:/tmp/mykitty",
  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/USERNAME/.local/share/nvim/lazy/kitty-scrollback.nvim",
  lines = 35,
  scrolled_by = 0,
  window_id = 1,
  window_title = "nvim +'KittyScrollbackCheckHealth'"
  }

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

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

kitty-scrollback: sed ~
- OK `sed -E -e s/\r//g -e s/$/\x1b[0m/g` exited with code *0* and stdout `expected�[0m`
  `sed: /usr/bin/sed`

kitty-scrollback: Kitty debug config ~
- OK `kitty0.31.0` created by ``Kovid Goyal``
  Linux raffarch 6.7.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Sun, 21 Jan 2024 22:14:10 +0000 x86_64
  Arch Linux 6.7.1-arch1-1 (/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:` /usr/bin/bash
  `Loaded config files:`
  /home/USERNAME/.config/kitty/kitty.conf
  
  Config options different from defaults:
  active_tab_title_template {index}: {title[title.rfind('/')+1:]}
  allow_remote_control      yes
  background_opacity        0.9
  confirm_os_window_close   0
  enabled_layouts           ['tall:bias=50;full_size=1;mirrored=false']
  font_family               FiraCode Nerd Font Mono
  font_size                 18.0
  listen_on                 unix:/tmp/mykitty
  tab_bar_style             powerline
  tab_powerline_style       round
  tab_title_template        {index}: {title[title.rfind('/')+1:]}
  `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:`
  ctrl+enter →  send_text normal,application \x1b[13;5u
  kitty_mod+' →  change_font_size all -1.0
  kitty_mod+p →  layout_action bias 10 20 30 40 50 60 70 80 90
  kitty_mod+à →  move_tab_backward
  kitty_mod+è →  move_window_backward
  kitty_mod+ù →  move_tab_forward
  shift+enter →  send_text normal,application \x1b[13;2u
  `Removed shortcuts:`
  kitty_mod+p > f →  kitten hints --type path --program -
  kitty_mod+p > h →  kitten hints --type hash --program -
  kitty_mod+p > l →  kitten hints --type line --program -
  kitty_mod+p > n →  kitten hints --type linenum
  kitty_mod+p > shift+f →  kitten hints --type path
  kitty_mod+p > w →  kitten hints --type word --program -
  kitty_mod+p > y →  kitten hints --type hyperlink
  `Changed shortcuts:`
  kitty_mod++ →  move_window_forward
  kitty_mod+0 →  change_font_size all +1.0
  kitty_mod+enter →  new_window_with_cwd
  kitty_mod+g →  kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
  kitty_mod+h →  kitty_scrollback_nvim
  kitty_mod+j →  previous_window
  kitty_mod+k →  next_window
  kitty_mod+l →  next_tab
  kitty_mod+o →  layout_action bias 90 80 70 60 50 40 30 20 10
  kitty_mod+r →  set_tab_title
  kitty_mod+t →  new_tab_with_cwd
  `Colors`:
  active_border_color       #b7bdf8 
  active_tab_background     #c6a0f6 
  active_tab_foreground     #181926 
  background                #24273a 
  bell_border_color         #eed49f 
  color0                    #494d64 
  color1                    #ed8796 
  color10                   #a6da95 
  color11                   #eed49f 
  color12                   #8aadf4 
  color13                   #f5bde6 
  color14                   #8bd5ca 
  color15                   #a5adcb 
  color2                    #a6da95 
  color3                    #eed49f 
  color4                    #8aadf4 
  color5                    #f5bde6 
  color6                    #8bd5ca 
  color7                    #b8c0e0 
  color8                    #5b6078 
  color9                    #ed8796 
  cursor                    #f4dbd6 
  cursor_text_color         #24273a 
  foreground                #cad3f5 
  inactive_border_color     #6e738d 
  inactive_tab_background   #1e2030 
  inactive_tab_foreground   #cad3f5 
  mark1_background          #b7bdf8 
  mark1_foreground          #24273a 
  mark2_background          #c6a0f6 
  mark2_foreground          #24273a 
  mark3_background          #7dc4e4 
  mark3_foreground          #24273a 
  selection_background      #f4dbd6 
  selection_foreground      #24273a 
  tab_bar_background        #181926 
  url_color                 #f4dbd6 
  
  `Important environment variables seen by the kitty process:`
  PATH                                `/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin`
  LANG                                `en_US.UTF-8`
  SHELL                               `/usr/bin/bash`
  DISPLAY                             `:0`
  WAYLAND_DISPLAY                     `wayland-1`
  USER                                `USERNAME`
  XCURSOR_SIZE                        `24`
  XDG_BACKEND                         `wayland`
  XDG_SEAT                            `seat0`
  XDG_SESSION_TYPE                    `wayland`
  XDG_CURRENT_DESKTOP                 `Hyprland`
  XDG_SESSION_CLASS                   `user`
  XDG_VTNR                            `1`
  XDG_SESSION_ID                      `3`
  XDG_RUNTIME_DIR                     `/run/user/1000`
  LC_TIME                             `en_DK.UTF-8`

Hey @10b14224cc thank you for reporting. kitty-scrollback.nvim has some options that are set by default https://github.com/mikesmithgh/kitty-scrollback.nvim/blob/main/lua/kitty-scrollback/launch.lua#L118

Particularly, vim.o.number and vim.o.laststatus that will hide line numbers and lualine.

kitty-scrollback.nvim has the option restore_options that restores the user options after setup. Could you try the following and let me know if this resolves your issues?

require('kitty-scrollback').setup({
  {
    restore_options = true,
  },
})

Regarding the background, kitty-scrollback.nvim should try to use kitty's background color if you are using the default nvim colorscheme. Otherwise, it should use your Neovim colorscheme's background color. There may be a bug or some configuration option that I am not checking causing this problem for you.

If your Neovim config is available, could you share a link to it?

Particularly, vim.o.number and vim.o.laststatus that will hide line numbers and lualine.

Actually I would prefer having lualine but hiding barbar (not useful there, right?)

kitty-scrollback.nvim has the option restore_options that restores the user options after setup. Could you try the following and let me know if this resolves your issues?

It shows lualine but the background is still black.

Also there is considerable space between window margin and lualine

If your Neovim config is available, could you share a link to it?

To set the colorscheme in nvim I do:

require("lazy").setup({
        "catppuccin/nvim"
})
[...]
vim.cmd.colorscheme("catppuccin-macchiato")
-- Set fully transparent background
-- Must be done after specifying colorscheme because it's overrode by colorscheme specification
-- To set transparency in vimL, see: https://stackoverflow.com/questions/37712730/set-vim-background-transparent/37720708#37720708
-- To port to Lua, see: https://stackoverflow.com/questions/71152802/how-to-override-color-scheme-in-neovim-lua-config-file/73370407#73370407
--]]
vim.api.nvim_set_hl(0, "Normal", {guibg = NONE, ctermbg = NONE})

For kitty:

include current-theme.conf
# Background transparency
background_opacity 0.9

and current-theme.conf is:

# vim:ft=kitty

## name:     Catppuccin Kitty Macchiato
## author:   Catppuccin Org
## license:  MIT
## upstream: https://github.com/catppuccin/kitty/blob/main/macchiato.conf
## blurb:    Soothing pastel theme for the high-spirited!



# The basic colors
foreground              #CAD3F5
background              #24273A
selection_foreground    #24273A
selection_background    #F4DBD6

# Cursor colors
cursor                  #F4DBD6
cursor_text_color       #24273A

# URL underline color when hovering with mouse
url_color               #F4DBD6

# Kitty window border colors
active_border_color     #B7BDF8
inactive_border_color   #6E738D
bell_border_color       #EED49F

# OS Window titlebar colors
wayland_titlebar_color system
macos_titlebar_color system

# Tab bar colors
active_tab_foreground   #181926
active_tab_background   #C6A0F6
inactive_tab_foreground #CAD3F5
inactive_tab_background #1E2030
tab_bar_background      #181926

# Colors for marks (marked text in the terminal)
mark1_foreground #24273A
mark1_background #B7BDF8
mark2_foreground #24273A
mark2_background #C6A0F6
mark3_foreground #24273A
mark3_background #7DC4E4

# The 16 terminal colors

# black
color0 #494D64
color8 #5B6078

# red
color1 #ED8796
color9 #ED8796

# green
color2  #A6DA95
color10 #A6DA95

# yellow
color3  #EED49F
color11 #EED49F

# blue
color4  #8AADF4
color12 #8AADF4

# magenta
color5  #F5BDE6
color13 #F5BDE6

# cyan
color6  #8BD5CA
color14 #8BD5CA

# white
color7  #B8C0E0
color15 #A5ADCB

@10b14224cc

Actually I would prefer having lualine but hiding barbar (not useful there, right?)

Yes, I agree barbar doesn't make much sense unless you have multiple buffers open. You could configure this in barbar like

    require('barbar').setup({
      auto_hide = 1, -- if # of buffers is <= to this, then hide barbar
      -- your config here
    })

you could also do something like
auto_hide = vim.env.KITTY_SCROLLBACK_NVIM == 'true' and 1 or -1,
or add some hooks into the after_ready callback to do something similar.

It shows lualine but the background is still black.

This is definitely a bug, I was able to reproduce with vim.api.nvim_set_hl(0, 'Normal', {}). Thanks for pointing this out, I created the issue #181 and plan to fix it.

Also there is considerable space between window margin and lualine

Could you please provide a screenshot of what you are seeing?

@10b14224cc I just fixed #181, that should fix you background color issue. Also, the spacing issue I believe you saw was actually the difference in the Kitty terminal background color and Neovim's background color. That should be fixed as well if that assumption is correct.

Let me know if this fixes your issues or if you help with anything else.

@10b14224cc I just fixed #181, that should fix you background color issue. Also, the spacing issue I believe you saw was actually the difference in the Kitty terminal background color and Neovim's background color. That should be fixed as well if that assumption is correct.

Let me know if this fixes your issues or if you help with anything else.

I don't know.

I now see the background as transparent as it should be.

I also see line numbers and lualine, they were supposed to not be there, weren't they?

But most importantly, if for example I press dd the line disappears, but pressing p doesn't put it back.

If I press i, another popup shows up, sometimes with the text in nvim and sometimes not, and press <C-CR> to run it.

image

Also, the output of the last command include the last prompt as well (I have starship):

image

I think this is overshooting it.

I really don't need my nvim config there.

Once upon a time I pressed the keybinding for the current buffer, the windows flashed a bit and I could use my nvim keybindings directly in the buffer, and after yanking what I needed it inserted the text in a new prompt.

I liked the old way better. I really don't need all this features.

Sorry, the popup that is being opened with i is always empty. So I don't have the text in nvim there.

How do I modify the output of the last command before running it?

I now see the background as transparent as it should be.

👍

I also see line numbers and lualine, they were supposed to not be there, weren't they?

If you have restore_options set to true then it will show whatever configuration you have for numbers and lualine ( see #179 (comment)).

If you don't want numbers or lualine, you can remove restore_options from your config.

But most importantly, if for example I press dd the line disappears, but pressing p doesn't put it back.
If I press i, another popup shows up, sometimes with the text in nvim and sometimes not, and press to run it.

I'm not sure I follow what you are saying here. If you press dd in the scrollback buffer it shouldn't allow that since you can't modify that buffer. If you dd and p inside the paste window, I would expect that to work. Where are you doing dd and p ?

If I press i, another popup shows up, sometimes with the text in nvim and sometimes not, and press to run it.

i will enter insert mode. The paste window should be blank, unless you have already copied text to it previously. For example, yy should copy a line to the paste window. esc will close the paste window. Then i will reopen the paste window with the previous text that was pasted.

Also, the output of the last command include the last prompt as well (I have starship):

This last command is whatever kitty returns from kitty @ get-text --extent=last_cmd_output. You can test this by commenting out map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output in your kitty.conf, reloading, and then pressing kitty_mod+g. This will open in kitty's default scrollback pager less. The results should be the same.

I liked the old way better. I really don't need all this features.

Check out no-configuration on the README. There haven't been any new features added, this is simply just using your Neovim configuration now which you may or may not want depending on your use case.

Just update your kitty.conf to include the args --nvim-args --clean --noplugin -n and you will have the same behavior as previously.

Something like this:

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

You should check out separte-neovim-configuration as well. There are options for no config, separate, and minimal configs.

Sorry, the popup that is being opened with i is always empty. So I don't have the text in nvim there.

How do I modify the output of the last command before running it?

i just opens the paste window, you need to select the text you want by yanking it and it should open in the paste window. Then, modify the command and execute.

This last command is whatever kitty returns from kitty @ get-text --extent=last_cmd_output. You can test this by commenting out map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output in your kitty.conf, reloading, and then pressing kitty_mod+g. This will open in kitty's default scrollback pager less. The results should be the same.

Yes, it returns the prompt as part of the output.

So is this a kitty bug?

This last command is whatever kitty returns from kitty @ get-text --extent=last_cmd_output. You can test this by commenting out map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output in your kitty.conf, reloading, and then pressing kitty_mod+g. This will open in kitty's default scrollback pager less. The results should be the same.

Yes, it returns the prompt as part of the output.

So is this a kitty bug?

Yep that would be an upstream bug in Kitty.

Hey @10b14224cc, I am closing this issue. Feel free to reopen or create a new issue if you have any other problems.

Hello @mikesmithgh,

Sorry for bothering you.

I don't understand how it works anymore.

I run

echo "hello"
echo "bye"

I type CTRL+SHIFT+G and I get this:
image

How do I select and copy the bye?

<Space>y types . y, so I don't understand if it's yanking and if so why it is typing.

Once upon a time with previous versions of kitty-scrollback.nvim the cursor stayed in the terminal, and I could move it using vim-keybindings.

Now it is opening a new window and I don't understand how to use it.

I think my vim keybindings are conflicting with that <Space>y maybe?

I type CTRL+SHIFT+G and I get this:
image

Hey @10b14224cc thanks for letting me know. That is not expected behavior. So, the window are you seeing is the "paste window". That should only be opened when you yank text from the buffer or enter insert mode.

It seems like something may be automatically triggering insert mode in this case causing the paste window to open.

y types . y, so I don't understand if it's yanking and if so why it is typing.

The "paste window" is in insert mode, so it is entering your text. You should be able to hit escape to enter normal mode, then escape to go back to the scrollback buffer. But, still this shouldn't happen automatically like you are seeing.

<Space>y means that if you yank anything using your leader key <Space> it will copy that text to the clipboard and exit kitty-scrollback.nvim.

Could you do two things for me?

1. Try updating the action_alias line in kitty.conf similar to:

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

Then reload your Kitty config with ctrl+shift+f5 (⌃ + ⌘ + , on macOS)

The args --nvim-args --clean --noplugin -n will open a clean nvim without your config or plugins.

Please let me know if this works. If this works, then we can try to hunt down what is causing the paste window to open automatically.

2. If you nvim config is available on github, could you share the link so I could take a look?

The args --nvim-args --clean --noplugin -n will open a clean nvim without your config or plugins.
Please let me know if this works. If this works, then we can try to hunt down what is causing the paste window to open automatically.

Yes with this it opens the scrollback buffer, and after I yank it opens the "paste window"

  1. If you nvim config is available on github, could you share the link so I could take a look?

It is not available on github, but now that I think about it, maybe this section of my init.lua is relevant?

-- when switching to a terminal window, automatically switch to insert mode
-- see: https://vi.stackexchange.com/a/43781/36430
vim.api.nvim_create_autocmd({ "TermOpen", "BufEnter" }, {
    pattern = { "*" },
    callback = function()
        if vim.opt.buftype:get() == "terminal" then
            vim.cmd(":startinsert")
        end
    end
})

It is not available on github, but now that I think about it, maybe this section of my init.lua is relevant?

-- when switching to a terminal window, automatically switch to insert mode
-- see: https://vi.stackexchange.com/a/43781/36430
vim.api.nvim_create_autocmd({ "TermOpen", "BufEnter" }, {
    pattern = { "*" },
    callback = function()
        if vim.opt.buftype:get() == "terminal" then
            vim.cmd(":startinsert")
        end
    end
})

ah that looks like it! let me check a couple things and I can give you a way to avoid this for kitty-scrollback.nvim

@10b14224cc could you try?

vim.api.nvim_create_autocmd({ 'TermOpen', 'BufEnter' }, {
  pattern = { '*' },
  callback = function()
    if vim.env.KITTY_SCROLLBACK_NVIM ~= 'true' and vim.o.buftype == 'terminal' then
      vim.cmd(':startinsert')
    end
  end,
})

I was able to reproduce the issue you were seeing, and kitty-scrollback.nvim is in a broken state due to that unexpected insert mode.

oh yes it works now. Many thanks.

oh yes it works now. Many thanks.

awesome!