mikesmithgh / kitty-scrollback.nvim

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

bug: `E5113: Error while calling lua chunk: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:103: no parser for 'vimdoc' language` #131

Closed xfzv closed 1 month ago

xfzv commented 9 months ago

When entering Kitty's scrollback history with <C-S-h> and either: yanking, pressing i or a, I keep getting the following error:

Error detected while processing FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20]..script /usr/share/nvim/runtime/ftplugin/help.lua:
E5113: Error while calling lua chunk: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:103: no parser for 'vimdoc' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:103: in function 'add'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:113: in function 'new'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:64: in function '_create_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:468: in function 'start'
        /usr/share/nvim/runtime/ftplugin/help.lua:2: in main chunk
        [C]: in function 'nvim_set_option_value'
        ...itty-scrollback.nvim/lua/kitty-scrollback/footer_win.lua:60: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Then the yanked content appears in kitty-scrollback window and I can perform the regular actions (Execute / Paste). If toggling mappings twice with g?, the error occurs again.

Note that I can't reproduce on my Arch Linux VM with similar setup (NVIM v0.10.0-dev-1988+g1ef60ea65-dirty, same Kitty and kitty-scrollback.nvim config). Only occurs on my main system with Gentoo.

Could it be an issue with dev-libs/tree-sitter package specifically on Gentoo?

Maybe this has nothing to do but I do have the vimdoc parser installed:

nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v20.6.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (Gentoo 13.2.1_p20230826 p7) 13.2.1 20230826
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.1.67-gentoo-custom",
  sysname = "Linux",
  version = "#11 SMP PREEMPT_DYNAMIC Tue Dec 26 18:38:12 CET 2023"
} ~

Parser/Features         H L F I J
[...]
  - vimdoc              ✓ . . . ✓

I tried to reinstall it with :TSInstall vimdoc but it doesn't make any difference, the error persits.

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

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

kitty-scrollback: kitty-scrollback.nvim version ~
- OK        `|`\___/`|`       *kitty-scrollback.nvim* @ `v3.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 = 157,
    cursor_x = 13,
    cursor_y = 25,
    kitty_config_dir = "/home/xfzv/.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 = { "enabled" }
    },
    kitty_path = "/usr/bin/kitty",
    kitty_scrollback_config = "ksb_builtin_checkhealth",
    kitty_version = { 0, 31, 0 },
    ksb_dir = "/home/xfzv/.local/share/nvim/lazy/kitty-scrollback.nvim",
    lines = 35,
    scrolled_by = 0,
    window_id = 1,
    window_title = "nvim"
  }

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

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

kitty-scrollback: sed ~
- OK `sed -E -e s/$//g -e s/\[\?25.\[.*;.*H\[.*//g` exited with code *0* and stdout `expected`
     `sed: /usr/bin/sed`

kitty-scrollback: Kitty debug config ~
- OK `kitty0.31.0` created by ``Kovid Goyal``
     Linux gentoo-desktop 6.1.67-gentoo-custom #11 SMP PREEMPT_DYNAMIC Tue Dec 26 18:38:12 CET 2023 x86_64

     This is gentoo-desktop (Linux x86_64 6.1.67-gentoo-custom) 18:08:52

     DISTRIB_ID="Gentoo"
     Running under: `X11Frozen:` False
     `Paths:  kitty:` /usr/bin/kitty
     `  base dir:` /usr/lib64/kitty
     `  extensions dir:` /usr/lib64/kitty/kitty
     `  system shell:` /bin/zsh
     `Loaded config files:`
       /home/xfzv/.config/kitty/kitty.conf

     Config options different from defaults:
     allow_remote_control       yes
     bell_path                  /usr/share/sounds/freedesktop/stereo/service-login.oga
     bold_font                  JetBrainsMono NF Bold
     bold_italic_font           JetBrainsMono NF Bold Italic
     close_on_child_death       True
     copy_on_select             clipboard
     cursor                     None
     cursor_beam_thickness      1.0
     cursor_shape               2
     cursor_stop_blinking_after 0
     disable_ligatures          1
     enabled_layouts            ['splits']
     font_family                JetBrainsMono NF Medium
     font_size                  10.5
     italic_font                JetBrainsMono NF Italic
     listen_on                  unix:/tmp/kitty
     `modify_font:`
         underline_position 18
         underline_thickness 1
     mouse_hide_wait            0.0
     paste_actions              frozenset({'quote-urls-at-prompt'})
     selection_background       None
     selection_foreground       None
     shell_integration          frozenset({'enabled'})
     strip_trailing_spaces      smart
     tab_bar_edge               1
     tab_bar_margin_height      TabBarMarginHeight(outer=1.0, inner=1.0)
     tab_bar_margin_width       1.0
     tab_bar_style              powerline
     tab_powerline_style        slanted
     url_style                  1
     visual_bell_duration       1.5
     window_margin_width        FloatEdges(left=1.0, top=1.0, right=1.0, bottom=1.0)
     window_padding_width       FloatEdges(left=1.0, top=1.0, right=1.0, bottom=1.0)
     `Added mouse actions:`
        ctrl+left release grabbed →  mouse_handle_click link
        ctrl+left release ungrabbed →  mouse_handle_click link
     `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:`
        alt+0x01000000 →  scroll_page_down
        alt+end →  scroll_end
        alt+home →  scroll_home
        ctrl+c →  copy_or_interrupt
        ctrl+kp_add →  change_font_size all +2.0
        ctrl+kp_subtract →  change_font_size all -2.0
        ctrl+v →  paste_from_clipboard
        ctrl+w →  close_tab
        f2 →  set_tab_title
     `Changed shortcuts:`
        kitty_mod+g →  kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
        kitty_mod+h →  kitty_scrollback_nvim
        kitty_mod+j →  move_tab_forward
        kitty_mod+k →  move_tab_backward
        kitty_mod+w →  detach_tab
     `Colors`:
        active_border_color        #a6e3a1
        active_tab_background      #505052
        active_tab_foreground      #cdd6f4
        background                 #1e1e20
        color0                     #45475a
        color1                     #f38ba8
        color10                    #a6e3a1
        color11                    #f9e2af
        color12                    #89b4fa
        color13                    #b4befe
        color14                    #94e2d5
        color15                    #a6adc8
        color2                     #a6e3a1
        color3                     #f9e2af
        color4                     #89b4fa
        color5                     #b4befe
        color6                     #94e2d5
        color7                     #bac2de
        color8                     #585b70
        color9                     #f38ba8
        foreground                 #cdd6f4
        inactive_border_color      #a6adc8
        inactive_tab_background    #262626
        inactive_tab_foreground    #cdd6f4
        url_color                  #89b4fa

     `Important environment variables seen by the kitty process:`
        PATH                                `/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/16/bin`
        LANG                                `en_US.UTF-8`
        EDITOR                              `/bin/nano`
        SHELL                               `/bin/zsh`
        DISPLAY                             `:0`
        USER                                `xfzv`
        XDG_CONFIG_DIRS                     `/etc/xdg`
        LC_ADDRESS                          `en_US.UTF-8`
        LC_NAME                             `en_US.UTF-8`
        XDG_DATA_HOME                       `/home/xfzv/.local/share`
        XDG_CONFIG_HOME                     `/home/xfzv/.config`
        LC_MONETARY                         `en_US.UTF-8`
        XDG_SEAT                            `seat0`
        XDG_SESSION_TYPE                    `tty`
        LC_PAPER                            `en_US.UTF-8`
        XDG_CACHE_HOME                      `/home/xfzv/.cache`
        XDG_SESSION_CLASS                   `user`
        LC_IDENTIFICATION                   `en_US.UTF-8`
        LC_TELEPHONE                        `en_US.UTF-8`
        LC_MESSAGES                         `en_US.UTF-8`
        LC_MEASUREMENT                      `en_US.UTF-8`
        XDG_VTNR                            `1`
        XDG_SESSION_ID                      `1`
        XDG_STATE_HOME                      `/home/xfzv/.local/state`
        XDG_RUNTIME_DIR                     `/run/user/1000`
        LC_TIME                             `en_US.UTF-8`
        LC_COLLATE                          `C.UTF-8`
        XDG_DATA_DIRS                       `/usr/local/share:/usr/share`
        LC_NUMERIC                          `en_US.UTF-8`
mikesmithgh commented 9 months ago

@xfzv interesting. The footer is using the filetype help for the highlights. Can you try :TSInstall vim ?

I think it uses vim instead of vimdoc. To be honest, I am not sure what the difference is.

Edit: vimdoc is for help files, vim is for vimscript.

mikesmithgh commented 9 months ago

@xfzv how are you installing Neovim, are you building from source? I was able to reproduce by manually removing vimdoc.so in neovim/build/lib/nvim/parser/. (I build Neovim from source).

Edit: https://neovim.io/doc/user/treesitter.html#treesitter-parsers

By default, Nvim bundles parsers for C, Lua, Vimscript, Vimdoc and Treesitter query files

I think your Neovim build may be missing the standard vimdoc treesitter parser that is supposed to come bundled with it.

xfzv commented 8 months ago

how are you installing Neovim, are you building from source?

Yes, using the ebuilds from Gentoo repository. Turns out I don't have the error anymore after switching from 9999 (pretty much Git version) to 0.9.4.

Both ebuilds are almost identical, I have no idea why the issue only occurs with the Git version.

- KEYWORDS="amd64 ~arm arm64 ~ppc ~ppc64 ~riscv x86 ~x64-macos"
+ KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86 ~x64-macos"

- "${FILESDIR}/${PN}-0.9.1-cmake-darwin.patch"
- "${FILESDIR}/${PN}-0.9.0-cmake-release-type.patch"
+ "${FILESDIR}/${PN}-9999-cmake-darwin.patch"

src_configure() {
+ ln -s "${BROOT}"/usr/bin/luajit "${BUILD_DIR}"/luajit || die

Well, feel free to close. As always, thank you for your help! :+1:


Edit: I found https://github.com/neovim/neovim/issues/26379, maybe related

However, rebuilding Neovim with either -DUSE_BUNDLED=OFF or -DUSE_BUNDLED=ON doesn't make any difference:

src_configure() {
    ln -s "${BROOT}"/usr/bin/luajit "${BUILD_DIR}"/luajit || die
    # Upstream default to LTO on non-debug builds
    # Let's expose it as a USE flag because upstream
    # have preferences for how we should use LTO
    # if we want it on (not just -flto)
    # ... but allow turning it off.
    # TODO: Investigate USE_BUNDLED, doesn't seem to be needed right now
    local mycmakeargs=(
+               -DUSE_BUNDLED=OFF
# or
+               -DUSE_BUNDLED=ON
        -DENABLE_LTO=$(usex lto)
        -DPREFER_LUA=$(usex lua_single_target_luajit no "$(lua_get_version)")
        -DLUA_PRG="${ELUA}"
    )
    cmake_src_configure
}
mikesmithgh commented 8 months ago

Edit: I found neovim/neovim#26379, maybe related

@xfzv good find! I subscribed to that issue. I'll keep this open for a little while in case anyone else has something similar 👍.

mikesmithgh commented 8 months ago

Note: I just saw this on the nightly CI build.

E5113: Error while calling lua chunk: ...ghtly/share/nvim/runtime/lua/vim/treesitter/language.lua:103: no parser for 'vimdoc' language, see :help treesitter-parsers

https://github.com/mikesmithgh/kitty-scrollback.nvim/actions/runs/7601066405

mikesmithgh commented 5 months ago

Closing this bug. https://github.com/neovim/neovim/issues/26379 is closed as completed in https://github.com/neovim/neovim/pull/28226

xfzv commented 5 months ago

Thanks for the heads-up!

I guess installing tree-sitter-vimdoc should be enough to get rid of the error. It doesn't seem to be available on Gentoo though, so I can't try.

xfzv commented 2 months ago

Sorry for the bump but I'm still getting the error on both Gentoo and Arch Linux with different Neovim versions. vimdoc parser is installed:

% cat /etc/os-release | head -n 3
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch

% nvim -v
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1720049189

% pacman -Q | rg tree-sitter
tree-sitter 0.22.6-1
tree-sitter-bash 0.21.0-2
tree-sitter-c 0.21.4-1
tree-sitter-lua 0.1.0-2
tree-sitter-markdown 0.2.3-2
tree-sitter-python 0.21.0-2
tree-sitter-query 0.3.0-1
tree-sitter-vimdoc 3.0.0-1
% cat /etc/os-release | head -n 3
NAME=Gentoo
ID=gentoo
PRETTY_NAME="Gentoo Linux"

% nvim -v
NVIM v0.11.0-dev-450+g05dcda8f9-dirty
Build type: Release
LuaJIT 2.1.1716656478

% :checkhealth nvim-treesitter:

[..]

Parser/Features         H L F I J

  - vimdoc              ✓ . . . ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

Any idea?

mikesmithgh commented 2 months ago

Hey @xfzv, I'll try and see if I can play around a bit to reproduce. I'm on a Mac so I'll probably use UTM to install Gentoo. I've been a little busy of late so may take a few days to get around to it. Thanks!

xfzv commented 1 month ago
% nvim -v
NVIM v0.11.0-dev-561+g7d24c4d6b-dirty

I noticed I'm now getting a different error instead:

Error in decoration provider treesitter/highlighter.win:
Error executing lua: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 2:4. Invalid node type "delimiter":
  (delimiter) @markup.heading.1
   ^

stack traceback:
        [C]: in function '_ts_parse_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
        /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'
        /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'get'
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:28: in function 'new'
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:243: in function 'get_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:191: in function 'fn'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:473: in function 'for_each_tree'
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:178: in function 'prepare_highlight_states'
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:405: in functi

Can't seem to be able to see the rest. Maybe that helps!

mikesmithgh commented 1 month ago

@xfzv thanks for the additional info! I'll try to carve out some time to investigate this. Feel free to post more info as you find it.

xfzv commented 1 month ago

The issue is finally solved for me. :tada:

app-editors/neovim-9999 ebuild was updated a few days ago. Bumping dev-libs/tree-sitter-query and dev-libs/tree-sitter-vimdoc versions did the trick, no more errors:

- =dev-libs/tree-sitter-query-0.3*
+ =dev-libs/tree-sitter-query-0.4*

- =dev-libs/tree-sitter-vimdoc-2*
+ =dev-libs/tree-sitter-vimdoc-3*
mikesmithgh commented 1 month ago

@xfzv awesome! I actually tried installing arch on UTM yesterday and couldn't figure out how to get a desktop environment working :joy: so I'm glad it is sorted out