Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

docs: Add Shell Script language documentation (#23248)

Peter Tripp8e1ad7d47568
diff --git a/docs/src/languages.md b/docs/src/languages.md
index befa2aded03..fb80ddb6806 100644
--- a/docs/src/languages.md
+++ b/docs/src/languages.md
@@ -55,6 +55,7 @@ Zed supports hundreds of programming languages and text formats. Some work out-o
- [Rust](./languages/rust.md)
- [Scala](./languages/scala.md)
- [Scheme](./languages/scheme.md)
+- [Shell Script](./languages/sh.md)
- [Svelte](./languages/svelte.md)
- [Swift](./languages/swift.md)
- [TailwindCSS](./languages/tailwindcss.md)
diff --git a/docs/src/languages/bash.md b/docs/src/languages/bash.md
index 708be2f00f8..1b1e9008d04 100644
--- a/docs/src/languages/bash.md
+++ b/docs/src/languages/bash.md
@@ -8,17 +8,29 @@ Report issues to: [https://github.com/d1y/bash.zed/issues](https://github.com/d1
## Configuration
-The bash-language-server support shellcheck. But you need to install it manually:
+When `shellcheck` is available `bash-language-server` will use it internally to provide diagnostics.
+
+### Install `shellcheck`:
```sh
-# macOS
-brew install shellcheck
+brew install shellcheck # macOS (HomeBrew)
+apt-get install shellcheck # Ubuntu/Debian
+pacman -S shellcheck # ArchLinux
+dnf install shellcheck # Fedora
+yum install shellcheck # CentOS/RHEL
+zypper install shellcheck # openSUSE
+choco install shellcheck # Windows (Chocolatey)
+```
-# Ubuntu/Debian
-sudo apt-get install shellcheck
+And verify it is available from your path:
-# Arch Linux
-pacman -S shellcheck
+```sh
+which shellcheck
+shellcheck --version
```
If you wish to customize the warnings/errors reported you just need to create a `.shellcheckrc` file. You can do this in the root of your project or in your home directory (`~/.shellcheckrc`). See: [shellcheck documentation](https://github.com/koalaman/shellcheck/wiki/Ignore#ignoring-one-or-more-types-of-errors-forever) for more.
+
+### See also:
+
+- [Zed Docs: Language Support: Shell Scripts](./sh.md)
diff --git a/docs/src/languages/sh.md b/docs/src/languages/sh.md
new file mode 100644
index 00000000000..2491b73ccf7
--- /dev/null
+++ b/docs/src/languages/sh.md
@@ -0,0 +1,62 @@
+# Shell Scripts
+
+Shell Scripts (bash, zsh, dash, sh) are supported natively by Zed.
+
+- Tree Sitter: [tree-sitter/tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash)
+
+## Settings
+
+You can configure various settings for Shell Scripts in your Zed User Settings (`~/.config/zed/settings.json`) or Zed Project Settings (`.zed/settings.json`):
+
+```json
+ "languages": {
+ "Shell Script": {
+ "tab_size": 2,
+ "hard_tabs": false
+ }
+ }
+```
+
+### Formatting
+
+Zed supports auto-formatting Shell Scripts using external tools like [`shfmt`](https://github.com/patrickvane/shfmt).
+
+1. Install `shfmt`:
+
+```sh
+brew install shfmt # macos (homebrew)
+sudo apt-get install shfmt # debian/ubuntu
+dnf install shfmt # fedora
+yum install shfmt # redhat
+pacman -Sy shfmt # archlinux
+choco install shfmt # windows (chocolatey)
+```
+
+2. Ensure `shfmt` is available in your path and check the version:
+
+```sh
+which shfmt
+shfmt --version
+```
+
+3. Configure Zed to automatically format Shell Scripts with `shfmt` on save:
+
+```json
+ "languages": {
+ "Shell Script": {
+ "format_on_save": "on",
+ "formatter": {
+ "external": {
+ "command": "shfmt",
+ // Change `--indent 2` to match your preferred tab_size
+ "arguments": ["--filename", "{buffer_path}", "--indent", "2"]
+ }
+ }
+ }
+ }
+```
+
+## See also:
+
+- [Zed Docs: Language Support: Bash](./bash.md)
+- [Zed Docs: Language Support: Fish](./fish.md)