diff --git a/lua/kitty-scrollback/kitty_commands.lua b/lua/kitty-scrollback/kitty_commands.lua index 7e4fbeb2..b75e61ba 100644 --- a/lua/kitty-scrollback/kitty_commands.lua +++ b/lua/kitty-scrollback/kitty_commands.lua @@ -63,7 +63,29 @@ local function defer_resize_term(min_cols) return orig_columns end -M.open_term_command = vim.fn.has('nvim-0.11') <= 0 and 'termopen' or 'jobstart' +local open_term_command_from_nvim_version = function() + if vim.fn.has('nvim-0.11') == 1 then + -- intentionally pass an invalid argument type to term + -- if an error is returned that it must be boolean then term exists for jobstart + ---@type boolean, integer|string + local ok, err = pcall(vim.fn.jobstart, '', { term = 1 }) + local jobstart_has_term = not ok + and err:match([[Vim:E475: Invalid argument: 'term' must be Boolean]]) + and true + or false + if jobstart_has_term then + return 'jobstart' + else + -- using Neovim v0.11, however, it is on a commit before implementing term on jobstart + return 'termopen' + end + else + -- earlier versions of Neovim use termopen + return 'termopen' + end +end + +M.open_term_command = open_term_command_from_nvim_version() ---@param get_text_opts KsbKittyGetTextArguments ---@param on_exit_cb function diff --git a/lua/kitty-scrollback/launch.lua b/lua/kitty-scrollback/launch.lua index 7de54cf6..db501a9f 100644 --- a/lua/kitty-scrollback/launch.lua +++ b/lua/kitty-scrollback/launch.lua @@ -421,36 +421,8 @@ M.launch = function() .. [[. Most likely `]] .. ksb_kitty_cmds.open_term_command .. [[` failed. ]], - [[]], - [[ If you are using Neovim nightly (NVIM v0.11), then you may need to update to the latest]], - [[ version of nightly. Please try updating Neovim to the latest version of nightly. If]], - [[ this error still occurs, then see if any additional help has been provided on the issue]], - [[ https://github.com/mikesmithgh/kitty-scrollback.nvim/issues/303.]], - [[]], - [[ If you are unable to update to a newer version of Neovim nightly, you can workaround ]], - [[ the problem by pinning kitty-scrollback.nvim to `v6.1.2`.]], - [[ ]], - [[ For example, if you are using lazy.nvim]], - [[>lua]], - [[ return {]], - [[ {]], - [[ 'mikesmithgh/kitty-scrollback.nvim',]], - [[ tag = 'v6.1.2',]], - [[ enabled = true,]], - [[ lazy = true,]], - [[ cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth', 'KittyScrollbackGenerateCommandLineEditing' },]], - [[ event = { 'User KittyScrollbackLaunch' },]], - [[ -- version = '*', -- latest stable version, may have breaking changes if major version changed]], - [[ -- version = '^6.0.0', -- pin major version, include fixes and features that do not have breaking changes]], - [[ config = function()]], - [[ require('kitty-scrollback').setup()]], - [[ end,]], - [[ },]], - [[ }]], - [[<]], - [[ If this is unrelated to issue #303, then create a new issue at ]], - [[ https://github.com/mikesmithgh/kitty-scrollback.nvim/issues and provide the ]], - [[ `KittyScrollbackCheckHealth` report.]], + [[ Please report the issue at https://github.com/mikesmithgh/kitty-scrollback.nvim/issues]], + [[ and provide the `KittyScrollbackCheckHealth` report.]], }) ksb_api.close_kitty_loading_window() if block_input_timer then