Skip to content

Commit 3b1ac53

Browse files
committed
feat: Copy files from vim-fall
1 parent 4248840 commit 3b1ac53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+4505
-0
lines changed

.github/workflows/jsr.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: jsr
2+
3+
env:
4+
DENO_VERSION: 2.x
5+
6+
on:
7+
push:
8+
tags:
9+
- "v*"
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- uses: denoland/setup-deno@v1
23+
with:
24+
deno-version: ${{ env.DENO_VERSION }}
25+
- name: Publish
26+
run: |
27+
deno run -A jsr:@david/[email protected]

.github/workflows/test.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
inputs:
10+
denops_branch:
11+
description: "Denops branch to test"
12+
required: false
13+
default: "main"
14+
15+
defaults:
16+
run:
17+
shell: bash --noprofile --norc -eo pipefail {0}
18+
19+
env:
20+
DENOPS_BRANCH: ${{ github.event.inputs.denops_branch || 'main' }}
21+
22+
jobs:
23+
check:
24+
strategy:
25+
matrix:
26+
runner:
27+
- ubuntu-latest
28+
deno_version:
29+
- "1.x"
30+
- "2.x"
31+
runs-on: ${{ matrix.runner }}
32+
steps:
33+
- run: git config --global core.autocrlf false
34+
if: runner.os == 'Windows'
35+
- uses: actions/checkout@v4
36+
- uses: denoland/[email protected]
37+
with:
38+
deno-version: "${{ matrix.deno_version }}"
39+
- uses: actions/cache@v4
40+
with:
41+
key: deno-${{ hashFiles('**/*') }}
42+
restore-keys: deno-
43+
path: |
44+
/home/runner/.cache/deno/deps/https/deno.land
45+
- name: Lint check
46+
run: deno lint
47+
- name: Format check
48+
run: deno fmt --check
49+
- name: Type check
50+
run: deno task check
51+
- name: Gen check
52+
run: |
53+
deno task gen
54+
git diff --exit-code
55+
56+
test:
57+
strategy:
58+
matrix:
59+
runner:
60+
- windows-latest
61+
- macos-latest
62+
- ubuntu-latest
63+
deno_version:
64+
- "1.x"
65+
- "2.x"
66+
host_version:
67+
- vim: "v9.1.0448"
68+
nvim: "v0.10.0"
69+
runs-on: ${{ matrix.runner }}
70+
timeout-minutes: 15
71+
steps:
72+
- run: git config --global core.autocrlf false
73+
if: runner.os == 'Windows'
74+
75+
- uses: actions/checkout@v4
76+
77+
- uses: denoland/[email protected]
78+
with:
79+
deno-version: "${{ matrix.deno_version }}"
80+
81+
- name: Get denops
82+
run: |
83+
git clone https://github.com/vim-denops/denops.vim /tmp/denops.vim
84+
echo "DENOPS_TEST_DENOPS_PATH=/tmp/denops.vim" >> "$GITHUB_ENV"
85+
86+
- name: Try switching denops branch
87+
run: |
88+
git -C /tmp/denops.vim switch ${{ env.DENOPS_BRANCH }} || true
89+
git -C /tmp/denops.vim branch
90+
91+
- uses: rhysd/action-setup-vim@v1
92+
id: vim
93+
with:
94+
version: "${{ matrix.host_version.vim }}"
95+
96+
- uses: rhysd/action-setup-vim@v1
97+
id: nvim
98+
with:
99+
neovim: true
100+
version: "${{ matrix.host_version.nvim }}"
101+
102+
- name: Export executables
103+
run: |
104+
echo "DENOPS_TEST_VIM_EXECUTABLE=${{ steps.vim.outputs.executable }}" >> "$GITHUB_ENV"
105+
echo "DENOPS_TEST_NVIM_EXECUTABLE=${{ steps.nvim.outputs.executable }}" >> "$GITHUB_ENV"
106+
107+
- name: Check versions
108+
run: |
109+
deno --version
110+
${DENOPS_TEST_VIM_EXECUTABLE} --version
111+
${DENOPS_TEST_NVIM_EXECUTABLE} --version
112+
113+
- name: Perform pre-cache
114+
run: |
115+
deno cache \
116+
${DENOPS_TEST_DENOPS_PATH}/denops/@denops-private/mod.ts ./denops/fall/main.ts
117+
118+
- name: Test
119+
run: deno task test:coverage
120+
timeout-minutes: 15
121+
122+
- run: |
123+
deno task coverage --lcov > coverage.lcov
124+
125+
- uses: codecov/codecov-action@v4
126+
with:
127+
os: ${{ runner.os }}
128+
files: ./coverage.lcov
129+
token: ${{ secrets.CODECOV_TOKEN }}
130+
131+
jsr-publish:
132+
runs-on: ubuntu-latest
133+
steps:
134+
- uses: actions/checkout@v4
135+
- uses: denoland/setup-deno@v1
136+
with:
137+
deno-version: ${{ env.DENO_VERSION }}
138+
- name: Publish (dry-run)
139+
run: |
140+
deno publish --dry-run

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.tool-versions
2+
.coverage
3+
deno.lock

.gitmessage

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# **Conventional Commits**
3+
#
4+
# <type>[optional scope]: <description>
5+
#
6+
# feat: feature (minor)
7+
# deps: dependencies (minor/patch)
8+
# fix: bug fix (patch)
9+
# refactor: refactoring code
10+
# test: test fix; no code change
11+
# docs: documentation fix; no code change
12+
# style: formatting, missing semi colons, etc; no code change
13+
# chore: updating build tasks, package manager configs, etc; no code change
14+
#
15+
# **Install**
16+
#
17+
# git config commit.template .gitmessage
18+
#
19+
# **Reference**
20+
#
21+
# - https://www.conventionalcommits.org/en/v1.0.0/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const baseUrl =
2+
"https://github.com/lambdalisue/vim-nerdfont/raw/refs/heads/master/assets/json/";
3+
4+
async function download(filename: string): Promise<void> {
5+
const url = new URL(filename, baseUrl);
6+
const response = await fetch(url);
7+
if (!response.ok) {
8+
throw new Error(`Failed to download ${url}`);
9+
}
10+
const text = await response.text();
11+
await Deno.writeTextFile(
12+
new URL(
13+
filename,
14+
new URL("../builtin/renderer/_nerdfont/", import.meta.url),
15+
),
16+
text,
17+
);
18+
}
19+
20+
await download("basename.json");
21+
await download("extension.json");
22+
await download("pattern.json");

.script/gen-exports.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { dirname, fromFileUrl, globToRegExp, relative } from "@std/path";
2+
import { walk } from "@std/fs";
3+
import { parse } from "@std/jsonc";
4+
5+
const excludes = [
6+
".*",
7+
"*_test.ts",
8+
"*_bench.ts",
9+
"_*.ts",
10+
];
11+
12+
async function generateExports(
13+
path: string,
14+
): Promise<Record<string, string>> {
15+
const patterns = excludes.map((p) => globToRegExp(p));
16+
const root = fromFileUrl(new URL("../", import.meta.url));
17+
const it = walk(path, {
18+
includeFiles: true,
19+
includeDirs: false,
20+
skip: [/node_modules/, /\/\..*\//],
21+
});
22+
const exports: Record<string, string> = {};
23+
for await (const entry of it) {
24+
if (!entry.name.endsWith(".ts")) continue;
25+
if (patterns.some((p) => p.test(entry.name))) continue;
26+
const exportName = [".", relative(path, normalizeExportName(entry.path))]
27+
.filter((v) => !!v)
28+
.join("/");
29+
const exportPath = [".", relative(root, entry.path)]
30+
.filter((v) => !!v)
31+
.join("/");
32+
exports[exportName] = exportPath;
33+
}
34+
return Object.fromEntries(Object.entries(exports).toSorted());
35+
}
36+
37+
function normalizeExportName(name: string): string {
38+
if (name.endsWith("/mod.ts")) {
39+
name = dirname(name);
40+
}
41+
name = name.replace(/\.ts$/, "");
42+
name = name.replace(/_/g, "-");
43+
return name;
44+
}
45+
46+
if (import.meta.main) {
47+
const exports = await generateExports(
48+
fromFileUrl(new URL("../", import.meta.url)),
49+
);
50+
const denoJsoncPath = new URL("../deno.jsonc", import.meta.url);
51+
const denoJsonc = parse(await Deno.readTextFile(denoJsoncPath)) as Record<
52+
string,
53+
unknown
54+
>;
55+
await Deno.writeTextFile(
56+
denoJsoncPath,
57+
JSON.stringify(
58+
{
59+
...denoJsonc,
60+
exports,
61+
},
62+
undefined,
63+
2,
64+
),
65+
);
66+
}

.script/gen-mod.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { dirname, fromFileUrl, globToRegExp, join, relative } from "@std/path";
2+
import { exists, walk } from "@std/fs";
3+
4+
const excludes = [
5+
"mod.ts",
6+
"*_test.ts",
7+
"*_bench.ts",
8+
"_*.ts",
9+
];
10+
11+
async function* iterModules(path: string): AsyncIterable<string> {
12+
const patterns = excludes.map((p) => globToRegExp(p));
13+
for await (const entry of Deno.readDir(path)) {
14+
if (entry.isFile) {
15+
if (!entry.name.endsWith(".ts")) continue;
16+
if (patterns.some((p) => p.test(entry.name))) continue;
17+
yield entry.name;
18+
} else if (entry.isDirectory) {
19+
const modPath = join(path, entry.name, "mod.ts");
20+
if (await exists(modPath)) {
21+
yield relative(path, modPath);
22+
}
23+
}
24+
}
25+
}
26+
27+
async function generateModTs(
28+
path: string,
29+
): Promise<void> {
30+
const it = walk(path, {
31+
includeFiles: false,
32+
includeDirs: true,
33+
includeSymlinks: false,
34+
});
35+
for await (const entry of it) {
36+
const filenames = await Array.fromAsync(iterModules(entry.path));
37+
if (filenames.length === 0) continue;
38+
filenames.sort();
39+
const lines = [
40+
"// This file is generated by gen-mod.ts",
41+
...filenames.map((name) => {
42+
if (name.endsWith("/mod.ts")) {
43+
return `export * as ${dirname(name)} from "./${name}";`;
44+
} else {
45+
return `export * from "./${name}";`;
46+
}
47+
}),
48+
];
49+
await Deno.writeTextFile(
50+
join(entry.path, "mod.ts"),
51+
lines.join("\n"),
52+
);
53+
}
54+
}
55+
56+
if (import.meta.main) {
57+
generateModTs(
58+
fromFileUrl(new URL("../builtin", import.meta.url)),
59+
);
60+
}

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright 2024 Alisue <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
20+

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 🍂 fall-std
2+
3+
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4+
5+
Standard library for using [Fall](https://github.com/vim-fall/fall), a
6+
Vim/Neovim Fuzzy Finder plugin powered by
7+
[Denops](https://github.com/vim-denops/denops.vim).
8+
9+
It is also used to develop extensions of Fall.
10+
11+
## License
12+
13+
The code in this repository follows the MIT license, as detailed in
14+
[LICENSE](./LICENSE). Contributors must agree that any modifications submitted
15+
to this repository also adhere to the license.

0 commit comments

Comments
 (0)