11# 🍂 fall-std
22
3+ [ ![ JSR] ( https://jsr.io/badges/@vim-fall/std )] ( https://jsr.io/@vim-fall/std )
34[ ![ 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 )
45[ ![ MIT License] ( https://img.shields.io/badge/license-MIT-blue.svg )] ( LICENSE )
56
@@ -9,6 +10,160 @@ Vim/Neovim Fuzzy Finder plugin powered by
910
1011It is also used to develop extensions of Fall.
1112
13+ ## Usage
14+
15+ ``` ts
16+ // Import Fall standard library functions and built-in utilities
17+ import {
18+ composeRenderers ,
19+ type Entrypoint ,
20+ pipeProjectors ,
21+ } from " jsr:@vim-fall/std@^0.1.0" ; // Fall standard library
22+ import * as builtin from " jsr:@vim-fall/std@^0.1.0/builtin" ; // Built-in Fall utilities
23+
24+ // Define custom actions for file handling, quickfix, and other operations
25+ const myPathActions = {
26+ ... builtin .action .defaultOpenActions ,
27+ ... builtin .action .defaultSystemopenActions ,
28+ ... builtin .action .defaultCdActions ,
29+ };
30+
31+ const myQuickfixActions = {
32+ ... builtin .action .defaultQuickfixActions ,
33+ " quickfix:qfreplace" : builtin .action .quickfix ({
34+ after: " Qfreplace" , // Using the "Qfreplace" plugin for replacing text in quickfix
35+ }),
36+ };
37+
38+ const myMiscActions = {
39+ ... builtin .action .defaultEchoActions ,
40+ ... builtin .action .defaultYankActions ,
41+ ... builtin .action .defaultSubmatchActions ,
42+ };
43+
44+ // Main entry point function for configuring the Fall interface
45+ export const main: Entrypoint = (
46+ {
47+ defineItemPickerFromSource , // Define item pickers from source data
48+ defineItemPickerFromCurator , // Define item pickers from curators (e.g., Git grep)
49+ refineGlobalConfig , // Refine global settings (e.g., theme and layout)
50+ },
51+ ) => {
52+ // Set up global configuration (layout and theme)
53+ refineGlobalConfig ({
54+ coordinator: builtin .coordinator .separate , // Use the "separate" layout style
55+ theme: builtin .theme .ASCII_THEME , // Apply ASCII-themed UI
56+ });
57+
58+ // Configure item pickers for "git-grep", "rg", and "file" sources
59+ defineItemPickerFromCurator (
60+ " git-grep" , // Picker for `git grep` results
61+ pipeProjectors (
62+ builtin .curator .gitGrep , // Uses Git to search
63+ builtin .modifier .relativePath , // Show relative paths
64+ ),
65+ {
66+ previewers: [builtin .previewer .file ], // Preview file contents
67+ actions: {
68+ ... myPathActions ,
69+ ... myQuickfixActions ,
70+ ... myMiscActions ,
71+ },
72+ defaultAction: " open" , // Default action to open the file
73+ },
74+ );
75+
76+ defineItemPickerFromCurator (
77+ " rg" , // Picker for `rg` (ripgrep) results
78+ pipeProjectors (
79+ builtin .curator .rg , // Uses `rg` for searching
80+ builtin .modifier .relativePath , // Modify results to show relative paths
81+ ),
82+ {
83+ previewers: [builtin .previewer .file ], // Preview file contents
84+ actions: {
85+ ... myPathActions ,
86+ ... myQuickfixActions ,
87+ ... myMiscActions ,
88+ },
89+ defaultAction: " open" , // Default action to open the file
90+ },
91+ );
92+
93+ // File picker configuration with exclusion filters for unwanted directories
94+ defineItemPickerFromSource (
95+ " file" , // Picker for files with exclusions
96+ pipeProjectors (
97+ builtin .source .file ({
98+ excludes: [
99+ / . * \/ node_modules\/ . * / , // Exclude node_modules
100+ / . * \/ . git\/ . * / , // Exclude Git directories
101+ / . * \/ . svn\/ . * / , // Exclude SVN directories
102+ / . * \/ . hg\/ . * / , // Exclude Mercurial directories
103+ / . * \/ . DS_Store$ / , // Exclude macOS .DS_Store files
104+ ],
105+ }),
106+ builtin .modifier .relativePath , // Show relative paths
107+ ),
108+ {
109+ matchers: [builtin .matcher .fzf ], // Use fuzzy search matcher
110+ renderers: [composeRenderers (
111+ builtin .renderer .smartPath , // Render smart paths
112+ builtin .renderer .nerdfont , // Render with NerdFont (requires NerdFont in terminal)
113+ )],
114+ previewers: [builtin .previewer .file ], // Preview file contents
115+ actions: {
116+ ... myPathActions ,
117+ ... myQuickfixActions ,
118+ ... myMiscActions ,
119+ },
120+ defaultAction: " open" , // Default action to open the file
121+ },
122+ );
123+
124+ // Configure "line" picker for selecting lines in a file
125+ defineItemPickerFromSource (" line" , builtin .source .line , {
126+ matchers: [builtin .matcher .fzf ], // Use fuzzy search matcher
127+ previewers: [builtin .previewer .buffer ], // Preview the buffer content
128+ actions: {
129+ ... myQuickfixActions ,
130+ ... myMiscActions ,
131+ ... builtin .action .defaultOpenActions ,
132+ ... builtin .action .defaultBufferActions ,
133+ },
134+ defaultAction: " open" , // Default action to open the line
135+ });
136+
137+ // Configure "buffer" picker for loaded buffers
138+ defineItemPickerFromSource (
139+ " buffer" ,
140+ builtin .source .buffer ({ filter: " bufloaded" }), // Show only loaded buffers
141+ {
142+ matchers: [builtin .matcher .fzf ], // Use fuzzy search matcher
143+ previewers: [builtin .previewer .buffer ], // Preview the buffer content
144+ actions: {
145+ ... myQuickfixActions ,
146+ ... myMiscActions ,
147+ ... builtin .action .defaultOpenActions ,
148+ ... builtin .action .defaultBufferActions ,
149+ },
150+ defaultAction: " open" , // Default action to open the buffer
151+ },
152+ );
153+
154+ // Configure "help" picker for help tags
155+ defineItemPickerFromSource (" help" , builtin .source .helptag , {
156+ matchers: [builtin .matcher .fzf ], // Use fuzzy search matcher
157+ previewers: [builtin .previewer .helptag ], // Preview help tag content
158+ actions: {
159+ ... myMiscActions ,
160+ ... builtin .action .defaultHelpActions , // Help actions
161+ },
162+ defaultAction: " help" , // Default action is to show help
163+ });
164+ };
165+ ```
166+
12167## License
13168
14169The code in this repository follows the MIT license, as detailed in
0 commit comments