Skip to content

Commit 1618039

Browse files
lambdalisueclaude
andcommitted
Fix deno task gen for Neovim 0.11+
Neovim 0.11+ removed builtin.txt and eval.txt files. Add fallback support to use vimfn.txt and vimeval.txt respectively for newer versions while maintaining backward compatibility. Fixes vim-denops/denops.vim#459 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f5303fd commit 1618039

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

.scripts/gen-function/gen-function.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,26 @@ const vimHelpDownloadUrls = [
4141
`https://raw.githubusercontent.com/vim/vim/v${VIM_VERSION}/runtime/doc/testing.txt`,
4242
`https://raw.githubusercontent.com/vim/vim/v${VIM_VERSION}/runtime/doc/textprop.txt`,
4343
];
44-
for (const vimHelpDownloadUrl of vimHelpDownloadUrls) {
45-
console.log(`Download from ${vimHelpDownloadUrl}`);
46-
}
4744
const vimHelps = await Promise.all(vimHelpDownloadUrls.map(downloadString));
4845
const vimDefs = parse(vimHelps.join("\n"));
4946
const vimFnSet = new Set(vimDefs.map((def) => def.fn)).difference(manualFnSet);
5047

5148
const nvimHelpDownloadUrls = [
5249
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/api.txt`,
53-
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/builtin.txt`,
54-
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/eval.txt`,
50+
[
51+
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/builtin.txt`,
52+
// Neovim 0.11+ removed "builtin.txt", but "vimfn.txt" seems to be equivalent.
53+
// https://github.com/neovim/neovim/pull/24493
54+
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/vimfn.txt`,
55+
],
56+
[
57+
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/eval.txt`,
58+
// Neovim 0.11+ removed "eval.txt", but "vimeval.txt" seems to be equivalent.
59+
// https://github.com/neovim/neovim/pull/24493
60+
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/vimeval.txt`,
61+
],
5562
`https://raw.githubusercontent.com/neovim/neovim/v${NVIM_VERSION}/runtime/doc/sign.txt`,
5663
];
57-
for (const nvimHelpDownloadUrl of nvimHelpDownloadUrls) {
58-
console.log(`Download from ${nvimHelpDownloadUrl}`);
59-
}
6064
const nvimHelps = await Promise.all(nvimHelpDownloadUrls.map(downloadString));
6165
const nvimDefs = parse(nvimHelps.join("\n"));
6266
const nvimFnSet = new Set(nvimDefs.map((def) => def.fn)).difference(

.scripts/utils.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ import { toText } from "@std/streams/to-text";
44
* Downloads a text file and returns the contents.
55
* Throws error if fetch fails.
66
*/
7-
export async function downloadString(url: string): Promise<string> {
8-
const response = await fetch(url);
9-
if (response.status >= 400 || !response.body) {
10-
throw new Error(`Failed to read ${url}`);
7+
export async function downloadString(urls: string | string[]): Promise<string> {
8+
urls = Array.isArray(urls) ? urls : [urls];
9+
for (const url of urls) {
10+
console.log(`Download from ${url}`);
11+
const response = await fetch(url);
12+
if (response.status >= 400 || !response.body) {
13+
console.debug(
14+
`Failed to download ${url}. Fallback to next URL if exists.`,
15+
);
16+
continue;
17+
}
18+
return await toText(response.body);
1119
}
12-
return await toText(response.body);
20+
throw new Error(`Failed to download from ${urls.join(", ")}`);
1321
}
1422

1523
/**

.scripts/utils_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ Deno.test(downloadString.name, async (t) => {
4747

4848
await t.step("Throws error if fetch fails", async () => {
4949
const url = "https://example.net/foo.ts";
50-
const expectedMessage = "Failed to read https://example.net/foo.ts";
50+
const expectedMessage =
51+
"Failed to download from https://example.net/foo.ts";
5152
await mockFetch({
5253
init: { status: 404 },
5354
async fn() {

0 commit comments

Comments
 (0)