bashd is a Language Server Protocol (LSP) implementation for Bash, built using the Go sh package and featuring ShellCheck integration for real-time linting.
- Check if sourced file exists
- Parser errors
- ShellCheck lints
- For document on document change
- For workspace on initialize
- Show
help
output as docs for keywords and builtins - Show man page as docs for executables
- Show location of assignment for variables
- Show location and body for functions
- Variable assignment in document and sourced files
- Function declaration in document and sourced files
- Sourced file itself
- Function calls in current document and sourced files
- Variable usage in current document and sourced files
- Function calls in workspace file which source the current file
- Variable usage in workspace file which source the current file
- Depending on
ReferenceContext.includeDeclaration
function declarations and variable assignments
- Function declarations and calls in document and sourced files
- Variable assignments and usage in document and sourced files
- Function declarations and calls in workspace file which source the current file
- Variable assignments and usage in workspace file which source the current file
- Variables declared in document (on
$
and{
) - Functions declared in document
- Environment variables (on
$
and{
) - Keywords
- Executables in PATH
- Resolve with
help
output as docs for keywords and builtins - Resolve with man page as docs for executables
- Variable assignment in document
- Function declaration in document
- Variable assignment in workspace .sh files and scripts without extension but shebang
- Function declaration in workspace .sh files and scripts without extension but shebang
- Entire file
- Range formatting (as long as range covers nodes that can be formatted)
- Fix for shellcheck lints (position dependent)
- Add ignore comment for shellcheck lints (position dependent)
- Fix all auto-fixable lints (only when there are fixable lints)
- Add shebang if not exist
- Minify script
- SGR ANSI escapes
- 256-color (8-bit) foreground (
\x1b[38;5;<n>m
) and background (\x1b[48;5;<n>m
) - True color (24-bit) foreground(
\x1b[38;2;<r>;<g>;<b>m
) and background (\x1b[48;2;<r>;<g>;<b>m
) - 3-bit / 4-bit color foreground (
\x1b[<n>m
; n ∈ [30,37] ∪ [90,97]) and background (\x1b[<n>m
; n ∈ [40,47] ∪ [100,107]) - Also alternative escapes
\e
and\033
If you have Go installed (v1.17+), you can install bashd directly with:
go install github.com/matkrin/bashd/cmd/bashd@latest
This will download, build, and install the binary to $HOME/go/bin
, make sure
it is is in your system’s PATH
:
export PATH="${HOME}/go/bin:${PATH}"
Additionally, precompiled binaries are available for Linux, macOS, and Windows in the releases section.
With Neovim version 0.11+, you can use bashd without plugins:
vim.lsp.config.bashd = {
cmd = { "bashd" },
filetypes = { "bash", "sh" },
root_markers = { ".git" },
}
vim.lsp.enable("bashd")
With lspconfig:
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
configs.bashd = {
default_config = {
name = "bashd",
cmd = { "bashd" },
filetypes = { "bash", "sh" },
root_dir = lspconfig.util.root_pattern(".git"),
},
}
lspconfig.bashd.setup({})
In languages.toml:
[language-server.bashd]
command = "bashd"
roots = [".git"]
[[language]]
name = "bash"
language-servers = [{ name = "bashd" }]