From 4e75dd16c8be7f173f90a0044bcd75f7247aeb9e Mon Sep 17 00:00:00 2001 From: Marko Mindek Date: Sun, 10 Mar 2024 02:14:48 +0100 Subject: [PATCH] docs for completion_prv --- content/en/docs/commands.md | 26 +++++++++++++++++++ .../en/docs/configuration/configuration.md | 13 +++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/content/en/docs/commands.md b/content/en/docs/commands.md index a38d4cc..ec1712c 100644 --- a/content/en/docs/commands.md +++ b/content/en/docs/commands.md @@ -30,6 +30,32 @@ After ensuring all dependencies are available, and fetching them if they are not | ---------------- | ---- | ---------------------------------------------------------| | `-d/--deps_only` | none | Only compile dependencies, no project apps will be built | +## completion +{{% blocks/callout type="info" title="Since version 3.23.0" %}} +{{< /blocks/callout >}} +Generates a completion file for one of the supported shells: `bash`, `zsh`. + +Completion files can be generated based on the project setup, so autocompletion also works for all plugins used in the project, not just for default providers. + +To use generated completion files run `source path/to/generated/file`. + +| Option | Type | Description | +| ------- | ------- | --------- | +| `-a/--aliases` | Comma separated list of strings | OS level aliases on which rebar3 completion will be triggered (e.g. `"rebar, r3"`) | +| `-f/--file` | string | Completion file name. If not absolute, it's relative to the `_build//` directory | +| `-s/--shell` | atom | Specify type of the completion file. By default it is autodected using `$SHELL` variable. Valid values are `bash` and `zsh`. + +{{% blocks/callout type="warning" title="zsh specific requirement" %}} +Make sure that `autoload -Uz compinit; compinit` is called in `.zshrc` file. +{{< /blocks/callout >}} + +For better user experience, set default autocompletion and override it when needed. +Default autocompletion can be set by generating a global completion file and loading it in `.bashrc` or `.zshrc`. + +To generate a global (project-independent) completion file run `rebar3 completion --file path/to/global/completion/file` outside a `rebar3` project. + + + ## clean Removes compiled BEAM files from apps. diff --git a/content/en/docs/configuration/configuration.md b/content/en/docs/configuration/configuration.md index 3d21123..2ba1e56 100644 --- a/content/en/docs/configuration/configuration.md +++ b/content/en/docs/configuration/configuration.md @@ -191,6 +191,17 @@ Disable recursive compiling on test and other dirs: }. ``` +## Completion + +```erlang +{completion, + [{aliases,["rebar", "r3"]}, + {file, "/home/user/completion/_rebar3"}, + {shell, bash}]}. +``` + +Options mirror those specified in [Commands](/docs/commands#completion) arguments. + ## Common Test ```erlang @@ -203,7 +214,7 @@ Reference of common test options for `ct_opts`: [https://www.erlang.org/doc/man/ A special option allows to load a default `sys.config` set of entries using `{ct_opts, [{sys_config, ["name.of.config"]}]}`. From the command line, it is however specified as `--sys_config name.of.config`. -Options often exist mirroring those that can be specified in [Commands](/docs/commands) arguments. +Options often exist mirroring those that can be specified in [Commands](/docs/commands/#ct) arguments. ## Cover