Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Publish
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ jobs:
runner:
- ubuntu-latest
deno_version:
- "1.x"
- "2.x"
runs-on: ${{ matrix.runner }}
steps:
- run: git config --global core.autocrlf false
if: runner.os == 'Windows'
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1.1.4
- uses: denoland/setup-deno@v2
with:
deno-version: "${{ matrix.deno_version }}"
- uses: actions/cache@v4
Expand Down Expand Up @@ -61,7 +60,6 @@ jobs:
- macos-latest
- ubuntu-latest
deno_version:
- "1.x"
- "2.x"
host_version:
- vim: "v9.1.0448"
Expand All @@ -74,7 +72,7 @@ jobs:

- uses: actions/checkout@v4

- uses: denoland/setup-deno@v1.1.4
- uses: denoland/setup-deno@v2
with:
deno-version: "${{ matrix.deno_version }}"

Expand Down Expand Up @@ -132,9 +130,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.DENO_VERSION }}
deno-version: "2.x"
- name: Publish (dry-run)
run: |
deno publish --dry-run
214 changes: 57 additions & 157 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,172 +1,72 @@
# 🍂 fall-std

[![JSR](https://jsr.io/badges/@vim-fall/std)](https://jsr.io/@vim-fall/std)
[![Deno](https://img.shields.io/badge/Deno%202.x-333?logo=deno&logoColor=fff)](#)
[![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)
[![codecov](https://codecov.io/gh/vim-fall/fall-std/graph/badge.svg?token=FWTFEJT1X1)](https://codecov.io/gh/vim-fall/fall-std)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Standard library for using [Fall](https://github.com/vim-fall/fall), a
A standard library for using [Fall](https://github.com/vim-fall/fall), a
Vim/Neovim Fuzzy Finder plugin powered by
[Denops](https://github.com/vim-denops/denops.vim).

It is also used to develop extensions of Fall.
[Denops](https://github.com/vim-denops/denops.vim). Users should import this
library in Fall's configuration file (`fall/config.ts`) to use the built-in
extensions and utility functions.

## Usage

```ts
// Import Fall standard library functions and built-in utilities
import {
composeRenderers,
type Entrypoint,
pipeProjectors,
} from "jsr:@vim-fall/std@^0.1.0"; // Fall standard library
import * as builtin from "jsr:@vim-fall/std@^0.1.0/builtin"; // Built-in Fall utilities

// Define custom actions for file handling, quickfix, and other operations
const myPathActions = {
...builtin.action.defaultOpenActions,
...builtin.action.defaultSystemopenActions,
...builtin.action.defaultCdActions,
};

const myQuickfixActions = {
...builtin.action.defaultQuickfixActions,
"quickfix:qfreplace": builtin.action.quickfix({
after: "Qfreplace", // Using the "Qfreplace" plugin for replacing text in quickfix
}),
};

const myMiscActions = {
...builtin.action.defaultEchoActions,
...builtin.action.defaultYankActions,
...builtin.action.defaultSubmatchActions,
};

// Main entry point function for configuring the Fall interface
export const main: Entrypoint = (
{
defineItemPickerFromSource, // Define item pickers from source data
defineItemPickerFromCurator, // Define item pickers from curators (e.g., Git grep)
refineGlobalConfig, // Refine global settings (e.g., theme and layout)
},
) => {
// Set up global configuration (layout and theme)
refineGlobalConfig({
coordinator: builtin.coordinator.separate, // Use the "separate" layout style
theme: builtin.theme.ASCII_THEME, // Apply ASCII-themed UI
});

// Configure item pickers for "git-grep", "rg", and "file" sources
defineItemPickerFromCurator(
"git-grep", // Picker for `git grep` results
pipeProjectors(
builtin.curator.gitGrep, // Uses Git to search
builtin.modifier.relativePath, // Show relative paths
),
{
previewers: [builtin.previewer.file], // Preview file contents
actions: {
...myPathActions,
...myQuickfixActions,
...myMiscActions,
},
defaultAction: "open", // Default action to open the file
},
);

defineItemPickerFromCurator(
"rg", // Picker for `rg` (ripgrep) results
pipeProjectors(
builtin.curator.rg, // Uses `rg` for searching
builtin.modifier.relativePath, // Modify results to show relative paths
),
{
previewers: [builtin.previewer.file], // Preview file contents
actions: {
...myPathActions,
...myQuickfixActions,
...myMiscActions,
},
defaultAction: "open", // Default action to open the file
},
);

// File picker configuration with exclusion filters for unwanted directories
defineItemPickerFromSource(
"file", // Picker for files with exclusions
pipeProjectors(
builtin.source.file({
excludes: [
/.*\/node_modules\/.*/, // Exclude node_modules
/.*\/.git\/.*/, // Exclude Git directories
/.*\/.svn\/.*/, // Exclude SVN directories
/.*\/.hg\/.*/, // Exclude Mercurial directories
/.*\/.DS_Store$/, // Exclude macOS .DS_Store files
],
}),
builtin.modifier.relativePath, // Show relative paths
),
{
matchers: [builtin.matcher.fzf], // Use fuzzy search matcher
renderers: [composeRenderers(
builtin.renderer.smartPath, // Render smart paths
builtin.renderer.nerdfont, // Render with NerdFont (requires NerdFont in terminal)
)],
previewers: [builtin.previewer.file], // Preview file contents
actions: {
...myPathActions,
...myQuickfixActions,
...myMiscActions,
},
defaultAction: "open", // Default action to open the file
},
);

// Configure "line" picker for selecting lines in a file
defineItemPickerFromSource("line", builtin.source.line, {
matchers: [builtin.matcher.fzf], // Use fuzzy search matcher
previewers: [builtin.previewer.buffer], // Preview the buffer content
actions: {
...myQuickfixActions,
...myMiscActions,
...builtin.action.defaultOpenActions,
...builtin.action.defaultBufferActions,
},
defaultAction: "open", // Default action to open the line
});

// Configure "buffer" picker for loaded buffers
defineItemPickerFromSource(
"buffer",
builtin.source.buffer({ filter: "bufloaded" }), // Show only loaded buffers
{
matchers: [builtin.matcher.fzf], // Use fuzzy search matcher
previewers: [builtin.previewer.buffer], // Preview the buffer content
actions: {
...myQuickfixActions,
...myMiscActions,
...builtin.action.defaultOpenActions,
...builtin.action.defaultBufferActions,
},
defaultAction: "open", // Default action to open the buffer
},
);

// Configure "help" picker for help tags
defineItemPickerFromSource("help", builtin.source.helptag, {
matchers: [builtin.matcher.fzf], // Use fuzzy search matcher
previewers: [builtin.previewer.helptag], // Preview help tag content
actions: {
...myMiscActions,
...builtin.action.defaultHelpActions, // Help actions
},
defaultAction: "help", // Default action is to show help
});
};
### Extensions

Extensions are available in the `builtin` directory. You can access them like
this:

```typescript
import * as builtin from "jsr:@vim-fall/std/builtin";

// Display all curators
console.log(builtin.curator);

// Display all sources
console.log(builtin.source);

// Display all actions
console.log(builtin.action);

// ...
```

### Utility Functions

Utility functions are defined in the root directory. You can access them like
this:

```typescript
import * as builtin from "jsr:@vim-fall/std/builtin";
import * as std from "jsr:@vim-fall/std";

// Refine a source with refiners
const refinedSource = std.refineSource(
// File source
builtin.source.file,
// Refiner to filter files based on the current working directory
builtin.refiner.cwd,
// Refiner to modify item paths to be relative from the current working directory
builtin.refiner.relativePath,
// ...
);
```

### More Extensions

For more extensions (including integrations with other Vim plugins, non-standard
workflows, etc.), check out
[vim-fall/fall-extra](https://github.com/vim-fall/fall-extra)
([@vim-fall/extra](https://jsr.io/@vim-fall/extra)).

## License

The code in this repository follows the MIT license, as detailed in
[LICENSE](./LICENSE). Contributors must agree that any modifications submitted
to this repository also adhere to the license.
The code in this repository follows the MIT license, as detailed in the LICENSE.
Contributors must agree that any modifications submitted to this repository also
adhere to the license.

This Markdown version will render properly when used in a Markdown environment.
Let me know if you'd like to adjust anything further!
18 changes: 8 additions & 10 deletions action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export type * from "@vim-fall/core/action";

import type { Denops } from "@denops/std";
import type { Action, InvokeParams } from "@vim-fall/core/action";

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

Expand All @@ -10,16 +13,14 @@ import { type DerivableArray, deriveArray } from "./util/derivable.ts";
* @param invoke - The function to invoke the action.
* @returns The defined action.
*/
export function defineAction<T>(
export function defineAction<T extends Detail = DetailUnit>(
invoke: (
denops: Denops,
params: InvokeParams<T>,
options: { signal?: AbortSignal },
) => Promish<void | true>,
): Action<T> {
return {
invoke,
};
return { invoke };
}

/**
Expand All @@ -30,10 +31,9 @@ export function defineAction<T>(
* @param actions - The actions to compose.
* @returns The composed action.
*/
export function composeActions<
T,
A extends DerivableArray<[Action<T>, ...Action<T>[]]>,
>(...actions: A): Action<T> {
export function composeActions<T extends Detail>(
...actions: DerivableArray<[Action<T>, ...Action<T>[]]>
): Action<T> {
return {
invoke: async (denops, params, options) => {
for (const action of deriveArray(actions)) {
Expand All @@ -42,5 +42,3 @@ export function composeActions<
},
};
}

export type * from "@vim-fall/core/action";
Loading