Skip to content

Commit 09b0acb

Browse files
committed
fix: add workaround for jobstart issues on nvim nightly (#305)
closes #303
1 parent f6b982e commit 09b0acb

File tree

2 files changed

+25
-31
lines changed

2 files changed

+25
-31
lines changed

lua/kitty-scrollback/kitty_commands.lua

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,29 @@ local function defer_resize_term(min_cols)
6363
return orig_columns
6464
end
6565

66-
M.open_term_command = vim.fn.has('nvim-0.11') <= 0 and 'termopen' or 'jobstart'
66+
local open_term_command_from_nvim_version = function()
67+
if vim.fn.has('nvim-0.11') == 1 then
68+
-- intentionally pass an invalid argument type to term
69+
-- if an error is returned that it must be boolean then term exists for jobstart
70+
---@type boolean, integer|string
71+
local ok, err = pcall(vim.fn.jobstart, '', { term = 1 })
72+
local jobstart_has_term = not ok
73+
and err:match([[Vim:E475: Invalid argument: 'term' must be Boolean]])
74+
and true
75+
or false
76+
if jobstart_has_term then
77+
return 'jobstart'
78+
else
79+
-- using Neovim v0.11, however, it is on a commit before implementing term on jobstart
80+
return 'termopen'
81+
end
82+
else
83+
-- earlier versions of Neovim use termopen
84+
return 'termopen'
85+
end
86+
end
87+
88+
M.open_term_command = open_term_command_from_nvim_version()
6789

6890
---@param get_text_opts KsbKittyGetTextArguments
6991
---@param on_exit_cb function

lua/kitty-scrollback/launch.lua

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -421,36 +421,8 @@ M.launch = function()
421421
.. [[. Most likely `]]
422422
.. ksb_kitty_cmds.open_term_command
423423
.. [[` failed. ]],
424-
[[]],
425-
[[ If you are using Neovim nightly (NVIM v0.11), then you may need to update to the latest]],
426-
[[ version of nightly. Please try updating Neovim to the latest version of nightly. If]],
427-
[[ this error still occurs, then see if any additional help has been provided on the issue]],
428-
[[ https://github.com/mikesmithgh/kitty-scrollback.nvim/issues/303.]],
429-
[[]],
430-
[[ If you are unable to update to a newer version of Neovim nightly, you can workaround ]],
431-
[[ the problem by pinning kitty-scrollback.nvim to `v6.1.2`.]],
432-
[[ ]],
433-
[[ For example, if you are using lazy.nvim]],
434-
[[>lua]],
435-
[[ return {]],
436-
[[ {]],
437-
[[ 'mikesmithgh/kitty-scrollback.nvim',]],
438-
[[ tag = 'v6.1.2',]],
439-
[[ enabled = true,]],
440-
[[ lazy = true,]],
441-
[[ cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth', 'KittyScrollbackGenerateCommandLineEditing' },]],
442-
[[ event = { 'User KittyScrollbackLaunch' },]],
443-
[[ -- version = '*', -- latest stable version, may have breaking changes if major version changed]],
444-
[[ -- version = '^6.0.0', -- pin major version, include fixes and features that do not have breaking changes]],
445-
[[ config = function()]],
446-
[[ require('kitty-scrollback').setup()]],
447-
[[ end,]],
448-
[[ },]],
449-
[[ }]],
450-
[[<]],
451-
[[ If this is unrelated to issue #303, then create a new issue at ]],
452-
[[ https://github.com/mikesmithgh/kitty-scrollback.nvim/issues and provide the ]],
453-
[[ `KittyScrollbackCheckHealth` report.]],
424+
[[ Please report the issue at https://github.com/mikesmithgh/kitty-scrollback.nvim/issues]],
425+
[[ and provide the `KittyScrollbackCheckHealth` report.]],
454426
})
455427
ksb_api.close_kitty_loading_window()
456428
if block_input_timer then

0 commit comments

Comments
 (0)