Skip to content

Commit 2758655

Browse files
committed
test if local docs exist before opening
fallback to web otherwise
1 parent 702ae4b commit 2758655

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/ferris/methods/open_documentation.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ local function open_documentation()
2020
return
2121
end
2222

23-
local url = response.result["local"] or response.result.web or response.result
23+
local url = response.result
24+
if url["web"] then
25+
local path = url["local"] and string.sub(url["local"], 7)
26+
if path and vim.uv.fs_stat(path) then
27+
url = url["local"]
28+
else
29+
url = url["web"]
30+
end
31+
end
2432

2533
if type(config.opts.url_handler) ~= "string" then
2634
config.opts.url_handler(url)

0 commit comments

Comments
 (0)