Skip to content

Customization

Λlisue edited this page Mar 30, 2025 · 11 revisions

In Fall, settings written in TypeScript to enhance Fall’s behavior are categorized as “Customization.” This specifically refers to modifications made to the user customization file, which can be accessed via the FallCustom command.

Note

Read Architecture to find the purpose of each modules.

When you run the FallCustom command, the user customization file opens. In this file, Pickers are defined, and only the Pickers defined here can be used in Fall.

For example, if you create a user customization file without defining any Pickers, as shown below, Fall will not have any Pickers available:

importtype{Entrypoint}from"jsr:@vim-fall/custom";exportconstmain: Entrypoint=()=>{// WARNING: Since no Pickers are defined, Fall provides no functionality};

A Picker can be defined by specifying at least its name, source, matcher, and actions. Additionally, if no additional options are required, modules can be passed as functions directly:

importtype{Entrypoint}from"jsr:@vim-fall/custom";import*asbuiltinfrom"jsr:@vim-fall/std/builtin";exportconstmain: Entrypoint=({ definePickerFromSource })=>{definePickerFromSource("file",// builtin.source.file and builtin.source.file() are treated as equivalentbuiltin.source.file,{matchers: [builtin.matcher.fzf],actions: {open: builtin.action.open,},defaultAction: "open",},);};

To define a Picker, you use the definePickerFromSource function as shown above. The main function receives the following arguments:

Argument NameDescription
denopsA Denops instance.
definePickerFromSourceA function to define a Picker using a Source and a Matcher.
definePickerFromCuratorA function to define a Picker using a Curator.
refineActionPickerA function to refine the Picker used for selecting actions.
refineSettingA function to adjust various settings.

Users can utilize these functions to define Pickers and customize their configurations.

See @vim-fall/std/builtin for available official builtin extensions and @vim-fall/extra for available official extra extensions. And see ./denops/fall/_assets/default.custom.ts for the latest default customization file.

In addition, @vim-fall/std provides the following functions to refine and compose individual modules:

NameDescription
bindSourceArgsWraps a source to prepend fixed arguments (static or dynamically resolved) to its input parameters before execution.
bindCuratorArgsWraps a curator to prepend fixed arguments (static or dynamically resolved) to its input parameters before execution.
refineSourceApplies multiple Refiners to Source to refine and process generated items.
refineCuratorApplies multiple Refiners to Curator to refine and process generated items.
composeSourcesCombines multiple Sources to create a new Source that sequentially retrieves items from all Sources.
composeMatchersCombines multiple Matchers to create a new Matcher that filters items through all Matchers.
composeCuratorsCombines multiple Curators to create a new Curator that retrieves items through all Curators.
composeSortersCombines multiple Sorters to create a new Sorter that sorts items through all Sorters.
composeRenderersCombines multiple Renderers to create a new Renderer that processes items through all Renderers.
composePreviewersCombines multiple Previewers to create a new Previewer that generates content from any of the Previewers.
composeActionsCombines multiple Actions to create a new Action that invokes all Actions.

By combining these modules, Fall enables flexible functionality.

For example, the following code demonstrates how to create a Source that retrieves files recorded in Vim’s oldfiles that exist in the current directory:

import{refineSource}from"jsr:@vim-fall/std"import*asbuiltinfrom"jsr:@vim-fall/std/builtin"constsource=refineSource(builtin.source.oldfiles,builtin.refiner.exists,builtin.refiner.cwd,);

Similarly, the following example shows how to create an Action that change directory and open.

import{composeActions}from"jsr:@vim-fall/std"import*asbuiltinfrom"jsr:@vim-fall/std/builtin"constaction=composeActions(builtin.action.cd,builtin.action.open,);

Clone this wiki locally