Bash language server that brings an IDE-like experience for bash scripts to most editors. This is based on the Tree Sitter parser and supports explainshell and shellcheck.
We strongly recommend that you install shellcheck to enable linting: https://github.com/koalaman/shellcheck#installing
Documentation around configuration can be found in the config.ts file.
- 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
npm i -g bash-language-server
On Fedora based distros:
dnf install -y nodejs-bash-language-server
If you encounter installation errors, ensure you have node version 14 or newer (node --version
).
The following editors and IDEs have available clients:
- Atom (ide-bash)
- Eclipse (ShellWax)
- Emacs (see below)
- Helix (built-in support)
- JupyterLab (jupyterlab-lsp)
- Neovim (see below)
- Sublime Text (LSP-bash)
- Vim (see below)
- Visual Studio Code (Bash IDE)
- Oni (see below)
For Vim 8 or later install the plugin prabirshrestha/vim-lsp and add the following configuration to .vimrc
:
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, according to it's Wiki article, add the following to your coc-settings.json
:
"languageserver": {
"bash": {
"command": "bash-language-server",
"args": ["start"],
"filetypes": ["sh"],
"ignoredRootPaths": ["~"]
}
}
For Vim 8 or NeoVim using dense-analysis/ale add the following
configuration to your .vimrc
:
let g:ale_linters = {
\ 'sh': ['language_server'],
\ }
For Neovim v0.8:
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, add the following configuration to
init.vim
:
let g:LanguageClient_serverCommands = {
\ 'sh': ['bash-language-server', 'start']
\ }
For Vim8/NeoVim v0.5 using jayli/vim-easycomplete. Execute :InstallLspServer sh
and config nothing. Maybe it's the easiest way to use bash-language-server in vim/nvim.
On the config file (File -> Preferences -> Edit Oni config
) add the following configuration:
"language.bash.languageServer.command": "bash-language-server",
"language.bash.languageServer.arguments": ["start"],
Lsp-mode has a built-in client, can be installed by use-package
.
Add the configuration to your .emacs.d/init.el
(use-package lsp-mode
:commands lsp
:hook
(sh-mode . lsp))
Please see docs/development-guide for more information.