bash-language-server
Advanced tools
Comparing version 4.1.0 to 4.1.1
# Bash Language Server | ||
## 4.1.1 | ||
- Background analysis: handle workspace root being a URL https://github.com/bash-lsp/bash-language-server/pull/625 | ||
- Shell documentation: add `--noprofile --norc` to avoid config files breaking formatting https://github.com/bash-lsp/bash-language-server/pull/626 | ||
## 4.1.0 | ||
@@ -4,0 +9,0 @@ |
@@ -20,4 +20,5 @@ "use strict"; | ||
exports.getFilePaths = exports.untildify = void 0; | ||
const os = require("node:os"); | ||
const node_url_1 = require("node:url"); | ||
const fastGlob = require("fast-glob"); | ||
const os = require("os"); | ||
// from https://github.com/sindresorhus/untildify/blob/f85a087418aeaa2beb56fe2684fe3b64fc8c588d/index.js#L11 | ||
@@ -34,2 +35,5 @@ function untildify(pathWithTilde) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (rootPath.startsWith('file://')) { | ||
rootPath = (0, node_url_1.fileURLToPath)(rootPath); | ||
} | ||
const stream = fastGlob.stream([globPattern], { | ||
@@ -36,0 +40,0 @@ absolute: true, |
@@ -24,3 +24,3 @@ "use strict"; | ||
else { | ||
args.push('-c', body); | ||
args.push('--noprofile', '--norc', '-c', body); | ||
} | ||
@@ -27,0 +27,0 @@ const process = ChildProcess.spawn(cmd, args); |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"publisher": "mads-hartmann", | ||
@@ -28,8 +28,8 @@ "main": "./out/server.js", | ||
"vscode-languageserver": "8.0.2", | ||
"vscode-languageserver-textdocument": "1.0.7", | ||
"vscode-languageserver-textdocument": "1.0.8", | ||
"web-tree-sitter": "0.20.7", | ||
"zod": "3.19.1" | ||
"zod": "3.20.2" | ||
}, | ||
"scripts": { | ||
"prepublishOnly": "cd ../ && yarn run compile" | ||
"prepublishOnly": "cd ../ && yarn run compile && cp README.md server/" | ||
}, | ||
@@ -36,0 +36,0 @@ "devDependencies": { |
149
README.md
# Bash Language Server | ||
Bash language server implementation based on [Tree Sitter][tree-sitter] and its [grammar for Bash][tree-sitter-bash]. Integrates with [explainshell][explainshell] and [shellcheck][shellcheck]. | ||
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]. | ||
Documentation for environment variables can be found in the [config.ts][https://github.com/bash-lsp/bash-language-server/blob/main/server/src/config.ts] file. | ||
We strongly recommend that you install [shellcheck][shellcheck] to enable linting: https://github.com/koalaman/shellcheck#installing | ||
For more information see the GitHub repository: [bash-ide/bash-language-server][https://github.com/bash-lsp/bash-language-server] | ||
Documentation around configuration can be found in the [config.ts](https://github.com/bash-lsp/bash-language-server/blob/main/server/src/config.ts) file. | ||
## Features | ||
- Jump to declaration | ||
- Find references | ||
- Code Outline & Show Symbols | ||
- Highlight occurrences | ||
- Code completion | ||
- Simple diagnostics reporting | ||
- Documentation for symbols on hover | ||
- Workspace symbols | ||
To be implemented: | ||
- Rename symbol | ||
- Better jump to declaration and find references based on scope | ||
## Installation | ||
```bash | ||
npm i -g bash-language-server | ||
``` | ||
On Fedora based distros: | ||
```bash | ||
dnf install -y nodejs-bash-language-server | ||
``` | ||
If you encounter installation errors, ensure you have node version 14 or newer (`node --version`). | ||
### Clients | ||
The following editors and IDEs have available clients: | ||
- Atom ([ide-bash][ide-bash]) | ||
- Eclipse ([ShellWax](https://marketplace.eclipse.org/content/shellwax)) | ||
- Emacs ([see below](#emacs)) | ||
- [Helix](https://helix-editor.com/) (built-in support) | ||
- JupyterLab ([jupyterlab-lsp][jupyterlab-lsp]) | ||
- Neovim ([see below](#neovim)) | ||
- Sublime Text ([LSP-bash][sublime-text-lsp]) | ||
- Vim ([see below](#vim)) | ||
- Visual Studio Code ([Bash IDE][vscode-marketplace]) | ||
- [Oni](https://github.com/onivim/oni) ([see below](#oni)) | ||
#### Vim | ||
For Vim 8 or later install the plugin [prabirshrestha/vim-lsp][vim-lsp] and add the following configuration to `.vimrc`: | ||
```vim | ||
if executable('bash-language-server') | ||
au User lsp_setup call lsp#register_server({ | ||
\ 'name': 'bash-language-server', | ||
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'bash-language-server start']}, | ||
\ 'allowlist': ['sh', 'bash'], | ||
\ }) | ||
endif | ||
``` | ||
For Vim 8 or Neovim using [neoclide/coc.nvim][coc.nvim], according to [it's Wiki article](https://github.com/neoclide/coc.nvim/wiki/Language-servers#bash), add the following to your `coc-settings.json`: | ||
```jsonc | ||
"languageserver": { | ||
"bash": { | ||
"command": "bash-language-server", | ||
"args": ["start"], | ||
"filetypes": ["sh"], | ||
"ignoredRootPaths": ["~"] | ||
} | ||
} | ||
``` | ||
For Vim 8 or NeoVim using [dense-analysis/ale][vim-ale] add the following | ||
configuration to your `.vimrc`: | ||
```vim | ||
let g:ale_linters = { | ||
\ 'sh': ['language_server'], | ||
\ } | ||
``` | ||
#### Neovim | ||
For Neovim v0.8: | ||
```lua | ||
vim.api.nvim_create_autocmd('FileType', { | ||
pattern = 'sh', | ||
callback = function() | ||
vim.lsp.start({ | ||
name = 'bash-language-server', | ||
cmd = { 'bash-language-server', 'start' }, | ||
}) | ||
end, | ||
}) | ||
``` | ||
For NeoVim using [autozimu/LanguageClient-neovim][languageclient-neovim], add the following configuration to | ||
`init.vim`: | ||
```vim | ||
let g:LanguageClient_serverCommands = { | ||
\ 'sh': ['bash-language-server', 'start'] | ||
\ } | ||
``` | ||
For Vim8/NeoVim v0.5 using [jayli/vim-easycomplete](https://github.com/jayli/vim-easycomplete). Execute `:InstallLspServer sh` and config nothing. Maybe it's the easiest way to use bash-language-server in vim/nvim. | ||
#### Oni | ||
On the config file (`File -> Preferences -> Edit Oni config`) add the following configuration: | ||
```javascript | ||
"language.bash.languageServer.command": "bash-language-server", | ||
"language.bash.languageServer.arguments": ["start"], | ||
``` | ||
#### Emacs | ||
[Lsp-mode](https://github.com/emacs-lsp/lsp-mode) has a built-in client, can be installed by `use-package`. | ||
Add the configuration to your `.emacs.d/init.el` | ||
```emacs-lisp | ||
(use-package lsp-mode | ||
:commands lsp | ||
:hook | ||
(sh-mode . lsp)) | ||
``` | ||
## Development Guide | ||
Please see [docs/development-guide][dev-guide] for more information. | ||
[tree-sitter]: https://github.com/tree-sitter/tree-sitter | ||
[tree-sitter-bash]: https://github.com/tree-sitter/tree-sitter-bash | ||
[vscode-marketplace]: https://marketplace.visualstudio.com/items?itemName=mads-hartmann.bash-ide-vscode | ||
[dev-guide]: https://github.com/bash-lsp/bash-language-server/blob/master/docs/development-guide.md | ||
[ide-bash]: https://atom.io/packages/ide-bash | ||
[sublime-text-lsp]: https://packagecontrol.io/packages/LSP-bash | ||
[explainshell]: https://explainshell.com/ | ||
[shellcheck]: https://www.shellcheck.net/ | ||
[languageclient-neovim]: https://github.com/autozimu/LanguageClient-neovim | ||
[nvim-lspconfig]: https://github.com/neovim/nvim-lspconfig | ||
[vim-lsp]: https://github.com/prabirshrestha/vim-lsp | ||
[vim-ale]: https://github.com/dense-analysis/ale | ||
[coc.nvim]: https://github.com/neoclide/coc.nvim | ||
[jupyterlab-lsp]: https://github.com/krassowski/jupyterlab-lsp |
@@ -0,1 +1,3 @@ | ||
import { pathToFileURL } from 'node:url' | ||
import { | ||
@@ -204,3 +206,3 @@ FIXTURE_DOCUMENT, | ||
parser, | ||
workspaceFolder: REPO_ROOT_FOLDER, | ||
workspaceFolder: pathToFileURL(REPO_ROOT_FOLDER).href, | ||
}) | ||
@@ -207,0 +209,0 @@ await newAnalyzer.initiateBackgroundAnalysis({ |
@@ -1,3 +0,5 @@ | ||
import * as Process from 'child_process' | ||
import * as Path from 'path' | ||
import * as Process from 'node:child_process' | ||
import * as Path from 'node:path' | ||
import { pathToFileURL } from 'node:url' | ||
import * as LSP from 'vscode-languageserver/node' | ||
@@ -17,3 +19,3 @@ import { CodeAction } from 'vscode-languageserver/node' | ||
async function initializeServer( | ||
{ rootPath }: { rootPath?: string } = { rootPath: FIXTURE_FOLDER }, | ||
{ rootPath }: { rootPath?: string } = { rootPath: pathToFileURL(FIXTURE_FOLDER).href }, | ||
) { | ||
@@ -20,0 +22,0 @@ const diagnostics: Array<LSP.PublishDiagnosticsParams | undefined> = [] |
@@ -0,3 +1,5 @@ | ||
import * as os from 'node:os' | ||
import { fileURLToPath } from 'node:url' | ||
import * as fastGlob from 'fast-glob' | ||
import * as os from 'os' | ||
@@ -21,2 +23,6 @@ // from https://github.com/sindresorhus/untildify/blob/f85a087418aeaa2beb56fe2684fe3b64fc8c588d/index.js#L11 | ||
}): Promise<string[]> { | ||
if (rootPath.startsWith('file://')) { | ||
rootPath = fileURLToPath(rootPath) | ||
} | ||
const stream = fastGlob.stream([globPattern], { | ||
@@ -23,0 +29,0 @@ absolute: true, |
@@ -17,3 +17,3 @@ import * as ChildProcess from 'child_process' | ||
} else { | ||
args.push('-c', body) | ||
args.push('--noprofile', '--norc', '-c', body) | ||
} | ||
@@ -20,0 +20,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
863551
7313
156
+ Addedvscode-languageserver-textdocument@1.0.8(transitive)
+ Addedzod@3.20.2(transitive)
- Removedvscode-languageserver-textdocument@1.0.7(transitive)
- Removedzod@3.19.1(transitive)
Updatedzod@3.20.2