diff --git a/.github/workflows/vimdocs.yml b/.github/workflows/vimdocs.yml index 0d5b877b..396db95e 100644 --- a/.github/workflows/vimdocs.yml +++ b/.github/workflows/vimdocs.yml @@ -35,7 +35,7 @@ jobs: with: vimdoc: kitty-scrollback.nvim pandoc: "tmp_vimdoc_workdir/README.md" - version: "NVIM v0.10+" + version: "NVIM v0.9+" toc: true demojify: true dedupsubheadings: false diff --git a/README.md b/README.md index af8feaec..6e989ba7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Navigate your Kitty scrollback buffer to quickly search, copy, and execute comma -[![neovim: v0.10+](https://img.shields.io/static/v1?style=flat-square&label=neovim&message=v0.10%2b&logo=neovim&labelColor=282828&logoColor=8faa80&color=414b32)](https://neovim.io/) +[![neovim: v0.9+](https://img.shields.io/static/v1?style=flat-square&label=neovim&message=v0.9%2b&logo=neovim&labelColor=282828&logoColor=8faa80&color=414b32)](https://neovim.io/) [![kitty v0.29+](https://img.shields.io/badge/v0.29%2B-352217?style=flat-square&logo=data%3Aimage%2Fjpeg%3Bbase64%2C%2F9j%2F4AAQSkZJRgABAQAAAQABAAD%2F4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9Y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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH%2F9k%3D&label=kitty&labelColor=282828)](https://sw.kovidgoyal.net/kitty/) [![semantic-release: angular](https://img.shields.io/static/v1?style=flat-square&label=semantic-release&message=angular&logo=semantic-release&labelColor=282828&logoColor=d8869b&color=8f3f71)](https://github.com/semantic-release/semantic-release) @@ -187,7 +187,7 @@ Navigate your Kitty scrollback buffer to quickly search, copy, and execute comma ## 📚 Prerequisites -- Neovim [v0.10+](https://github.com/neovim/neovim/releases) +- Neovim [v0.9+](https://github.com/neovim/neovim/releases) - Kitty [v0.29+](https://github.com/kovidgoyal/kitty/releases) ## 🏃 Quickstart diff --git a/doc/kitty-scrollback.nvim.txt b/doc/kitty-scrollback.nvim.txt index 8682cd43..bd3974c3 100644 --- a/doc/kitty-scrollback.nvim.txt +++ b/doc/kitty-scrollback.nvim.txt @@ -1,4 +1,4 @@ -*kitty-scrollback.nvim.txt* For NVIM v0.10+ Last change: 2023 November 23 +*kitty-scrollback.nvim.txt* For NVIM v0.9+ Last change: 2023 November 24 ============================================================================== Table of Contents *kitty-scrollback.nvim-table-of-contents* @@ -162,7 +162,7 @@ EXAMPLE USE CASES *kitty-scrollback.nvim-example-use-cases* PREREQUISITES *kitty-scrollback.nvim-prerequisites* -- Neovim v0.10+ +- Neovim v0.9+ - Kitty v0.29+ diff --git a/lua/kitty-scrollback/api.lua b/lua/kitty-scrollback/api.lua index 76e7e95c..7dd9316f 100644 --- a/lua/kitty-scrollback/api.lua +++ b/lua/kitty-scrollback/api.lua @@ -183,7 +183,12 @@ end M.checkhealth = function() local kitty_scrollback_kitten = vim.api.nvim_get_runtime_file('python/kitty_scrollback_nvim.py', false)[1] - if vim.fn.has('nvim-0.10') > 0 then + -- NOTE(#58): nvim v0.9 support + -- setup backports for v0.9 because checkhealth can be called outside of standard setup flow + if vim.fn.has('nvim-0.10') <= 0 then + require('kitty-scrollback.backport').setup() + end + if vim.fn.has('nvim-0.9') > 0 then vim .system({ 'kitty', diff --git a/lua/kitty-scrollback/backport/README.md b/lua/kitty-scrollback/backport/README.md new file mode 100644 index 00000000..a5fc86ac --- /dev/null +++ b/lua/kitty-scrollback/backport/README.md @@ -0,0 +1,10 @@ +# Backported functionality from v0.10 to v0.9 + +## Files +- runtime/lua/vim/_system.lua +- runtime/lua/vim/version.lua + +## Backport sha256s +- backport-sha.json contains the file and sha256 checksums at the time of copy +- TODO: add a cron to have a nightly check if these files changes in Neovim + diff --git a/lua/kitty-scrollback/backport/_system.lua b/lua/kitty-scrollback/backport/_system.lua new file mode 100644 index 00000000..75a689e5 --- /dev/null +++ b/lua/kitty-scrollback/backport/_system.lua @@ -0,0 +1,378 @@ +-- NOTE: copied from +-- https://github.com/neovim/neovim/blob/a8a93e517f9eb988ee86170d9a77382637dd24a3/runtime/lua/vim/_system.lua + +---@diagnostic disable +local uv = vim.uv + +--- @class SystemOpts +--- @field stdin? string|string[]|true +--- @field stdout? fun(err:string?, data: string?)|false +--- @field stderr? fun(err:string?, data: string?)|false +--- @field cwd? string +--- @field env? table +--- @field clear_env? boolean +--- @field text? boolean +--- @field timeout? integer Timeout in ms +--- @field detach? boolean + +--- @class vim.SystemCompleted +--- @field code integer +--- @field signal integer +--- @field stdout? string +--- @field stderr? string + +--- @class vim.SystemState +--- @field handle? uv.uv_process_t +--- @field timer? uv.uv_timer_t +--- @field pid? integer +--- @field timeout? integer +--- @field done? boolean|'timeout' +--- @field stdin? uv.uv_stream_t +--- @field stdout? uv.uv_stream_t +--- @field stderr? uv.uv_stream_t +--- @field stdout_data? string[] +--- @field stderr_data? string[] +--- @field result? vim.SystemCompleted + +--- @enum vim.SystemSig +local SIG = { + HUP = 1, -- Hangup + INT = 2, -- Interrupt from keyboard + KILL = 9, -- Kill signal + TERM = 15, -- Termination signal + -- STOP = 17,19,23 -- Stop the process +} + +---@param handle uv.uv_handle_t? +local function close_handle(handle) + if handle and not handle:is_closing() then + handle:close() + end +end + +---@param state vim.SystemState +local function close_handles(state) + close_handle(state.handle) + close_handle(state.stdin) + close_handle(state.stdout) + close_handle(state.stderr) + close_handle(state.timer) +end + +--- @class vim.SystemObj +--- @field pid integer +--- @field private _state vim.SystemState +--- @field wait fun(self: vim.SystemObj, timeout?: integer): vim.SystemCompleted +--- @field kill fun(self: vim.SystemObj, signal: integer|string) +--- @field write fun(self: vim.SystemObj, data?: string|string[]) +--- @field is_closing fun(self: vim.SystemObj): boolean? +local SystemObj = {} + +--- @param state vim.SystemState +--- @return vim.SystemObj +local function new_systemobj(state) + return setmetatable({ + pid = state.pid, + _state = state, + }, { __index = SystemObj }) +end + +--- @param signal integer|string +function SystemObj:kill(signal) + self._state.handle:kill(signal) +end + +--- @package +--- @param signal? vim.SystemSig +function SystemObj:_timeout(signal) + self._state.done = 'timeout' + self:kill(signal or SIG.TERM) +end + +local MAX_TIMEOUT = 2 ^ 31 + +--- @param timeout? integer +--- @return vim.SystemCompleted +function SystemObj:wait(timeout) + local state = self._state + + local done = vim.wait(timeout or state.timeout or MAX_TIMEOUT, function() + return state.result ~= nil + end) + + if not done then + -- Send sigkill since this cannot be caught + self:_timeout(SIG.KILL) + vim.wait(timeout or state.timeout or MAX_TIMEOUT, function() + return state.result ~= nil + end) + end + + return state.result +end + +--- @param data string[]|string|nil +function SystemObj:write(data) + local stdin = self._state.stdin + + if not stdin then + error('stdin has not been opened on this object') + end + + if type(data) == 'table' then + for _, v in ipairs(data) do + stdin:write(v) + stdin:write('\n') + end + elseif type(data) == 'string' then + stdin:write(data) + elseif data == nil then + -- Shutdown the write side of the duplex stream and then close the pipe. + -- Note shutdown will wait for all the pending write requests to complete + -- TODO(lewis6991): apparently shutdown doesn't behave this way. + -- (https://github.com/neovim/neovim/pull/17620#discussion_r820775616) + stdin:write('', function() + stdin:shutdown(function() + if stdin then + stdin:close() + end + end) + end) + end +end + +--- @return boolean +function SystemObj:is_closing() + local handle = self._state.handle + return handle == nil or handle:is_closing() +end + +---@param output fun(err:string?, data: string?)|false +---@return uv.uv_stream_t? +---@return fun(err:string?, data: string?)? Handler +local function setup_output(output) + if output == nil then + return assert(uv.new_pipe(false)), nil + end + + if type(output) == 'function' then + return assert(uv.new_pipe(false)), output + end + + assert(output == false) + return nil, nil +end + +---@param input string|string[]|true|nil +---@return uv.uv_stream_t? +---@return string|string[]? +local function setup_input(input) + if not input then + return + end + + local towrite --- @type string|string[]? + if type(input) == 'string' or type(input) == 'table' then + towrite = input + end + + return assert(uv.new_pipe(false)), towrite +end + +--- @return table +local function base_env() + local env = vim.fn.environ() --- @type table + env['NVIM'] = vim.v.servername + env['NVIM_LISTEN_ADDRESS'] = nil + return env +end + +--- uv.spawn will completely overwrite the environment +--- when we just want to modify the existing one, so +--- make sure to prepopulate it with the current env. +--- @param env? table +--- @param clear_env? boolean +--- @return string[]? +local function setup_env(env, clear_env) + if clear_env then + return env + end + + --- @type table + env = vim.tbl_extend('force', base_env(), env or {}) + + local renv = {} --- @type string[] + for k, v in pairs(env) do + renv[#renv + 1] = string.format('%s=%s', k, tostring(v)) + end + + return renv +end + +--- @param stream uv.uv_stream_t +--- @param text? boolean +--- @param bucket string[] +--- @return fun(err: string?, data: string?) +local function default_handler(stream, text, bucket) + return function(err, data) + if err then + error(err) + end + if data ~= nil then + if text then + bucket[#bucket + 1] = data:gsub('\r\n', '\n') + else + bucket[#bucket + 1] = data + end + else + stream:read_stop() + stream:close() + end + end +end + +local M = {} + +--- @param cmd string +--- @param opts uv.spawn.options +--- @param on_exit fun(code: integer, signal: integer) +--- @param on_error fun() +--- @return uv.uv_process_t, integer +local function spawn(cmd, opts, on_exit, on_error) + local handle, pid_or_err = uv.spawn(cmd, opts, on_exit) + if not handle then + on_error() + error(pid_or_err) + end + return handle, pid_or_err --[[@as integer]] +end + +---@param timeout integer +---@param cb fun() +---@return uv.uv_timer_t +local function timer_oneshot(timeout, cb) + local timer = assert(uv.new_timer()) + timer:start(timeout, 0, function() + timer:stop() + timer:close() + cb() + end) + return timer +end + +--- @param state vim.SystemState +--- @param code integer +--- @param signal integer +--- @param on_exit fun(result: vim.SystemCompleted)? +local function _on_exit(state, code, signal, on_exit) + close_handles(state) + + local check = assert(uv.new_check()) + check:start(function() + for _, pipe in pairs({ state.stdin, state.stdout, state.stderr }) do + if not pipe:is_closing() then + return + end + end + check:stop() + check:close() + + if state.done == nil then + state.done = true + end + + if (code == 0 or code == 1) and state.done == 'timeout' then + -- Unix: code == 0 + -- Windows: code == 1 + code = 124 + end + + local stdout_data = state.stdout_data + local stderr_data = state.stderr_data + + state.result = { + code = code, + signal = signal, + stdout = stdout_data and table.concat(stdout_data) or nil, + stderr = stderr_data and table.concat(stderr_data) or nil, + } + + if on_exit then + on_exit(state.result) + end + end) +end + +--- Run a system command +--- +--- @param cmd string[] +--- @param opts? SystemOpts +--- @param on_exit? fun(out: vim.SystemCompleted) +--- @return vim.SystemObj +function M.run(cmd, opts, on_exit) + vim.validate({ + cmd = { cmd, 'table' }, + opts = { opts, 'table', true }, + on_exit = { on_exit, 'function', true }, + }) + + opts = opts or {} + + local stdout, stdout_handler = setup_output(opts.stdout) + local stderr, stderr_handler = setup_output(opts.stderr) + local stdin, towrite = setup_input(opts.stdin) + + --- @type vim.SystemState + local state = { + done = false, + cmd = cmd, + timeout = opts.timeout, + stdin = stdin, + stdout = stdout, + stderr = stderr, + } + + --- @diagnostic disable-next-line:missing-fields + state.handle, state.pid = spawn(cmd[1], { + args = vim.list_slice(cmd, 2), + stdio = { stdin, stdout, stderr }, + cwd = opts.cwd, + --- @diagnostic disable-next-line:assign-type-mismatch + env = setup_env(opts.env, opts.clear_env), + detached = opts.detach, + hide = true, + }, function(code, signal) + _on_exit(state, code, signal, on_exit) + end, function() + close_handles(state) + end) + + if stdout then + state.stdout_data = {} + stdout:read_start(stdout_handler or default_handler(stdout, opts.text, state.stdout_data)) + end + + if stderr then + state.stderr_data = {} + stderr:read_start(stderr_handler or default_handler(stderr, opts.text, state.stderr_data)) + end + + local obj = new_systemobj(state) + + if towrite then + obj:write(towrite) + obj:write(nil) -- close the stream + end + + if opts.timeout then + state.timer = timer_oneshot(opts.timeout, function() + if state.handle and state.handle:is_active() then + obj:_timeout() + end + end) + end + + return obj +end + +return M diff --git a/lua/kitty-scrollback/backport/backport-sha.json b/lua/kitty-scrollback/backport/backport-sha.json new file mode 100644 index 00000000..b66534e8 --- /dev/null +++ b/lua/kitty-scrollback/backport/backport-sha.json @@ -0,0 +1,4 @@ +{ + "runtime/lua/vim/_system.lua": "9e8813381da9093060dfd09065499e87ac23d673a7fa53a52b6e6dfac0cd6e7e", + "runtime/lua/vim/version.lua": "d94c6888586745fb04b76037db70d5bf82e0d2a376d2e3e18bc0e162f421857d" +} diff --git a/lua/kitty-scrollback/backport.lua b/lua/kitty-scrollback/backport/init.lua similarity index 69% rename from lua/kitty-scrollback/backport.lua rename to lua/kitty-scrollback/backport/init.lua index 05e4524c..299474b0 100644 --- a/lua/kitty-scrollback/backport.lua +++ b/lua/kitty-scrollback/backport/init.lua @@ -1,3 +1,6 @@ +---@mod kitty-scrollback.backport +-- NOTE(#58): nvim v0.9 support + local ksb_health = require('kitty-scrollback.health') local M = {} @@ -19,6 +22,9 @@ local function backport_version() return ret end + if type(vim.version) == 'function' then -- nvim 0.8 vim.version is a table instead of function + vim.version = vim.version() + end setmetatable(vim.version, { --- Returns the current Nvim version. __call = function() @@ -39,12 +45,32 @@ local function backport_health() vim.health.error = vim.health.error or vim.health.report_error end +local function backport_uv() + if not vim.uv then + vim.uv = vim.loop + end +end + +local function backport_system() + -- copied from _editor.lua + ---@diagnostic disable-next-line: duplicate-set-field + vim.system = function(cmd, opts, on_exit) + if type(opts) == 'function' then + on_exit = opts + opts = nil + end + return require('kitty-scrollback.backport._system').run(cmd, opts, on_exit) + end +end + M.setup = function() + backport_uv() + backport_health() if ksb_health.check_nvim_version('nvim-0.10', true) then return end backport_version() - backport_health() + backport_system() end return M diff --git a/lua/kitty-scrollback/health.lua b/lua/kitty-scrollback/health.lua index b3159f8a..5bf44057 100644 --- a/lua/kitty-scrollback/health.lua +++ b/lua/kitty-scrollback/health.lua @@ -179,7 +179,7 @@ end M.check_nvim_version = function(version, check_only) if not check_only then - vim.health.start('kitty-scrollback: Neovim version 0.10+') + vim.health.start('kitty-scrollback: Neovim version 0.9+') end local nvim_version = 'NVIM ' .. tostring(vim.version()) if vim.fn.has(version) > 0 then @@ -281,7 +281,7 @@ end M.check = function() if - M.check_nvim_version('nvim-0.10') -- always check first to avoid undefined calls in versions < 0.10 + M.check_nvim_version('nvim-0.9') and check_kitty_scrollback_nvim_version() and check_kitty_remote_control() and check_has_kitty_data() @@ -318,7 +318,7 @@ M.advice = function() end return { nvim_version = { - 'Neovim version 0.10 or greater is required to work with kitty-scrollback.nvim', + 'Neovim version 0.9 or greater is required to work with kitty-scrollback.nvim', }, kitty_version = { 'Kitty version 0.29 or greater is required to work with kitty-scrollback.nvim', diff --git a/lua/kitty-scrollback/kitty_commands.lua b/lua/kitty-scrollback/kitty_commands.lua index 46f870ff..814dc993 100644 --- a/lua/kitty-scrollback/kitty_commands.lua +++ b/lua/kitty-scrollback/kitty_commands.lua @@ -345,6 +345,10 @@ M.send_text_to_clipboard = function(text) end M.try_detect_nerd_font = function() + -- setup backports for v0.9 because try_detect_nerd_font can be called outside of standard setup flow + if vim.fn.has('nvim-0.10') <= 0 then + require('kitty-scrollback.backport').setup() + end local has_nerd_font = false vim .system({ diff --git a/lua/kitty-scrollback/launch.lua b/lua/kitty-scrollback/launch.lua index a69ced13..bc5701d2 100644 --- a/lua/kitty-scrollback/launch.lua +++ b/lua/kitty-scrollback/launch.lua @@ -277,7 +277,7 @@ M.setup = function(kitty_data_str) vim.cmd.checkhealth('kitty-scrollback') return end - if not ksb_health.check_nvim_version('nvim-0.10', true) then + if not ksb_health.check_nvim_version('nvim-0.9', true) then local prompt_msg = 'kitty-scrollback.nvim: Fatal error, on version NVIM ' .. tostring(vim.version()) .. '. ' diff --git a/scripts/dev_generate_vimdocs.sh b/scripts/dev_generate_vimdocs.sh index 75d976ed..b5904b67 100755 --- a/scripts/dev_generate_vimdocs.sh +++ b/scripts/dev_generate_vimdocs.sh @@ -10,7 +10,7 @@ sed -E -e's/\[!(NOTE|WARNING|IMPORTANT)\].*/[!\1]\n>/Ig' -e 's/.*(.+)<\ -e 's/(.+)<\/a>/\2 <\1>/g' tmp_vimdoc_workdir/README.md # panvimdoc -~/gitrepos/panvimdoc/panvimdoc.sh --project-name kitty-scrollback.nvim --input-file tmp_vimdoc_workdir/README.md --demojify true --vim-version 'NVIM v0.10+' --toc true --dedup-subheadings false --treesitter true +~/gitrepos/panvimdoc/panvimdoc.sh --project-name kitty-scrollback.nvim --input-file tmp_vimdoc_workdir/README.md --demojify true --vim-version 'NVIM v0.9+' --toc true --dedup-subheadings false --treesitter true # postformat kitty-scrollback.nvim.txt