You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-2
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Bash Language Server
2
2
3
-
Bash language server that brings an IDE-like experience for bash scripts to most editors. This is based on the [Tree Sitter parser][tree-sitter-bash] and supports [explainshell][explainshell] and [shellcheck][shellcheck].
3
+
Bash language server that brings an IDE-like experience for bash scripts to most editors. This is based on the [Tree Sitter parser][tree-sitter-bash] and supports [explainshell][explainshell], [shellcheck][shellcheck] and [shfmt][shfmt].
4
4
5
5
Documentation around configuration variables can be found in the [config.ts](https://github.com/bash-lsp/bash-language-server/blob/main/server/src/config.ts) file.
6
6
@@ -15,6 +15,7 @@ Documentation around configuration variables can be found in the [config.ts](htt
15
15
- Documentation for symbols on hover
16
16
- Workspace symbols
17
17
- Rename symbol
18
+
- Format document
18
19
19
20
To be implemented:
20
21
@@ -24,7 +25,14 @@ To be implemented:
24
25
25
26
### Dependencies
26
27
27
-
As a dependency, we recommend that you first install shellcheck [shellcheck][shellcheck] to enable linting: https://github.com/koalaman/shellcheck#installing . If shellcheck is installed, bash-language-server will automatically call it to provide linting and code analysis each time the file is updated (with debounce time or 500ms).
28
+
As a dependency, we recommend that you first install [shellcheck][shellcheck] to enable linting:
29
+
https://github.com/koalaman/shellcheck#installing . If `shellcheck` is installed,
30
+
bash-language-server will automatically call it to provide linting and code analysis each time the
31
+
file is updated (with debounce time of 500ms).
32
+
33
+
If you want your shell scripts to be formatted consistently, you can install [shfmt][shfmt]. If
34
+
`shfmt` is installed then your documents will be formatted whenever you take the 'format document'
35
+
action. In most editors this can be configured to happen automatically when files are saved.
28
36
29
37
### Bash language server
30
38
@@ -180,6 +188,22 @@ Using the built-in `eglot` lsp mode:
180
188
(bash-ts-mode . eglot-ensure))
181
189
```
182
190
191
+
## `shfmt` integration
192
+
193
+
The indentation used by `shfmt` is whatever has been configured for the current editor session, so
194
+
there is no `shfmt`-specific configuration variable for this. If your editor is configured for
195
+
two-space indents then that's what it will use. If you're using tabs for indentation then `shfmt`
196
+
will use that.
197
+
198
+
The `shfmt` integration also supports configuration via `.editorconfig`. If any `shfmt`-specific
199
+
configuration properties are found in `.editorconfig` then the config in `.editorconfig` will be
200
+
used and the language server config will be ignored. This follows `shfmt`'s approach of using either
201
+
`.editorconfig` or command line flags, but not both. Note that only `shfmt`-specific configuration
202
+
properties are read from `.editorconfig` - indentation preferences are still provided by the editor,
203
+
so to format using the indentation specified in `.editorconfig` make sure your editor is also
204
+
configured to read `.editorconfig`. It is possible to disable `.editorconfig` support and always use
205
+
the language server config by setting the "Ignore Editorconfig" configuration variable.
206
+
183
207
## Logging
184
208
185
209
The minimum logging level for the server can be adjusted using the `BASH_IDE_LOG_LEVEL` environment variable
@@ -197,6 +221,7 @@ Please see [docs/development-guide][dev-guide] for more information.
0 commit comments