fix(scraper): relative python module import path

This commit is contained in:
Barrett Ruth 2025-09-19 20:55:06 -04:00
parent b12844c3a0
commit 514761733b
4 changed files with 62 additions and 55 deletions

View file

@ -10,7 +10,6 @@
local M = {}
---Parse git diff markers and extract highlight information
---@param text string Raw git diff output line
---@return string cleaned_text, DiffHighlight[]
local function parse_diff_line(text)
@ -52,7 +51,6 @@ local function parse_diff_line(text)
return result_text, highlights
end
---Parse complete git diff output
---@param diff_output string
---@return ParsedDiff
function M.parse_git_diff(diff_output)
@ -64,10 +62,8 @@ function M.parse_git_diff(diff_output)
local content_lines = {}
local all_highlights = {}
-- Skip git diff header lines
local content_started = false
for _, line in ipairs(lines) do
-- Skip header lines (@@, +++, ---, index, etc.)
if
content_started
or (
@ -80,33 +76,27 @@ function M.parse_git_diff(diff_output)
then
content_started = true
-- Process content lines
if line:match('^%+') then
-- Added line - remove + prefix and parse highlights
local clean_line = line:sub(2) -- Remove + prefix
local clean_line = line:sub(2)
local parsed_line, line_highlights = parse_diff_line(clean_line)
table.insert(content_lines, parsed_line)
-- Set line numbers for highlights
local line_num = #content_lines
for _, highlight in ipairs(line_highlights) do
highlight.line = line_num - 1 -- 0-based for extmarks
highlight.line = line_num - 1
table.insert(all_highlights, highlight)
end
elseif not line:match('^%-') and not line:match('^\\') then -- Skip removed lines and "\ No newline" messages
-- Word-diff content line or unchanged line
elseif not line:match('^%-') and not line:match('^\\') then
local clean_line = line:match('^%s') and line:sub(2) or line
local parsed_line, line_highlights = parse_diff_line(clean_line)
-- Only add non-empty lines
if parsed_line ~= '' then
table.insert(content_lines, parsed_line)
-- Set line numbers for highlights
local line_num = #content_lines
for _, highlight in ipairs(line_highlights) do
highlight.line = line_num - 1 -- 0-based for extmarks
highlight.line = line_num - 1
table.insert(all_highlights, highlight)
end
end
@ -120,12 +110,10 @@ function M.parse_git_diff(diff_output)
}
end
---Apply highlights to a buffer using extmarks
---@param bufnr number
---@param highlights DiffHighlight[]
---@param namespace number
function M.apply_highlights(bufnr, highlights, namespace)
-- Clear existing highlights in this namespace
vim.api.nvim_buf_clear_namespace(bufnr, namespace, 0, -1)
for _, highlight in ipairs(highlights) do
@ -139,13 +127,11 @@ function M.apply_highlights(bufnr, highlights, namespace)
end
end
---Create namespace for diff highlights
---@return number
function M.create_namespace()
return vim.api.nvim_create_namespace('cp_diff_highlights')
end
---Parse and apply git diff to buffer
---@param bufnr number
---@param diff_output string
---@param namespace number