Bash Language Server

repository·main·Indexed 25 days ago

https://github.com/bash-lsp/bash-language-server

A Node.js language server for Bash scripts implementing the Language Server Protocol (LSP). It provides IDE-like features including code completion, jump to declaration, diagnostics, and formatting by leveraging Tree Sitter, ShellCheck, and shfmt. It supports various editors including VS Code (via the Bash IDE extension), Vim, Neovim, and Emacs.

Tokens
5K
Snippets
17
Records
44
Agent score
82%

What's inside bash-language-server

  1. Features of the Bash IDE extension

    main

    The Bash IDE extension provides the following features for shell scripting in Visual Studio Code:

    • Navigation: Jump to declaration, Find references, Workspace symbols, and Rename symbol.
    • IntelliSense: Code completion, Code Outline & Show Symbols, Highlight occurrences, and Snippets.
    • Information: Documentation for flags on hover (via explainshell).
    • Code Quality: Simple diagnostics reporting and Format document (via shfmt).
  2. Develop the server within VS Code

    main

    Since the server is embedded in the VS Code client, you must link server changes to your local client installation. Run the following command once, then follow the standard 'Working on the client' steps (launching the Launch Client task) to see your server changes reflected in the extension.

    pnpm link-server
  3. Install the Bash IDE VS Code extension

    main

    The Bash IDE is a Visual Studio Code extension that utilizes the Bash Language Server and integrates with explainshell, shellcheck, and shfmt to provide advanced shell scripting features.

    To enable full functionality, it is highly recommended to install the following external tools:

    • shellcheck: Enables linting and diagnostics.
    • shfmt: Enables code formatting.

    You can find the extension on the VS Marketplace or Open VSX.

  4. Set up the development environment

    main

    To begin developing on the Bash Language Server project, ensure you have pnpm and node (v20 or newer) installed. Follow these steps to initialize the workspace:

    1. Install dependencies in the project root using pnpm install. This triggers the postinstall hook to install dependencies for both the vscode-client and server sub-projects.
    2. Verify the configuration by compiling both the client and the server using pnpm compile.
    pnpm install
    pnpm compile