|
1 | 1 | # 🍂 fall-std |
2 | 2 |
|
3 | 3 | [](https://jsr.io/@vim-fall/std) |
| 4 | +[](#) |
4 | 5 | [](https://github.com/vim-fall/fall-std/actions/workflows/test.yml) |
5 | 6 | [](https://codecov.io/gh/vim-fall/fall-std) |
6 | 7 | [](LICENSE) |
7 | 8 |
|
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 |
9 | 10 | 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. |
13 | 14 |
|
14 | 15 | ## Usage |
15 | 16 |
|
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 | +); |
166 | 56 | ``` |
167 | 57 |
|
| 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 | + |
168 | 65 | ## License |
169 | 66 |
|
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! |
0 commit comments