├── .github
├── CODEOWNERS
├── workflows
│ ├── sync-labels.yml
│ ├── labeler.yml
│ ├── assign.yml
│ ├── trunk-check.yml
│ └── zsh-n.yml
├── ISSUE_TEMPLATE
│ ├── config.yml
│ └── 01_bug_report.yml
└── labeler.yml
├── .trunk
├── out
├── .gitignore
├── configs
│ └── .markdownlint.yaml
└── trunk.yaml
├── .gitattributes
├── docs
├── images
│ ├── z-a-rust.png
│ └── annex-rust.gif
└── README.md
├── .vscode
└── settings.json
├── functions
├── .za-rust-help-handler
├── .za-rust-atload-handler
├── .za-rust-atpull-handler
├── .za-rust-download-file-stdout
├── .za-rust-bin-or-src-function-body
├── .za-rust-atdelete-handler
└── .za-rust-atclone-handler
├── .gitignore
├── LICENSE
├── z-a-rust.plugin.zsh
└── .editorconfig
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @z-shell/tsc
2 |
--------------------------------------------------------------------------------
/.trunk/out:
--------------------------------------------------------------------------------
1 | /home/ss-o/.cache/trunk/repos/ec3857bef14c947c59aab5c9a1012473/out
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | .za* diff=zsh
3 | _zi* diff=zsh
4 |
5 | docs/images/* binary -text
6 |
--------------------------------------------------------------------------------
/docs/images/z-a-rust.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z-shell/z-a-rust/HEAD/docs/images/z-a-rust.png
--------------------------------------------------------------------------------
/docs/images/annex-rust.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z-shell/z-a-rust/HEAD/docs/images/annex-rust.gif
--------------------------------------------------------------------------------
/.trunk/.gitignore:
--------------------------------------------------------------------------------
1 | *out
2 | *logs
3 | *actions
4 | *notifications
5 | plugins
6 | user_trunk.yaml
7 | user.yaml
8 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.associations": {
3 | "*za-*": "zsh"
4 | },
5 | "shellformat.useEditorConfig": true
6 | }
7 |
--------------------------------------------------------------------------------
/functions/.za-rust-help-handler:
--------------------------------------------------------------------------------
1 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2 | # vim: ft=zsh sw=2 ts=2 et
3 | #
4 | # Copyright (c) 2021 Z-Shell Community
5 |
--------------------------------------------------------------------------------
/functions/.za-rust-atload-handler:
--------------------------------------------------------------------------------
1 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2 | # vim: ft=zsh sw=2 ts=2 et
3 | #
4 | # Copyright (c) 2021 Z-Shell Community
5 |
--------------------------------------------------------------------------------
/functions/.za-rust-atpull-handler:
--------------------------------------------------------------------------------
1 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2 | # vim: ft=zsh sw=2 ts=2 et
3 | #
4 | # Copyright (c) 2021 Z-Shell Community
5 |
--------------------------------------------------------------------------------
/.github/workflows/sync-labels.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "♻️ Sync Labels"
3 |
4 | on:
5 | schedule:
6 | - cron: "22 2 * * 2"
7 | workflow_dispatch:
8 |
9 | jobs:
10 | labels:
11 | name: "♻️ Sync labels"
12 | uses: z-shell/.github/.github/workflows/sync-labels.yml@main
13 |
--------------------------------------------------------------------------------
/.trunk/configs/.markdownlint.yaml:
--------------------------------------------------------------------------------
1 | # Autoformatter friendly markdownlint config (all formatting rules disabled)
2 | default: true
3 | blank_lines: false
4 | bullet: false
5 | html: false
6 | indentation: false
7 | line_length: false
8 | spaces: false
9 | url: false
10 | whitespace: false
11 |
--------------------------------------------------------------------------------
/.github/workflows/labeler.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: 🔖 Pull Request Labeler
3 | on:
4 | pull_request_target:
5 |
6 | permissions:
7 | contents: read
8 | pull-requests: write
9 |
10 | jobs:
11 | triage:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - uses: actions/labeler@v4
15 | with:
16 | repo-token: "${{ secrets.GH_PAT }}"
17 | sync-labels: false
18 |
--------------------------------------------------------------------------------
/.github/workflows/assign.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "❇️ Assign"
3 |
4 | on:
5 | issues:
6 | types:
7 | - opened
8 | pull_request:
9 | types:
10 | - labeled
11 |
12 | jobs:
13 | assign:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/add-to-project@main
17 | with:
18 | project-url: https://github.com/orgs/z-shell/projects/4
19 | github-token: ${{ secrets.GH_PAT }}
20 | labeled: bug 🐞, triage 📑, package 📦
21 | label-operator: OR
22 |
--------------------------------------------------------------------------------
/.github/workflows/trunk-check.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "⭕ Trunk"
3 | on:
4 | push:
5 | branches: [main]
6 | tags: ["v*.*.*"]
7 | pull_request:
8 | types: [opened, synchronize]
9 | schedule:
10 | - cron: "0 05 * * 5"
11 | workflow_dispatch:
12 |
13 | jobs:
14 | check:
15 | if: github.event.schedule != '0 05 * * 5'
16 | name: "⚡"
17 | uses: z-shell/.github/.github/workflows/trunk.yml@main
18 | upload:
19 | if: github.event.schedule == '0 05 * * 5'
20 | name: "🆙"
21 | uses: z-shell/.github/.github/workflows/trunk.yml@main
22 | secrets:
23 | trunk-token: ${{ secrets.TRUNK_TOKEN }}
24 |
--------------------------------------------------------------------------------
/.trunk/trunk.yaml:
--------------------------------------------------------------------------------
1 | version: 0.1
2 | cli:
3 | version: 1.4.0
4 | plugins:
5 | sources:
6 | - id: trunk
7 | ref: v0.0.8
8 | uri: https://github.com/trunk-io/plugins
9 | lint:
10 | enabled:
11 | - gitleaks@8.15.3
12 | - markdownlint@0.33.0
13 | - oxipng@8.0.0
14 | - prettier@2.8.3
15 | - git-diff-check
16 | - actionlint@1.6.23
17 | - oxipng@8.0.0
18 | - gitleaks@8.15.3
19 | - markdownlint@0.33.0
20 | - prettier@2.8.3
21 | - git-diff-check
22 | - actionlint@1.6.23
23 | runtimes:
24 | enabled:
25 | - go@1.18.3
26 | - node@18.12.1
27 | actions:
28 | enabled:
29 | - trunk-announce
30 | - trunk-check-pre-push
31 | - trunk-fmt-pre-commit
32 | - trunk-upgrade-available
33 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | ---
2 | blank_issues_enabled: true
3 | contact_links:
4 | - name: ZI Wiki
5 | url: https://z.digitalclouds.dev
6 | about: Knowledge base.
7 | - name: Community Discussions
8 | url: https://github.com/orgs/z-shell/discussions
9 | about: Please ask and answer questions here.
10 | - name: Slack Workspace
11 | url: https://join.slack.com/t/z-shell/shared_invite/zt-16twpopd2-p08ROUeT2aGZ5njJwysawA
12 | about: Join to ask and answer questions or collaborate.
13 | - name: Crowdin Translations
14 | url: https://digitalclouds.crowdin.com/z-shell
15 | about: Join to participate in translations.
16 | - name: Z-Shell Portfolio
17 | url: https://github.zshell.dev/
18 | about: Z-Shell organization portfolio and governance.
19 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ❮ Zi ❯ Annex - Rust
5 |
6 |
7 |
An Annex that installs rust and cargo packages locally inside the plugin or snippet directories
8 | 
9 |
10 |
11 | ## 💡 Wiki: [rust](https://wiki.zshell.dev/ecosystem/annexes/rust) - [annexes](https://wiki.zshell.dev/ecosystem/category/-annexes)
12 |
13 | ## Install
14 |
15 | Simply load like a regular plugin, i.e.:
16 |
17 | ```zsh
18 | zi light z-shell/z-a-rust
19 | ```
20 |
21 | This installs the annex and makes the `rustup` and `cargo''` ices available.
22 |
23 | ---
24 |
25 | > **Note**
26 | >
27 | > This repository compatible with [Zi](https://github.com/z-shell/zi)
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Cargo
2 | # will have compiled files and executables
3 | /target/
4 |
5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
7 | Cargo.lock
8 |
9 | # These are backup files generated by rustfmt
10 | **/*.rs.bk
11 |
12 | ### Zsh
13 | # Zsh compiled script + zrecompile backup
14 | *.zwc
15 | *.zwc.old
16 |
17 | # Zsh completion-optimization dumpfile
18 | *zcompdump*
19 |
20 | # Zsh zcalc history
21 | .zcalc_history
22 |
23 | # A popular plugin manager's files
24 | ._zi
25 | ._zinit
26 | .zinit_lastupd
27 | .zi_lastupd
28 |
29 | # zshelldoc tool's files
30 | docs/zsdoc/data
31 |
32 | # robbyrussell/oh-my-zsh/plugins/per-directory-history plugin's files
33 | # (when set-up to store the history in the local directory)
34 | .directory_history
35 |
36 | # MichaelAquilina/zsh-autoswitch-virtualenv plugin's files
37 | # (for Zsh plugins using Python)
38 | .venv
39 |
40 | # Zunit tests' output
41 | /tests/_output/*
42 | !/tests/_output/.gitkeep
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Z-Shell
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.github/labeler.yml:
--------------------------------------------------------------------------------
1 | documentation 📝:
2 | - "docs/**/*.md"
3 | - "community/**/*.md"
4 | - "ecosystem/**/*.md"
5 | dependencies 📦:
6 | - "package.json"
7 | - "pnpm-lock.yaml"
8 | - "yarn.lock"
9 | enhancement ✨:
10 | - "functions/**"
11 | - "src/**"
12 | - "lib/**"
13 | maintenance 📈:
14 | - ".all-contributorsrc"
15 | - ".deepsource.toml"
16 | - ".editorconfig"
17 | - ".gitattributes"
18 | - ".gitignore"
19 | - ".github/CODEOWNERS"
20 | - ".github/*.md"
21 | - ".github/*.yml"
22 | - ".github/*.yaml"
23 | - ".github/*.json"
24 | - ".markdownlint.json"
25 | - ".prettierrc"
26 | - ".prettierignore"
27 | - ".trunk/*.yaml"
28 | - ".trunk/*.json"
29 | - ".trunk/*rc"
30 | - ".vscode/**"
31 | - "babel.config.js"
32 | - "docusaurus.config.js"
33 | - "crowdin.yml"
34 | - "netlify.toml"
35 | - "tsconfig.json"
36 | i18n 🌐:
37 | - "i18n/**"
38 | - "docs/i18n/**"
39 | annex 🌀:
40 | - "*"
41 | #package 📦:
42 | # - 'ecosystem/packages/**/*.md'
43 | # - 'i18n/**/docusaurus-plugin-content-ecosystem/**/packages/**/*.md'
44 | #plugin ⚙️:
45 | # - 'ecosystem/plugins/**.md'
46 | # - 'i18n/**/docusaurus-plugin-content-ecosystem/**/plugins/**/*.md'
47 | ci 🤖:
48 | - ".github/workflows/*"
49 |
--------------------------------------------------------------------------------
/z-a-rust.plugin.zsh:
--------------------------------------------------------------------------------
1 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2 | # vim: ft=zsh sw=2 ts=2 et
3 | #
4 | # Copyright (c) 2021 Z-Shell Community
5 | #
6 | # According to the Zsh Plugin Standard:
7 | # https://wiki.zshell.dev/community/zsh_plugin_standard/#zero-handling
8 | 0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
9 | 0="${${(M)0:#/*}:-$PWD/$0}"
10 |
11 | # https://wiki.zshell.dev/community/zsh_plugin_standard/#funtions-directory
12 | if [[ $PMSPEC != *f* ]]; then
13 | fpath+=( "${0:h}/functions" )
14 | fi
15 |
16 | # https://wiki.zshell.dev/community/zsh_plugin_standard/#the-proposed-function-name-prefixes
17 | autoload -Uz .za-rust-{bin-or-src-function-body,download-file-stdout,{atload,atclone,atpull,atdelete,help}-handler}
18 |
19 | # An empty stub to fill the help handler fields
20 | .za-rust-null-handler() { :; }
21 |
22 | @zi-register-annex "z-a-rust" hook:atload-40 \
23 | .za-rust-atload-handler \
24 | .za-rust-help-handler "rustup|cargo''" # also register new ices
25 |
26 | @zi-register-annex "z-a-rust" hook:atclone-40 \
27 | .za-rust-atclone-handler \
28 | .za-rust-null-handler
29 |
30 | @zi-register-annex "z-a-rust" hook:\%atpull-40 \
31 | .za-rust-atclone-handler \
32 | .za-rust-null-handler
33 |
34 | @zi-register-annex "z-a-rust" hook:atdelete-40 \
35 | .za-rust-atdelete-handler \
36 | .za-rust-null-handler
37 |
--------------------------------------------------------------------------------
/functions/.za-rust-download-file-stdout:
--------------------------------------------------------------------------------
1 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2 | # vim: ft=zsh sw=2 ts=2 et
3 | #
4 | # Copyright (c) 2021 Z-Shell Community
5 | #
6 | # FUNCTION: .za-rust-download-file-stdout [[[
7 | # Downloads file to stdout. Supports following backend commands:
8 | # curl, wget, lftp, lynx. Used by snippet loading.
9 |
10 | local url="$1" restart="$2"
11 | builtin setopt localoptions localtraps
12 |
13 | if (( restart )); then
14 | (( ${path[(I)/usr/local/bin]} )) || \
15 | {
16 | path+=( "/usr/local/bin" );
17 | trap "path[-1]=()" EXIT
18 | }
19 |
20 | if (( ${+commands[curl]} )) then
21 | command curl -fsSL "$url" || return 1
22 | elif (( ${+commands[wget]} )); then
23 | command wget -q "$url" -O - || return 1
24 | elif (( ${+commands[lftp]} )); then
25 | command lftp -c "cat $url" || return 1
26 | elif (( ${+commands[lynx]} )) then
27 | command lynx -source "$url" || return 1
28 | else
29 | return 2
30 | fi
31 | else
32 | if type curl 2>/dev/null 1>&2; then
33 | command curl -fsSL "$url" || return 1
34 | elif type wget 2>/dev/null 1>&2; then
35 | command wget -q "$url" -O - || return 1
36 | elif type lftp 2>/dev/null 1>&2; then
37 | command lftp -c "cat $url" || return 1
38 | else
39 | .za-rust-download-file-stdout "$url" "1"
40 | return $?
41 | fi
42 | fi
43 |
44 | return 0
45 |
--------------------------------------------------------------------------------
/.github/workflows/zsh-n.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "✅ Zsh"
3 | on:
4 | push:
5 | tags: ["v*.*.*"]
6 | branches:
7 | - main
8 | - next
9 | paths:
10 | - "*.zsh"
11 | - "functions/*"
12 | pull_request:
13 | paths:
14 | - "*.zsh"
15 | - "functions/*"
16 | workflow_dispatch: {}
17 |
18 | jobs:
19 | zsh-matrix:
20 | runs-on: ubuntu-latest
21 | outputs:
22 | matrix: ${{ steps.set-matrix.outputs.matrix }}
23 | steps:
24 | - name: ⤵️ Check out code from GitHub
25 | uses: actions/checkout@v3
26 | - name: "⚡ Set matrix output"
27 | id: set-matrix
28 | run: |
29 | MATRIX="$(find . -type d -name 'doc' -prune -o -type f \( -iname '*.zsh' -o -iname '.za-*' \) -print | jq -ncR '{"include": [{"file": inputs}]}')"
30 | echo "MATRIX=${MATRIX}" >&2
31 | echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
32 | zsh-n:
33 | runs-on: ubuntu-latest
34 | needs: zsh-matrix
35 | strategy:
36 | fail-fast: false
37 | matrix: ${{ fromJSON(needs.zsh-matrix.outputs.matrix) }}
38 | steps:
39 | - name: ⤵️ Check out code from GitHub
40 | uses: actions/checkout@v3
41 | - name: "⚡ Install dependencies"
42 | run: sudo apt update && sudo apt-get install -yq zsh
43 | - name: "⚡ zsh -n: ${{ matrix.file }}"
44 | env:
45 | ZSH_FILE: ${{ matrix.file }}
46 | run: |
47 | zsh -n "${ZSH_FILE}"
48 | - name: "⚡ zcompile ${{ matrix.file }}"
49 | env:
50 | ZSH_FILE: ${{ matrix.file }}
51 | run: |
52 | zsh -fc "zcompile ${ZSH_FILE}"; rc=$?
53 | ls -al "${ZSH_FILE}.zwc"; exit "$rc"
54 |
--------------------------------------------------------------------------------
/functions/.za-rust-bin-or-src-function-body:
--------------------------------------------------------------------------------
1 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2 | # vim: ft=zsh sw=2 ts=2 et
3 | #
4 | # Copyright (c) 2021 Z-Shell Community
5 | #
6 | # FUNCTION: .za-bgn-bin-or-src-function-body
7 | # Returns the body of the function wrapping a binary
8 |
9 | local name="$2" bin="$3" dir="$4"
10 | integer run_type="$1" set_rust_home_vars="$5" \
11 | set_gem_home="$6" set_node_path="$7" set_cwd="$8" \
12 | use_all_null="$9" use_err_null="$10" use_out_null="$11"
13 |
14 | local nl=$'\n' tab=$' '
15 |
16 | REPLY="function ${(q)name} {
17 | local bindir=${(qqq)bin:h}
18 | local -x PATH=${(qqq)dir}/bin:\"\$PATH\"
19 | ${${(M)set_rust_home_vars:#1}:+local -x RUSTUP_HOME=${(qqq)dir}/rustup CARGO_HOME=${(qqq)dir}}
20 | ${${(M)set_gem_home:#1}:+local -x GEM_HOME=${(qqq)dir}}
21 | ${${(M)set_node_path:#1}:+local -x NODE_PATH=${(qqq)dir}/node_modules}
22 | ${${(M)set_cwd:#1}:+"local oldpwd=${(qqq)PWD}
23 | () { setopt localoptions noautopushd; builtin cd -q ${(qqq)dir}; }"}
24 | "
25 |
26 | if (( run_type == 0 )); then
27 | REPLY+="$tab\"\$bindir\"/${(qqq)bin:t} \"\$@\""
28 | elif (( run_type == 1 )); then
29 | REPLY+="$tab() { source \"\$bindir\"/${(qqq)bin:t}; } \"\$@\""
30 | elif (( run_type == 2 )); then
31 | REPLY+="$tab() { eval \"\$(<\"\$bindir\"/${(qqq)bin:t})\"; } \"\$@\""
32 | fi
33 |
34 | (( use_all_null )) && REPLY+=" &>/dev/null"
35 | (( use_err_null )) && REPLY+=" 2>/dev/null"
36 | (( use_out_null )) && REPLY+=" >/dev/null"
37 |
38 | REPLY+="$nl"
39 | REPLY+="${${(M)set_cwd:#1}:+"$nl$tab() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}
40 | }"
41 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Space or Tabs?
2 | # https://stackoverflow.com/questions/35649847/objective-reasons-for-using-spaces-instead-of-tabs-for-indentation
3 | # https://stackoverflow.com/questions/12093748/how-to-use-tabs-instead-of-spaces-in-a-shell-script
4 | # https://github.com/editorconfig/editorconfig-defaults/blob/master/editorconfig-defaults.json
5 | #
6 | # 1. What happens when I press the Tab key in my text editor?
7 | # 2. What happens when I request my editor to indent one or more lines?
8 | # 3. What happens when I view a file containing U+0009 HORIZONTAL TAB characters?
9 | #
10 | # Answers:
11 | #
12 | # 1. Pressing the Tab key should indent the current line (or selected lines) one additional level.
13 | # 2. As a secondary alternative, I can also tolerate an editor that,
14 | # like Emacs, uses this key for a context-sensitive fix-my-indentation command.
15 | # 3. Indenting one or more lines should follow the reigning convention, if consensus is sufficiently strong; otherwise,
16 | # I greatly prefer 2-space indentation at each level. U+0009 characters should shift subsequent characters to the next tab stop.
17 | #
18 | # Note: VIM users should use alternate marks [[[ and ]]] as the original ones can confuse nested substitutions, e.g.: ${${${VAR}}}
19 | #
20 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
21 | # vim: ft=zsh sw=2 ts=2 et
22 |
23 | root = true
24 |
25 | [*]
26 | charset = utf-8
27 | indent_style = space
28 | indent_size = 2
29 | insert_final_newline = true
30 | trim_trailing_whitespace = true
31 |
32 | [*.sln]
33 | indent_style = tab
34 |
35 | [*.{md,mdx,rst}]
36 | trim_trailing_whitespace = false
37 |
38 | [*.{cmd,bat}]
39 | end_of_line = crlf
40 |
41 | [*za-*]
42 | end_of_line = lf
43 |
44 | [*.{sh,bash,zsh,fish}]
45 | end_of_line = lf
46 |
47 | [Makefile]
48 | indent_style = tab
49 | indent_size = 4
50 |
51 | [*.{py,rb}]
52 | indent_size = 4
53 |
54 | [*.{go,java,scala,groovy,kotlin}]
55 | indent_style = tab
56 | indent_size = 4
57 |
58 | [*.{cs,csx,cake,vb,vbx}]
59 | # Default Severity for all .NET Code Style rules below
60 | dotnet_analyzer_diagnostic.severity = warning
61 |
--------------------------------------------------------------------------------
/functions/.za-rust-atdelete-handler:
--------------------------------------------------------------------------------
1 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2 | # vim: ft=zsh sw=2 ts=2 et
3 | #
4 | # Copyright (c) 2021 Z-Shell Community
5 | #
6 | # FUNCTION: .za-rust-atdelete-handler [[[
7 |
8 | builtin emulate -RL zsh ${=${options[xtrace]:#off}:+-o xtrace}
9 | builtin setopt extendedglob warncreateglobal typesetsilent noshortloops
10 |
11 | [[ "$1" = plugin ]] && \
12 | local type="$1" user="$2" plugin="$3" id_as="$4" dir="$5" hook="$6" || \
13 | local type="$1" url="$2" id_as="$3" dir="$4" hook="$5"
14 |
15 | local nl=$'\n'
16 |
17 | if [[ -n "${ICE[cargo]}" ]] {
18 | local -a cargos bin_pkg_dst tmpsdst
19 | cargos=( "${(s.;.)ICE[cargo]}" )
20 |
21 | local cargo
22 |
23 | for cargo ( $cargos ) {
24 | bin_pkg_dst=( ${(@s.->.)cargo} )
25 | bin_pkg_dst=( "${bin_pkg_dst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
26 | tmpsdst=( ${(@s.<-.)bin_pkg_dst[1]} )
27 | tmpsdst=( "${tmpsdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
28 | if (( ${#tmpsdst} > 1 )); then
29 | bin_pkg_dst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${bin_pkg_dst[2]:-${tmpdist[2]#\!}}" )
30 | else
31 | bin_pkg_dst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${bin_pkg_dst[2]:-${bin_pkg_dst[1]#\!}}" )
32 | fi
33 | bin_pkg_dst=( "${bin_pkg_dst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
34 | if [[ ${bin_pkg_dst[2]} = \!* ]]; then
35 | bin_pkg_dst[2]=${bin_pkg_dst[2]#\!}
36 | bin_pkg_dst[1]=${bin_pkg_dst[1]##[a-zA-Z]##:}
37 | bin_pkg_dst[2]=${bin_pkg_dst[2]##[a-zA-Z]##:}
38 | bin_pkg_dst[3]=${bin_pkg_dst[3]##[a-zA-Z]##:}
39 | else
40 | continue
41 | fi
42 |
43 | local target_binary="${${(M)bin_pkg_dst[1]:#/*}:-$dir/bin/${bin_pkg_dst[1]}}" \
44 | fnam="${bin_pkg_dst[3]:-${bin_pkg_dst[1]:t}}"
45 | local file="$ZPFX/bin/$fnam"
46 |
47 | if [[ -f $file ]]; then
48 | command rm -f "$file"
49 | if [[ -f $file ]]; then
50 | +zi-message "{annex}rust-annex{ehi}:{rst} {error}Could not remove the {pname}${fnam}{error} shim from {var}\$ZPFX/bin{error}, verify the permissions{rst}"
51 | else
52 | +zi-message "{annex}rust-annex{ehi}:{rst} Correctly removed the {pname}${fnam}{rst} shim from {var}\$ZPFX/bin{rst}" || \
53 | fi
54 | else
55 | +zi-message "{annex}rust-annex{ehi}:{rst} {error}The {pname}${fnam}{error} shim did not exist in {var}\$ZPFX/bin{error} or is not a regular file{rst}"
56 | fi
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/01_bug_report.yml:
--------------------------------------------------------------------------------
1 | name: "🐞 Bug report"
2 | description: File a bug report
3 | title: "[bug]: "
4 | labels: ["bug 🐞", "triage 📑"]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | First off, thanks for taking the time to contribute! Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.
10 | - type: input
11 | id: environment
12 | attributes:
13 | label: Environment
14 | description: >
15 | Please describe your environment e.g: echo "OSTYPE=${OSTYPE} CPUTYPE=$(uname -m) / MACHINE_TYPE=$MACHTYPE ZSH_VERSION=${ZSH_VERSION}"
16 |
17 | It may contain any additional information which would help to reproduce the issue.
18 | placeholder: "OSTYPE=linux-gnu CPUTYPE=x86_64 / MACHINE_TYPE=x86_64 ZSH_VERSION=5.8"
19 | validations:
20 | required: true
21 | - type: textarea
22 | id: expected
23 | attributes:
24 | label: Expected behavior
25 | description: "Please describe the expected behavior"
26 | validations:
27 | required: true
28 | - type: textarea
29 | id: current
30 | attributes:
31 | label: Current behavior
32 | description: "Please describe how the bug manifests"
33 | validations:
34 | required: true
35 | - type: textarea
36 | id: reproduce
37 | attributes:
38 | label: Steps to reproduce
39 | description: "Explain the steps required to duplicate the issue"
40 | validations:
41 | required: true
42 | - type: textarea
43 | id: code-snippet
44 | attributes:
45 | label: Code snippet
46 | description: "Please insert your zshrc or just a short code snippet in concern"
47 | validations:
48 | required: true
49 | - type: textarea
50 | id: additional
51 | attributes:
52 | label: Aditional information
53 | description: "List any other information that is relevant to your issue. For reports and stats run `zi analytics`"
54 | validations:
55 | required: true
56 | - type: checkboxes
57 | attributes:
58 | label: Self-service
59 | description: |
60 | If you feel like you could contribute to this issue, please check the box below. This would tell us and other people looking for contributions that someone's working on it.
61 | If you do check this box, please send a pull request within 7 days so we can still delegate this to someone else.
62 | options:
63 | - label: I'd be willing to address this documentation request myself.
64 | - type: checkboxes
65 | attributes:
66 | label: Have you read the Contributing Guidelines?
67 | options:
68 | - label: I have read the [Contributing Guidelines](https://github.com/z-shell/community/blob/main/docs/CONTRIBUTING_GUIDELINES.md).
69 | required: true
70 | - type: checkboxes
71 | attributes:
72 | label: Are you familiar with Contributor Covenant Code of Conduct?
73 | options:
74 | - label: I have read the [Contributor Covenant Code of Conduct](https://github.com/z-shell/zi/blob/main/docs/CODE_OF_CONDUCT.md).
75 | required: true
76 | - type: input
77 | id: contact
78 | attributes:
79 | label: Contact Details
80 | description: How can we get in touch with you if we need more info?
81 | placeholder: ex. email@example.com
82 | validations:
83 | required: false
84 |
--------------------------------------------------------------------------------
/functions/.za-rust-atclone-handler:
--------------------------------------------------------------------------------
1 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2 | # vim: ft=zsh sw=2 ts=2 et
3 | #
4 | # Copyright (c) 2021 Z-Shell Community
5 |
6 | builtin emulate -RL zsh ${=${options[xtrace]:#off}:+-o xtrace}
7 | builtin setopt extendedglob warncreateglobal typesetsilent noshortloops
8 |
9 | typeset -g za_rust_ef
10 | za_rust_ef=( ${(k)functions} )
11 | trap "unset -f -- \"\${(k)functions[@]:|za_rust_ef}\" &>/dev/null; unset za_rust_ef" EXIT
12 | trap "unset -f -- \"\${(k)functions[@]:|za_rust_ef}\" &>/dev/null; unset za_rust_ef; return 1" INT
13 |
14 | [[ "$1" = plugin ]] && \
15 | local type="$1" user="$2" plugin="$3" id_as="$4" dir="$5" hook="$6" || \
16 | local type="$1" url="$2" id_as="$3" dir="$4" hook="$5"
17 |
18 | if [[ $OSTYPE == cygwin ]]; then
19 | dir=`cygpath -w $dir`
20 | fi
21 |
22 | local nl=$'\n'
23 |
24 | if (( ${+ICE[rustup]} )) {
25 | if [[ $hook = *atclone-<-> ]] {
26 | (
27 | builtin cd -q "$dir" || {
28 | +zi-message "{annex}rust-annex{ehi}:{rst} {error}An internal error, please report at: {url}https://github.com/z-shell/z-a-rust/issues{rst}"
29 | return 1
30 | }
31 | command mkdir -p bin rustup
32 | .za-rust-download-file-stdout 'https://sh.rustup.rs' 0 >! bin/rustup-init || \
33 | {
34 | .za-rust-download-file-stdout 'https://sh.rustup.rs' 1 >! bin/rustup-init || \
35 | {
36 | +zi-message "{annex}rust-annex{ehi}:{rst} {error}Could not download the {pname}rustup.rs{error} installer{rst}"
37 | return 0
38 | }
39 | }
40 | command chmod +x bin/rustup-init
41 | local -x CARGO_HOME="$dir" RUSTUP_HOME="$dir/rustup"
42 | if (( !OPTS[opt_-q,--quiet] )) {
43 | +zi-message "{annex}rust-annex{ehi}:{rst} Running the rustup installer…{rst}"
44 | bin/rustup-init -y --no-modify-path |& command grep -E '(installing|installed)'
45 | bin/rustup component remove rust-docs
46 | } else {
47 | bin/rustup-init -y --no-modify-path &> /dev/null
48 | bin/rustup component remove rust-docs &> /dev/null
49 | }
50 | ) || return 0
51 | } else {
52 | (
53 | builtin cd -q "$dir" || {
54 | +zi-message "{annex}rust-annex{ehi}:{rst} {error}An internal error, please report at: {url}https://github.com/z-shell/z-a-rust/issues{rst}"
55 | return 1
56 | }
57 | local -x CARGO_HOME="$dir" RUSTUP_HOME="$dir/rustup" PATH="$dir/bin:$PATH"
58 | if (( !OPTS[opt_-q,--quiet] )) {
59 | +zi-message "{annex}rust-annex{ehi}:{rst} Running \`rustup update'…{rst}"
60 | command rustup update |& command grep -E -i '(error|warning|installing|info: latest update )'
61 | } else {
62 | command rustup update &> /dev/null
63 | }
64 | )
65 | }
66 | }
67 |
68 | if [[ -n "${ICE[cargo]}" ]] {
69 | local -a cargo_defs bin_pkg_dst tmpsdst cargos
70 | cargo_defs=( "${(s.;.)ICE[cargo]}" )
71 |
72 | local cargo
73 |
74 | for cargo ( $cargo_defs ) {
75 | bin_pkg_dst=( ${(@s.->.)cargo} )
76 | tmpsdst=( ${(@s.<-.)bin_pkg_dst[1]} )
77 | if (( ${#tmpsdst} > 1 )); then
78 | bin_pkg_dst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${bin_pkg_dst[2]:-${tmpdist[2]#\!}}" )
79 | else
80 | bin_pkg_dst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${bin_pkg_dst[2]:-${bin_pkg_dst[1]#\!}}" )
81 | fi
82 | bin_pkg_dst=( "${bin_pkg_dst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
83 | bin_pkg_dst[2]=${bin_pkg_dst[2]#\!}
84 | bin_pkg_dst[1]=${bin_pkg_dst[1]##[a-zA-Z]##:}
85 | bin_pkg_dst[2]=${bin_pkg_dst[2]##[a-zA-Z]##:}
86 | bin_pkg_dst[3]=${bin_pkg_dst[3]##[a-zA-Z]##:}
87 | cargos+=( ${bin_pkg_dst[2]} )
88 | }
89 |
90 | (( ${#cargos} )) && {
91 | if [[ "$hook" = *atclone-<-> ]]; then
92 | +zi-message "{annex}rust-annex{ehi}:{rst} Instaling the requested crates…{rst}"
93 | if (( ${+ICE[rustup]} )) {
94 | local -x CARGO_HOME="$dir" RUSTUP_HOME="$dir/rustup" PATH="$dir/bin:$PATH"
95 | command $dir/bin/cargo install --force --root "$dir" "${cargos[@]}"
96 | } else {
97 | cargo install --force --root "$dir" "${cargos[@]}"
98 | }
99 | elif [[ "$hook" = *atpull-<-> ]]; then
100 | if (( !OPTS[opt_-q,--quiet] )) {
101 | +zi-message "{annex}rust-annex{ehi}:{rst} Updating the installed crates…{rst}"
102 | }
103 | local toml_dir
104 | local -a tomls
105 | tomls=( "$dir"/**/Cargo.toml(N.) )
106 | for toml_dir ( ${tomls:h} ) {
107 | (
108 | builtin cd -q "$toml_dir" && {
109 | if (( ${+ICE[rustup]} )) {
110 | local -x CARGO_HOME="$dir" RUSTUP_HOME="$dir/rustup" PATH="$dir/bin:$PATH"
111 | command $dir/bin/cargo update
112 | command $dir/bin/cargo build
113 | } else {
114 | cargo update
115 | cargo build
116 | }
117 | }
118 | )
119 | }
120 | fi
121 | }
122 | }
123 |
124 | if [[ -n "${ICE[cargo]}" ]] {
125 | local -a cargos bin_pkg_dst
126 | cargos=( "${(s.;.)ICE[cargo]}" )
127 |
128 | local cargo
129 |
130 | for cargo ( $cargos ) {
131 | integer set_rust_home_vars=0 \
132 | set_gem_home=0 set_node_path=0 set_cwd=0 \
133 | use_all_null=0 use_err_null=0 use_out_null=0
134 |
135 | bin_pkg_dst=( ${(@s.->.)cargo} )
136 | bin_pkg_dst=( "${bin_pkg_dst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
137 | tmpsdst=( ${(@s.<-.)bin_pkg_dst[1]} )
138 | tmpsdst=( "${tmpsdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
139 | if (( ${#tmpsdst} > 1 )); then
140 | bin_pkg_dst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${bin_pkg_dst[2]:-${tmpdist[2]#\!}}" )
141 | else
142 | bin_pkg_dst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${bin_pkg_dst[2]:-${bin_pkg_dst[1]#\!}}" )
143 | fi
144 | bin_pkg_dst=( "${bin_pkg_dst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
145 | if [[ ${bin_pkg_dst[2]} = \!* ]]; then
146 | bin_pkg_dst[2]=${bin_pkg_dst[2]#\!}
147 | [[ ${bin_pkg_dst[2]} = [gncNEO]#R[gncNEO]#:* ]] && set_rust_home_vars=1
148 | [[ ${bin_pkg_dst[2]} = [gncNEO]#g[gncNEO]#:* ]] && set_gem_home=1
149 | [[ ${bin_pkg_dst[2]} = [gncNEO]#n[gncNEO]#:* ]] && set_node_path=1
150 | [[ ${bin_pkg_dst[2]} = [gncNEO]#c[gncNEO]#:* ]] && set_cwd=1
151 | [[ ${bin_pkg_dst[2]} = [gncNEO]#N[gncNEO]#:* ]] && use_all_null=1
152 | [[ ${bin_pkg_dst[2]} = [gncNEO]#E[gncNEO]#:* ]] && use_err_null=1
153 | [[ ${bin_pkg_dst[2]} = [gncNEO]#O[gncNEO]#:* ]] && use_out_null=1
154 | bin_pkg_dst[1]=${bin_pkg_dst[1]##[a-zA-Z]##:}
155 | bin_pkg_dst[2]=${bin_pkg_dst[2]##[a-zA-Z]##:}
156 | bin_pkg_dst[3]=${bin_pkg_dst[3]##[a-zA-Z]##:}
157 | else
158 | continue
159 | fi
160 |
161 | local target_binary="${${(M)bin_pkg_dst[1]:#/*}:-$dir/bin/${bin_pkg_dst[1]}}" \
162 | fnam="${bin_pkg_dst[3]:-${bin_pkg_dst[1]:t}}"
163 | local file="$ZPFX/bin/$fnam"
164 |
165 | .za-rust-bin-or-src-function-body 0 "$fnam" "$target_binary" "$dir" \
166 | "${${(M)set_rust_home_vars:#1}:-${+ICE[rustup]}}" \
167 | "$set_gem_home" "$set_node_path" "$set_cwd" \
168 | "$use_all_null" "$use_err_null" "$use_out_null"
169 |
170 | builtin print -r -- "#!/usr/bin/env zsh$nl$nl$REPLY$nl$nl$fnam \"\$@\"" >! "$file"
171 | command chmod +x "$file"
172 |
173 | if [[ -x $file ]]; then
174 | if (( !OPTS[opt_-q,--quiet] )); then
175 | if [[ $hook == atclone-<-> || $ZI[annex-multi-flag:pull-active] -ge 1 ]]; then
176 | +zi-message "{annex}rust-annex{ehi}:{rst} ${${hook:#*atclone-<->}:+Re-}Created the {pname}${fnam}{rst} shim"
177 | fi
178 | fi
179 | else
180 | +zi-message "{annex}rust-annex{ehi}:{rst} {error}Something went wrong while creating the {pname}${fnam}{rst} shim"
181 | fi
182 | }
183 | }
184 |
--------------------------------------------------------------------------------