Skip to content

Commit 7e916bd

Browse files
authored
Merge pull request #1 from vim-fall/fix-types
Fix types
2 parents 11c0f55 + 96cea10 commit 7e916bd

Some content is hidden

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

77 files changed

+2368
-1275
lines changed

.github/workflows/jsr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v4
2020
with:
2121
fetch-depth: 0
22-
- uses: denoland/setup-deno@v1
22+
- uses: denoland/setup-deno@v2
2323
with:
2424
deno-version: ${{ env.DENO_VERSION }}
2525
- name: Publish

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ jobs:
2626
runner:
2727
- ubuntu-latest
2828
deno_version:
29-
- "1.x"
3029
- "2.x"
3130
runs-on: ${{ matrix.runner }}
3231
steps:
3332
- run: git config --global core.autocrlf false
3433
if: runner.os == 'Windows'
3534
- uses: actions/checkout@v4
36-
- uses: denoland/setup-deno@v1.1.4
35+
- uses: denoland/setup-deno@v2
3736
with:
3837
deno-version: "${{ matrix.deno_version }}"
3938
- uses: actions/cache@v4
@@ -61,7 +60,6 @@ jobs:
6160
- macos-latest
6261
- ubuntu-latest
6362
deno_version:
64-
- "1.x"
6563
- "2.x"
6664
host_version:
6765
- vim: "v9.1.0448"
@@ -74,7 +72,7 @@ jobs:
7472

7573
- uses: actions/checkout@v4
7674

77-
- uses: denoland/setup-deno@v1.1.4
75+
- uses: denoland/setup-deno@v2
7876
with:
7977
deno-version: "${{ matrix.deno_version }}"
8078

@@ -132,9 +130,9 @@ jobs:
132130
runs-on: ubuntu-latest
133131
steps:
134132
- uses: actions/checkout@v4
135-
- uses: denoland/setup-deno@v1
133+
- uses: denoland/setup-deno@v2
136134
with:
137-
deno-version: ${{ env.DENO_VERSION }}
135+
deno-version: "2.x"
138136
- name: Publish (dry-run)
139137
run: |
140138
deno publish --dry-run

README.md

Lines changed: 57 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,72 @@
11
# 🍂 fall-std
22

33
[![JSR](https://jsr.io/badges/@vim-fall/std)](https://jsr.io/@vim-fall/std)
4+
[![Deno](https://img.shields.io/badge/Deno%202.x-333?logo=deno&logoColor=fff)](#)
45
[![Test](https://github.com/vim-fall/fall-std/actions/workflows/test.yml/badge.svg)](https://github.com/vim-fall/fall-std/actions/workflows/test.yml)
56
[![codecov](https://codecov.io/gh/vim-fall/fall-std/graph/badge.svg?token=FWTFEJT1X1)](https://codecov.io/gh/vim-fall/fall-std)
67
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
78

8-
Standard library for using [Fall](https://github.com/vim-fall/fall), a
9+
A standard library for using [Fall](https://github.com/vim-fall/fall), a
910
Vim/Neovim Fuzzy Finder plugin powered by
10-
[Denops](https://github.com/vim-denops/denops.vim).
11-
12-
It is also used to develop extensions of Fall.
11+
[Denops](https://github.com/vim-denops/denops.vim). Users should import this
12+
library in Fall's configuration file (`fall/config.ts`) to use the built-in
13+
extensions and utility functions.
1314

1415
## Usage
1516

16-
```ts
17-
// Import Fall standard library functions and built-in utilities
18-
import {
19-
composeRenderers,
20-
type Entrypoint,
21-
pipeProjectors,
22-
} from "jsr:@vim-fall/std@^0.1.0"; // Fall standard library
23-
import * as builtin from "jsr:@vim-fall/std@^0.1.0/builtin"; // Built-in Fall utilities
24-
25-
// Define custom actions for file handling, quickfix, and other operations
26-
const myPathActions = {
27-
...builtin.action.defaultOpenActions,
28-
...builtin.action.defaultSystemopenActions,
29-
...builtin.action.defaultCdActions,
30-
};
31-
32-
const myQuickfixActions = {
33-
...builtin.action.defaultQuickfixActions,
34-
"quickfix:qfreplace": builtin.action.quickfix({
35-
after: "Qfreplace", // Using the "Qfreplace" plugin for replacing text in quickfix
36-
}),
37-
};
38-
39-
const myMiscActions = {
40-
...builtin.action.defaultEchoActions,
41-
...builtin.action.defaultYankActions,
42-
...builtin.action.defaultSubmatchActions,
43-
};
44-
45-
// Main entry point function for configuring the Fall interface
46-
export const main: Entrypoint = (
47-
{
48-
defineItemPickerFromSource, // Define item pickers from source data
49-
defineItemPickerFromCurator, // Define item pickers from curators (e.g., Git grep)
50-
refineGlobalConfig, // Refine global settings (e.g., theme and layout)
51-
},
52-
) => {
53-
// Set up global configuration (layout and theme)
54-
refineGlobalConfig({
55-
coordinator: builtin.coordinator.separate, // Use the "separate" layout style
56-
theme: builtin.theme.ASCII_THEME, // Apply ASCII-themed UI
57-
});
58-
59-
// Configure item pickers for "git-grep", "rg", and "file" sources
60-
defineItemPickerFromCurator(
61-
"git-grep", // Picker for `git grep` results
62-
pipeProjectors(
63-
builtin.curator.gitGrep, // Uses Git to search
64-
builtin.modifier.relativePath, // Show relative paths
65-
),
66-
{
67-
previewers: [builtin.previewer.file], // Preview file contents
68-
actions: {
69-
...myPathActions,
70-
...myQuickfixActions,
71-
...myMiscActions,
72-
},
73-
defaultAction: "open", // Default action to open the file
74-
},
75-
);
76-
77-
defineItemPickerFromCurator(
78-
"rg", // Picker for `rg` (ripgrep) results
79-
pipeProjectors(
80-
builtin.curator.rg, // Uses `rg` for searching
81-
builtin.modifier.relativePath, // Modify results to show relative paths
82-
),
83-
{
84-
previewers: [builtin.previewer.file], // Preview file contents
85-
actions: {
86-
...myPathActions,
87-
...myQuickfixActions,
88-
...myMiscActions,
89-
},
90-
defaultAction: "open", // Default action to open the file
91-
},
92-
);
93-
94-
// File picker configuration with exclusion filters for unwanted directories
95-
defineItemPickerFromSource(
96-
"file", // Picker for files with exclusions
97-
pipeProjectors(
98-
builtin.source.file({
99-
excludes: [
100-
/.*\/node_modules\/.*/, // Exclude node_modules
101-
/.*\/.git\/.*/, // Exclude Git directories
102-
/.*\/.svn\/.*/, // Exclude SVN directories
103-
/.*\/.hg\/.*/, // Exclude Mercurial directories
104-
/.*\/.DS_Store$/, // Exclude macOS .DS_Store files
105-
],
106-
}),
107-
builtin.modifier.relativePath, // Show relative paths
108-
),
109-
{
110-
matchers: [builtin.matcher.fzf], // Use fuzzy search matcher
111-
renderers: [composeRenderers(
112-
builtin.renderer.smartPath, // Render smart paths
113-
builtin.renderer.nerdfont, // Render with NerdFont (requires NerdFont in terminal)
114-
)],
115-
previewers: [builtin.previewer.file], // Preview file contents
116-
actions: {
117-
...myPathActions,
118-
...myQuickfixActions,
119-
...myMiscActions,
120-
},
121-
defaultAction: "open", // Default action to open the file
122-
},
123-
);
124-
125-
// Configure "line" picker for selecting lines in a file
126-
defineItemPickerFromSource("line", builtin.source.line, {
127-
matchers: [builtin.matcher.fzf], // Use fuzzy search matcher
128-
previewers: [builtin.previewer.buffer], // Preview the buffer content
129-
actions: {
130-
...myQuickfixActions,
131-
...myMiscActions,
132-
...builtin.action.defaultOpenActions,
133-
...builtin.action.defaultBufferActions,
134-
},
135-
defaultAction: "open", // Default action to open the line
136-
});
137-
138-
// Configure "buffer" picker for loaded buffers
139-
defineItemPickerFromSource(
140-
"buffer",
141-
builtin.source.buffer({ filter: "bufloaded" }), // Show only loaded buffers
142-
{
143-
matchers: [builtin.matcher.fzf], // Use fuzzy search matcher
144-
previewers: [builtin.previewer.buffer], // Preview the buffer content
145-
actions: {
146-
...myQuickfixActions,
147-
...myMiscActions,
148-
...builtin.action.defaultOpenActions,
149-
...builtin.action.defaultBufferActions,
150-
},
151-
defaultAction: "open", // Default action to open the buffer
152-
},
153-
);
154-
155-
// Configure "help" picker for help tags
156-
defineItemPickerFromSource("help", builtin.source.helptag, {
157-
matchers: [builtin.matcher.fzf], // Use fuzzy search matcher
158-
previewers: [builtin.previewer.helptag], // Preview help tag content
159-
actions: {
160-
...myMiscActions,
161-
...builtin.action.defaultHelpActions, // Help actions
162-
},
163-
defaultAction: "help", // Default action is to show help
164-
});
165-
};
17+
### Extensions
18+
19+
Extensions are available in the `builtin` directory. You can access them like
20+
this:
21+
22+
```typescript
23+
import * as builtin from "jsr:@vim-fall/std/builtin";
24+
25+
// Display all curators
26+
console.log(builtin.curator);
27+
28+
// Display all sources
29+
console.log(builtin.source);
30+
31+
// Display all actions
32+
console.log(builtin.action);
33+
34+
// ...
35+
```
36+
37+
### Utility Functions
38+
39+
Utility functions are defined in the root directory. You can access them like
40+
this:
41+
42+
```typescript
43+
import * as builtin from "jsr:@vim-fall/std/builtin";
44+
import * as std from "jsr:@vim-fall/std";
45+
46+
// Refine a source with refiners
47+
const refinedSource = std.refineSource(
48+
// File source
49+
builtin.source.file,
50+
// Refiner to filter files based on the current working directory
51+
builtin.refiner.cwd,
52+
// Refiner to modify item paths to be relative from the current working directory
53+
builtin.refiner.relativePath,
54+
// ...
55+
);
16656
```
16757

58+
### More Extensions
59+
60+
For more extensions (including integrations with other Vim plugins, non-standard
61+
workflows, etc.), check out
62+
[vim-fall/fall-extra](https://github.com/vim-fall/fall-extra)
63+
([@vim-fall/extra](https://jsr.io/@vim-fall/extra)).
64+
16865
## License
16966

170-
The code in this repository follows the MIT license, as detailed in
171-
[LICENSE](./LICENSE). Contributors must agree that any modifications submitted
172-
to this repository also adhere to the license.
67+
The code in this repository follows the MIT license, as detailed in the LICENSE.
68+
Contributors must agree that any modifications submitted to this repository also
69+
adhere to the license.
70+
71+
This Markdown version will render properly when used in a Markdown environment.
72+
Let me know if you'd like to adjust anything further!

action.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
export type * from "@vim-fall/core/action";
2+
13
import type { Denops } from "@denops/std";
24
import type { Action, InvokeParams } from "@vim-fall/core/action";
35

6+
import type { Detail, DetailUnit } from "./item.ts";
47
import type { Promish } from "./util/_typeutil.ts";
58
import { type DerivableArray, deriveArray } from "./util/derivable.ts";
69

@@ -10,16 +13,14 @@ import { type DerivableArray, deriveArray } from "./util/derivable.ts";
1013
* @param invoke - The function to invoke the action.
1114
* @returns The defined action.
1215
*/
13-
export function defineAction<T>(
16+
export function defineAction<T extends Detail = DetailUnit>(
1417
invoke: (
1518
denops: Denops,
1619
params: InvokeParams<T>,
1720
options: { signal?: AbortSignal },
1821
) => Promish<void | true>,
1922
): Action<T> {
20-
return {
21-
invoke,
22-
};
23+
return { invoke };
2324
}
2425

2526
/**
@@ -30,10 +31,9 @@ export function defineAction<T>(
3031
* @param actions - The actions to compose.
3132
* @returns The composed action.
3233
*/
33-
export function composeActions<
34-
T,
35-
A extends DerivableArray<[Action<T>, ...Action<T>[]]>,
36-
>(...actions: A): Action<T> {
34+
export function composeActions<T extends Detail>(
35+
...actions: DerivableArray<[Action<T>, ...Action<T>[]]>
36+
): Action<T> {
3737
return {
3838
invoke: async (denops, params, options) => {
3939
for (const action of deriveArray(actions)) {
@@ -42,5 +42,3 @@ export function composeActions<
4242
},
4343
};
4444
}
45-
46-
export type * from "@vim-fall/core/action";

0 commit comments

Comments
 (0)