The withfig/autocomplete repo contains a linter program that can be used to validate your specs automatically. It returns syntax and type errors from your autocomplete spec.
To use the linter, run the following command from the root autocomplete folder.
npm run lint build/[specName].js
To run the linter on ALL specs in the /build folder, run
npm run lint or
Note that you'll need to run
npm install to grab the right dependencies.
- Make sure Fig is on and autocomplete is working
- Put your spec in the
~/.fig/autocompletedirectory (or symlink it there from wherever you are building it)
- Test your spec automatically using the Fig linter
- Test your spec manually in the terminal:
- Go to a new line in your terminal
- Backspace repeatedly until the line is empty
- Type the command for the completion spec as you would normally
Fig caches completion specs on each load. Typing in
cd invalidates the cache by loading the
cd completion spec.
Let's say you are building a completion spec for your CLI tool,
foobar. When you type
foobar into your Terminal, Fig loads the
foobarcompletion spec. This spec will remain loaded until another one replaces it. No matter what changes you make to the
foobar spec, these will not be displayed until you load another spec, then load up
Fig reads completion specs from the following folder:
You can edit your spec there. Or you can edit it from anywhere and symlink it to that repo
ln -s /path/to/my/spec ~/.fig/autocomplete/
Right click the popup window and click Inspect Element. It will open up Safari's web dev console
Is autocomplete working? Try going to a new line in the terminal and typing
cdplus a space.
- If Fig pops up, autocomplete is working. Chances are it is a problem with your script. Make sure you have correct syntax. View the logs (above) for any errors.
- If Fig doesn't pop up, autocomplete has crashed 😬. Click to the Fig Icon (◧) in the mac status bar and toggle autocomplete on and off
If Fig still doesn't work, restart Fig ( ◧ -> Restart Fig)
View our support guide
If you'd like to contribute, please fork our withfig/autocomplete github repo and submit a PR.
Your spec will have to pass a linting test in GitHub actions and a quick security review by the Fig team before we merge it.