Bash Language Server

5.6.0 · active · verified Sun Apr 19

The Bash Language Server provides an IDE-like experience for Bash scripts by implementing the Language Server Protocol. It leverages Tree Sitter for parsing, and integrates with external tools like ShellCheck for linting, shfmt for formatting, and explainshell for documentation. The current stable version is 5.6.0. It follows a frequent release cadence, indicated by multiple minor and patch releases within short periods. A key differentiator is its comprehensive integration with established Bash tooling, offering features such as jump to definition, find references, code completion, diagnostics, and formatting. It requires Node.js version 16 or newer to run, and ships with TypeScript types, allowing for type-safe client development or custom integrations. Primarily used as a standalone server, it's typically invoked by editor clients rather than imported as a library.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates global installation verification and clarifies how the Bash Language Server is typically used via editor integrations rather than direct programmatic imports.

import { startServer } from 'bash-language-server/lib/server';
import { exec } from 'child_process';

// This package is primarily a CLI tool (bash-language-server start)
// for editor integration. The following demonstrates how to verify
// its global installation and provides a conceptual programmatic hook.

console.log('Verifying bash-language-server installation...');

exec('bash-language-server --version', (error, stdout, stderr) => {
  if (error) {
    console.error(`Error checking server version: ${error.message}`);
    console.error('Please ensure bash-language-server is installed globally: npm i -g bash-language-server');
    return;
  }
  if (stderr) {
    console.error(`Server stderr: ${stderr}`);
  }
  console.log(`Bash Language Server installed and version: ${stdout.trim()}`);
  console.log('\nTo use it, configure your editor (e.g., VS Code, Neovim) to use `bash-language-server start` as its LSP server command.');
  
  // For advanced, programmatic usage (e.g., custom testing or embedding),
  // one might theoretically import 'startServer' from 'bash-language-server/lib/server'.
  // However, this function expects a Language Server Protocol connection object
  // (e.g., from 'vscode-languageserver/node') which is outside a simple quickstart.
  // Example of how it *might* be used in a highly custom setup:
  // const connection = createConnection(ProposedFeatures.all);
  // connection.onInitialize((params) => { /* ... */ });
  // connection.listen();
  // startServer(connection);
});

view raw JSON →