Skip to content

Commit 98b553e

Browse files
Merge branch 'main' into feature/snippets-for-argument-parsing
2 parents 48a16ec + 23fdaa9 commit 98b553e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4417
-613
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717

1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121

2222
- name: Initialize CodeQL
23-
uses: github/codeql-action/init@v2
23+
uses: github/codeql-action/init@v3
2424
with:
2525
languages: javascript
2626

2727
- name: Perform CodeQL Analysis
28-
uses: github/codeql-action/analyze@v2
28+
uses: github/codeql-action/analyze@v3

.github/workflows/deploy.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ jobs:
99
deploy:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
13+
14+
- name: Install shellcheck and shfmt (used for testing)
15+
run: sudo apt-get install -y shellcheck shfmt
1316

1417
- uses: pnpm/action-setup@v2
1518
with:
1619
version: 8
1720

18-
- uses: actions/setup-node@v3
21+
- uses: actions/setup-node@v4
1922
with:
2023
node-version: 20
2124
registry-url: https://registry.npmjs.org/

.github/workflows/upgrade-tree-sitter.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
upgrade_tree_sitter:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313

1414
- uses: pnpm/action-setup@v2
1515
with:
1616
version: 8
1717

18-
- uses: actions/setup-node@v3
18+
- uses: actions/setup-node@v4
1919
with:
2020
node-version: 20
2121
cache: "pnpm"
@@ -27,7 +27,7 @@ jobs:
2727
run: bash scripts/upgrade-tree-sitter.sh
2828

2929
- name: Verify file changes
30-
uses: tj-actions/verify-changed-files@v16
30+
uses: tj-actions/verify-changed-files@v17
3131
id: verify-changed-files
3232
with:
3333
files: |
@@ -36,7 +36,7 @@ jobs:
3636
3737
- name: Create pull request
3838
if: steps.verify-changed-files.outputs.files_changed == 'true'
39-
uses: peter-evans/create-pull-request@v5
39+
uses: peter-evans/create-pull-request@v6
4040
with:
4141
add-paths: server
4242
title: Auto upgrade tree-sitter-bash parser

.github/workflows/verify.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ jobs:
1212
node-version: [16.x, 18.x, 20.x]
1313

1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616

17-
- name: Install shellcheck (used for testing)
18-
run: sudo apt-get install -y shellcheck
17+
- name: Install shellcheck and shfmt (used for testing)
18+
run: sudo apt-get install -y shellcheck shfmt
1919

2020
- uses: pnpm/action-setup@v2
2121
with:
2222
version: 8
2323

2424
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v3
25+
uses: actions/setup-node@v4
2626
with:
2727
cache: "pnpm"
2828
cache-dependency-path: '**/pnpm-lock.yaml'
@@ -34,7 +34,7 @@ jobs:
3434
run: pnpm verify:bail
3535

3636
- name: Publish coverage to codecov.io
37-
uses: codecov/codecov-action@v3
37+
uses: codecov/codecov-action@v4
3838
if: success() && matrix.node-version == '20.x'
3939
with:
4040
token: ${{ secrets.CODECOV_TOKEN }}

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nodejs 18.17.1
1+
nodejs 18.20.1

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"typescript.tsdk": "./node_modules/typescript/lib",
99
"typescript.tsc.autoDetect": "off",
1010
"editor.codeActionsOnSave": {
11-
"source.fixAll.eslint": true
11+
"source.fixAll.eslint": "explicit"
1212
}
1313
}

README.md

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Bash Language Server
22

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].
4-
5-
We strongly recommend that you install [shellcheck][shellcheck] to enable linting: https://github.com/koalaman/shellcheck#installing
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].
64

75
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.
86

@@ -16,28 +14,48 @@ Documentation around configuration variables can be found in the [config.ts](htt
1614
- Simple diagnostics reporting
1715
- Documentation for symbols on hover
1816
- Workspace symbols
17+
- Rename symbol
18+
- Format document
1919

2020
To be implemented:
2121

22-
- Rename symbol
2322
- Better jump to declaration and find references based on scope
2423

2524
## Installation
2625

26+
### Dependencies
27+
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.
36+
37+
### Bash language server
38+
2739
Usually you want to install a client for your editor (see the section below).
2840

29-
But if you want to install the server binary:
41+
But if you want to install the server binary (for examples for editors, like helix, where a generic LSP client is built in), you can install from npm registry as:
3042

3143
```bash
3244
npm i -g bash-language-server
3345
```
3446

35-
On Fedora based distros:
47+
Alternatively, bash-language-server may also be distributed directly by your Linux distro, for example on Fedora based distros:
3648

3749
```bash
3850
dnf install -y nodejs-bash-language-server
3951
```
4052

53+
Or on Ubuntu with snap:
54+
55+
```bash
56+
sudo snap install bash-language-server --classic
57+
```
58+
4159
To verify that everything is working:
4260

4361
```bash
@@ -69,7 +87,7 @@ For Vim 8 or later install the plugin [prabirshrestha/vim-lsp][vim-lsp] and add
6987
if executable('bash-language-server')
7088
au User lsp_setup call lsp#register_server({
7189
\ 'name': 'bash-language-server',
72-
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'bash-language-server start']},
90+
\ 'cmd': {server_info->['bash-language-server', 'start']},
7391
\ 'allowlist': ['sh', 'bash'],
7492
\ })
7593
endif
@@ -158,6 +176,34 @@ Add the configuration to your `.emacs.d/init.el`
158176
(sh-mode . lsp))
159177
```
160178

179+
Using the built-in `eglot` lsp mode:
180+
181+
```emacs-lisp
182+
(use-package eglot
183+
:config
184+
(add-to-list 'eglot-server-programs '((sh-mode bash-ts-mode) . ("bash-language-server" "start")))
185+
186+
:hook
187+
(sh-mode . eglot-ensure)
188+
(bash-ts-mode . eglot-ensure))
189+
```
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+
161207
## Logging
162208

163209
The minimum logging level for the server can be adjusted using the `BASH_IDE_LOG_LEVEL` environment variable
@@ -175,6 +221,7 @@ Please see [docs/development-guide][dev-guide] for more information.
175221
[sublime-text-lsp]: https://packagecontrol.io/packages/LSP-bash
176222
[explainshell]: https://explainshell.com/
177223
[shellcheck]: https://www.shellcheck.net/
224+
[shfmt]: https://github.com/mvdan/sh#shfmt
178225
[languageclient-neovim]: https://github.com/autozimu/LanguageClient-neovim
179226
[nvim-lspconfig]: https://github.com/neovim/nvim-lspconfig
180227
[vim-lsp]: https://github.com/prabirshrestha/vim-lsp

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@
1717
"postinstall": "pnpm --dir=vscode-client install --ignore-workspace"
1818
},
1919
"devDependencies": {
20-
"@types/jest": "29.5.4",
21-
"@types/node": "18.17.11",
22-
"@typescript-eslint/eslint-plugin": "5.62.0",
23-
"@typescript-eslint/parser": "5.62.0",
24-
"eslint": "8.48.0",
25-
"eslint-config-prettier": "8.10.0",
26-
"eslint-plugin-jest": "27.2.3",
20+
"@types/jest": "29.5.12",
21+
"@types/node": "18.19.30",
22+
"@typescript-eslint/eslint-plugin": "7.5.0",
23+
"@typescript-eslint/parser": "7.5.0",
24+
"eslint": "8.57.0",
25+
"eslint-config-prettier": "9.1.0",
26+
"eslint-plugin-jest": "27.9.0",
2727
"eslint-plugin-prettier": "4.2.1",
28-
"eslint-plugin-simple-import-sort": "10.0.0",
29-
"eslint-plugin-sort-class-members": "1.18.0",
30-
"jest": "29.6.4",
28+
"eslint-plugin-simple-import-sort": "12.0.0",
29+
"eslint-plugin-sort-class-members": "1.20.0",
30+
"jest": "29.7.0",
3131
"prettier": "2.8.8",
32-
"ts-jest": "29.1.1",
33-
"typescript": "5.2.2",
32+
"ts-jest": "29.1.2",
33+
"typescript": "5.4.4",
3434
"vscode-languageserver": "8.0.2",
35-
"vscode-languageserver-textdocument": "1.0.8"
35+
"vscode-languageserver-textdocument": "1.0.11"
3636
},
3737
"resolutions": {
38-
"@types/vscode": "1.81.0"
38+
"@types/vscode": "1.88.0"
3939
},
4040
"engines": {
4141
"node": ">=16",
42-
"pnpm": "8.x"
42+
"pnpm": ">=8.x"
4343
},
4444
"jest": {
4545
"preset": "ts-jest",

0 commit comments

Comments
 (0)