File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11local document = require (" image/utils/document" )
2+ local magic = require (" image/utils/magic" )
23
34return document .create_document_integration ({
45 name = " org" ,
@@ -18,9 +19,8 @@ return document.create_document_integration({
1819
1920 local images = {}
2021 local query = vim .treesitter .query .parse (' org' , [[
21- (link_desc
22- url: (expr) @image_link
23- (#match? @image_link "^(file:)?[^ ]+\\.(png|jpe?g|gif|webp)$"))
22+ (link_desc url: (expr) @image_link)
23+ (link url: (expr) @image_link)
2424 ]] )
2525
2626 for _ , node in query :iter_captures (root , bufnr ) do
@@ -30,20 +30,22 @@ return document.create_document_integration({
3030 local srcfile_abspath = vim .api .nvim_buf_get_name (0 )
3131 local base_dir = vim .fn .fnamemodify (srcfile_abspath , " :h" )
3232 local abspath = vim .fn .fnamemodify (base_dir .. " /" .. relpath , " :p" )
33- local start_row , start_col , end_row , end_col = node :range ()
34- table.insert (
35- images ,
36- {
37- node = node ,
38- range = {
39- start_row = start_row ,
40- start_col = start_col ,
41- end_row = end_row ,
42- end_col = end_col ,
43- },
44- url = abspath ,
45- }
46- )
33+ if magic .is_image (abspath ) then
34+ local start_row , start_col , end_row , end_col = node :range ()
35+ table.insert (
36+ images ,
37+ {
38+ node = node ,
39+ range = {
40+ start_row = start_row ,
41+ start_col = start_col ,
42+ end_row = end_row ,
43+ end_col = end_col ,
44+ },
45+ url = abspath ,
46+ }
47+ )
48+ end
4749 end
4850 end
4951
You can’t perform that action at this time.
0 commit comments