Skip to content

Feature/update snippets #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions snippets/convention.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Convention for snippets

## Naming

Naming convention for `description`:

- for operators it's `"<operator>" operator` (e.g. `"in" operator`)
- for functions it's `function definition` or `"<function>" function definition`
- for builtins it's `"<builtin>" invocation` (e.g. `"alias" invocation"`) or
`"<builtin> <subcommand>" invocation` (e.g. `"bits or" invocation"`)
- for shell shebang it's `shebang`
- for anything else it's any string

Naming convention for `prefix`:

- for operators it's `<operator>` (e.g. `in`)
- for functions it's `function`, `<function>` (e.g. `main`)
- for builtins it's `<builtin>` (e.g. `alias`) or `<builtin>-<subcommand>`
(e.g. `bits-or`)
- for shebang it's `shebang`
- for anything else it's any string

If snippet contains a documenting comment than prefix should begin with at `@`
symbol.

Snippets are only created for commands those satisfy at least one condition:

- read data from stdin
- have at least one mandatory or optional argument (not `...rest`)
Here by argument positional argument or argument for an option is meant.

If there are options available for command or a subcommand then there is no
restriction about what options to pick to put in snippet definition.

## Placeholders

Placeholders by default should describe what kind of value is expected like
`${1:path/to/directory}`. But when there is a format defined for placeholder
then example value should be used like `${1:ff}`.

Placeholders can not to list all available choices like
`${1|big5,euc-jp,euc-kr,gbk,iso-8859-1,utf-16,cp1252,latin5|}`. When there are
more then 8 alternatives, provide the most common ones in terms of usage
frequency (it doesn't apply for `date` snippet and placeholders with data
types).
Loading