mikesmithgh / kitty-scrollback.nvim

😽 Open your Kitty scrollback buffer with Neovim. Ameowzing!
Apache License 2.0
413 stars 11 forks source link

bug: `Vim:Can only call this function in an unmodified buffer` #262

Open jcrespy opened 1 month ago

jcrespy commented 1 month ago

Hello,

I tried reusing the plugin after a long time, but it doesn't work for me anymore. I tried reinstalling following every step in the install process.

OS : macos

The error message I get when running :

kitty-scrollback.nvim

ERROR: failed to execute remote Kitty command

entrypoint: termopen() :: pcall(vim.fn.termopen) error returned 
command: /opt/homebrew/bin/kitty @ get-text --match="id:1" --ansi --clear-selection --add-wrap-markers --extent=all | sed -E -e 's/\r//g' -  e 's/$/\x1b[0m/g' && /opt/homebrew/bin/kitty +runpy 'sys.stdout.flush()' && printf "^[]2;"
stdout:
  <none>

stderr:

  Vim:Can only call this function in an unmodified buffer

Output of checkhealth :


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

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

kitty-scrollback: kitty-scrollback.nvim version ~
- OK        `|`\___/`|`       *kitty-scrollback.nvim* @ `v5.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 = 141,
    cursor_x = 1,
    cursor_y = 1,
    kitty_config_dir = "/Users/julien/.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 = "no-cursor"
    },
    kitty_path = "/opt/homebrew/bin/kitty",
    kitty_scrollback_config = "ksb_builtin_checkhealth",
    kitty_version = { 0, 35, 2 },
    ksb_dir = "/Users/julien/.local/share/nvim/lazy/kitty-scrollback.nvim",
    lines = 67,
    scrolled_by = 0,
    shell = "/bin/zsh",
    tmux = vim.empty_dict(),
    window_id = 1,
    window_title = "nvim +'KittyScrollbackCheckHealth'"
  }

kitty-scrollback: Kitty version 0.32.2+ ~
- OK kitty 0.35.2

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

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

kitty-scrollback: Kitty debug config ~
- OK kitty 0.35.2 (ad328bfeaa) created by Kovid Goyal
     Darwin Juliens-MacBook-Air.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122 arm64
     ProductName:       macOS ProductVersion:       14.5 BuildVersion:      23F79
     `OpenGL:` '4.1 Metal - 88.1' Detected version: 4.1
     `Frozen:` True
     `Paths:  kitty:` /Applications/kitty.app/Contents/MacOS/kitty
     `  base dir:` /Applications/kitty.app/Contents/Resources/kitty
     `  extensions dir:` /Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions
     `  system shell:` /bin/zsh
     `Loaded config files:`
       /Users/julien/.config/kitty/kitty.conf

     Config options different from defaults:
     allow_remote_control       yes
     background_blur            50
     background_opacity         0.1
     close_on_child_death       True
     dynamic_background_opacity True
     enable_audio_bell          False
     enabled_layouts            ['splits']
     font_family                FiraCode Nerd Font Mono
     font_size                  14.0
     hide_window_decorations    2
     listen_on                  unix:/tmp/kitty
     shell_integration          frozenset({'no-cursor'})
     window_padding_width       FloatEdges(left=5.0, top=5.0, right=5.0, bottom=5.0)
     `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 →  launch --cwd=current --location=split
        ctrl+h →  kitten pass_keys.py neighboring_window left   ctrl+h
        ctrl+j →  kitten pass_keys.py neighboring_window bottom ctrl+j
        ctrl+k →  kitten pass_keys.py neighboring_window top    ctrl+k
        ctrl+l →  kitten pass_keys.py neighboring_window right  ctrl+l
        opt+r →  start_resizing_window
     `Removed shortcuts:`
        cmd+, →  edit_config_file
        cmd+enter →  new_window
        cmd+h →  hide_macos_app
        cmd+k →  clear_terminal to_cursor active
        cmd+m →  minimize_macos_window
        cmd+n →  new_os_window
        cmd+q →  quit
        cmd+t →  new_tab
        cmd+w →  close_tab
        ctrl+cmd+, →  load_config_file
        ctrl+cmd+f →  toggle_fullscreen
        opt+cmd+h →  hide_macos_other_apps
        opt+cmd+r →  clear_terminal reset active
        opt+cmd+s →  toggle_macos_secure_keyboard_entry
        shift+cmd+/ →  open_url https://sw.kovidgoyal.net/kitty/
        shift+cmd+[ →  previous_tab
        shift+cmd+] →  next_tab
        shift+cmd+w →  close_os_window
     `Changed shortcuts:`
        kitty_mod+g →  kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
        kitty_mod+h →  kitty_scrollback_nvim
        kitty_mod+j →  resize_window shorter 5
        kitty_mod+k →  resize_window taller 5
        kitty_mod+l →  resize_window narrower 5
        kitty_mod+o →  remote_control set-background-opacity 1
        kitty_mod+t →  remote_control set-background-opacity 0.1
     `Colors`:
        active_border_color        #f38ba6 
        active_tab_background      #cba6f7 
        active_tab_foreground      #11111b 
        background                 #1e1e2e 
        bell_border_color          #f9e2af 
        color0                     #45475a 
        color1                     #f38ba8 
        color10                    #a6e3a1 
        color11                    #f9e2af 
        color12                    #89b4fa 
        color13                    #f5c2e7 
        color14                    #94e2d5 
        color15                    #a6adc8 
        color2                     #a6e3a1 
        color3                     #f9e2af 
        color4                     #89b4fa 
        color5                     #f5c2e7 
        color6                     #94e2d5 
        color7                     #bac2de 
        color8                     #585b70 
        color9                     #f38ba8 
        cursor                     #f5e0dc 
        cursor_text_color          #1e1e2e 
        foreground                 #cdd6f4 
        inactive_border_color      #6c7086 
        inactive_tab_background    #181825 
        inactive_tab_foreground    #cdd6f4 
        mark1_background           #b4befe 
        mark1_foreground           #1e1e2e 
        mark2_background           #cba6f7 
        mark2_foreground           #1e1e2e 
        mark3_background           #74c7ec 
        mark3_foreground           #1e1e2e 
        selection_background       #f5e0dc 
        selection_foreground       #1e1e2e 
        tab_bar_background         #11111b 
        url_color                  #f5e0dc 

     `Important environment variables seen by the kitty process:`
        PATH                                `/opt/homebrew/Cellar/pyenv-virtualenv/1.2.3/shims:/Users/julien/.pyenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/julien/.local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/homebrew/Cellar/pyenv-virtualenv/1.2.3/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Applications/kitty.app/Contents/MacOS`
        LANG                                `en_US.UTF-8`
        SHELL                               `/bin/zsh`
        USER                                `julien`

My kitty.conf :

background_opacity 0.1
background_blur 50

dynamic_background_opacity yes
allow_remote_control yes

font_size 14.0
font_family FiraCode Nerd Font Mono
enable_audio_bell no

# We set the cursor to indicate which vi mode we are in in inpurc,
# so we don't want kitty to change it again
# See https://sw.kovidgoyal.net/kitty/shell-integration/ 
shell_integration no-cursor

window_padding_width 5

enabled_layouts Splits

# Vim-like window management
map ctrl+enter launch --cwd=current --location=split
map ctrl+q close_window

map ctrl+j kitten pass_keys.py neighboring_window bottom ctrl+j
map ctrl+k kitten pass_keys.py neighboring_window top    ctrl+k
map ctrl+h kitten pass_keys.py neighboring_window left   ctrl+h
map ctrl+l kitten pass_keys.py neighboring_window right  ctrl+l

# map kitty_mod+h neighboring_window left
# map kitty_mod+l neighboring_window right
# map kitty_mod+j neighboring_window down
# map kitty_mod+k neighboring_window up

map kitty_mod+h resize_window wider 5
map kitty_mod+l resize_window narrower 5
map kitty_mod+j resize_window shorter 5
map kitty_mod+k resize_window taller 5

map alt+r start_resizing_window
hide_window_decorations titlebar-only

map kitty_mod+o remote_control set-background-opacity 1
map kitty_mod+t remote_control set-background-opacity 0.1

# BEGIN_KITTY_THEME
# Catppuccin-Mocha
include current-theme.conf
# END_KITTY_THEME

# Kitty scrollback
listen_on unix:/tmp/kitty
#
# kitty-scrollback.nvim Kitten alias
action_alias kitty_scrollback_nvim kitten /Users/julien/.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

And the plugin config :

return {
  '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 = '^3.0.0', -- pin major version, include fixes and features that do not have breaking changes
  config = function()
    require('kitty-scrollback').setup()
  end,
}

Did I mess something up, or is this a bug ?

mikesmithgh commented 1 month ago

Hey @jcrespy thank you for reporting. This is most likely a conflict with another plugin that is populating the buffer on startup.

mikesmithgh commented 3 weeks ago

Hi @jcrespy just checking if you are still having an issue?