Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove shell integration validation #71

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/kitty-scrollback.nvim.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*kitty-scrollback.nvim.txt* For NVIM v0.9+ Last change: 2023 November 26
*kitty-scrollback.nvim.txt* For NVIM v0.9+ Last change: 2023 November 27

==============================================================================
Table of Contents *kitty-scrollback.nvim-table-of-contents*
Expand Down
44 changes: 0 additions & 44 deletions lua/kitty-scrollback/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,6 @@ local function check_clipboard()
end
end

local function check_kitty_shell_integration()
vim.health.start('kitty-scrollback: Kitty shell integration')
if not next(p or {}) then
vim.health.error('No Kitty data')
return
end
-- use last_cmd_output because it is valid and requires shell integration
if M.is_valid_extent_keyword('last_cmd_output') then
vim.health.ok('Kitty shell integration is enabled')
else
vim.health.warn(
'Kitty shell integration is disabled and/or `no-prompt-mark` is set.\n Some functionality will not work when Kitty shell '
.. 'integration is disabled or `no-prompt-mark` is set, such as capturing the last command output.',
table.concat(M.advice().kitty_shell_integration, '\n')
)
end
end

local function check_sed()
vim.health.start('kitty-scrollback: sed')
local sed_path = vim.fn.exepath('sed')
Expand Down Expand Up @@ -288,7 +270,6 @@ M.check = function()
and M.check_kitty_version()
then
check_clipboard()
check_kitty_shell_integration()
check_sed()
check_kitty_debug_config()
end
Expand Down Expand Up @@ -376,29 +357,4 @@ M.advice = function()
}
end

---@param extent string
M.is_valid_extent_keyword = function(extent)
local valid = false

local standard = { 'screen', 'all', 'selection' }
local standard_extent = vim.tbl_filter(function(e)
return e == extent:lower()
end, standard)
if #standard_extent > 0 then
return true
end

local shell_integration = p.kitty_data.kitty_opts.shell_integration
for _, keyword in pairs(shell_integration) do
local k = keyword:lower()
if k == 'disabled' or k == 'no-prompt-mark' then
return false
end
if k == 'enabled' then
valid = true
end
end
return valid
end

return M
36 changes: 0 additions & 36 deletions lua/kitty-scrollback/launch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -342,39 +342,6 @@ M.setup = function(kitty_data_str)
return true
end

local function validate_extent(extent)
if ksb_health.is_valid_extent_keyword(extent) then
return true
end
local msg = vim.list_extend({
'',
'==============================================================================',
'kitty-scrollback.nvim',
'',
'ERROR: Kitty shell integration is disabled and/or `no-prompt-mark` is set',
'',
'The option *'
.. opts.kitty_get_text.extent
.. '* requires Kitty shell integration and prompt marks to be enabled. ',
}, ksb_health.advice().kitty_shell_integration)
local error_bufid = vim.api.nvim_create_buf(false, true)
vim.o.conceallevel = 2
vim.o.concealcursor = 'n'
vim.api.nvim_set_option_value('filetype', 'checkhealth', {
buf = error_bufid,
})
local prompt_msg = 'kitty-scrollback.nvim: Fatal error, see logs.'
vim.api.nvim_set_current_buf(error_bufid)
vim.api.nvim_buf_set_lines(error_bufid, 0, -1, false, msg)
ksb_util.restore_and_redraw()
ksb_kitty_cmds.close_kitty_loading_window(true)
local response = vim.fn.confirm(prompt_msg, '&Quit\n&Continue')
if response ~= 2 then
ksb_kitty_cmds.signal_term_to_kitty_child_process()
end
return false
end

---Launch kitty-scrollack.nvim with configured scrollback buffer
M.launch = function()
local kitty_data = p.kitty_data
Expand All @@ -395,9 +362,6 @@ M.launch = function()

local extent = '--extent=all'
local extent_opt = opts.kitty_get_text.extent
if not validate_extent(extent_opt or 'all') then
return
end
if extent_opt then
extent = '--extent=' .. extent_opt
end
Expand Down