fix: decouple python env setup from config init
Problem: setup_python_env() is called from check_required_runtime() during config.setup(), which runs on the very first :CP command. The uv sync and nix build calls use vim.system():wait(), blocking the Neovim event loop. During the block the UI is frozen and vim.schedule-based log messages never render, so the user sees an unresponsive editor with no feedback. Solution: remove setup_python_env() from check_required_runtime() so config init is instant. Call it lazily from run_scraper() instead, only when a scraper subprocess is actually needed. Use vim.notify + vim.cmd.redraw() before blocking calls so the notification renders immediately via a forced screen repaint, rather than being queued behind vim.schedule.
This commit is contained in:
parent
622620f6d0
commit
49e4233b3f
2 changed files with 13 additions and 5 deletions
|
|
@ -25,6 +25,15 @@ end
|
|||
---@param args string[]
|
||||
---@param opts { sync?: boolean, ndjson?: boolean, on_event?: fun(ev: table), on_exit?: fun(result: table) }
|
||||
local function run_scraper(platform, subcommand, args, opts)
|
||||
if not utils.setup_python_env() then
|
||||
local msg = 'no Python environment available (install uv or nix)'
|
||||
logger.log(msg, vim.log.levels.ERROR)
|
||||
if opts and opts.on_exit then
|
||||
opts.on_exit({ success = false, error = msg })
|
||||
end
|
||||
return { success = false, error = msg }
|
||||
end
|
||||
|
||||
local plugin_path = utils.get_plugin_path()
|
||||
local cmd = utils.get_python_cmd(platform, plugin_path)
|
||||
vim.list_extend(cmd, { subcommand })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue