npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

neo-bash-ls

v5.3.1

Published

A language server for Bash

Downloads

6

Readme

Bash Language Server

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, shellcheck and shfmt.

Documentation around configuration variables can be found in the 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
  • Rename symbol
  • Format document

To be implemented:

  • Better jump to declaration and find references based on scope

Installation

Dependencies

As a dependency, we recommend that you first install shellcheck shellcheck to enable linting: https://github.com/koalaman/shellcheck#installing . If shellcheck is installed, bash-language-server will automatically call it to provide linting and code analysis each time the file is updated (with debounce time of 500ms).

If you want your shell scripts to be formatted consistently, you can install shfmt. If shfmt is installed then your documents will be formatted whenever you take the 'format document' action. In most editors this can be configured to happen automatically when files are saved.

Bash language server

Usually you want to install a client for your editor (see the section below).

But if you want to install the server binary (for examples for editors, like helix, where a generic LSP client is built in), you can install from npm registry as:

npm i -g bash-language-server

Alternatively, bash-language-server may also be distributed directly by your Linux distro, for example on Fedora based distros:

dnf install -y nodejs-bash-language-server

Or on Ubuntu with snap:

sudo snap install bash-language-server --classic

To verify that everything is working:

bash-language-server --help

If you encounter installation errors, ensure you have node version 16 or newer (node --version).

Clients

The following editors and IDEs have available clients:

Vim

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->['bash-language-server', 'start']},
        \ 'allowlist': ['sh', 'bash'],
        \ })
endif

For Vim 8 or Neovim using YouCompleteMe, add the following to .vimrc:

let g:ycm_language_server =
            \ [
            \   {
            \       'name': 'bash',
            \       'cmdline': [ 'bash-language-server', 'start' ],
            \       'filetypes': [ 'sh' ],
            \   }
            \ ]

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'],
    \ }

Neovim

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.

Oni

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"],

Emacs

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))

Using the built-in eglot lsp mode:

(use-package eglot
  :config
  (add-to-list 'eglot-server-programs '((sh-mode bash-ts-mode) . ("bash-language-server" "start")))

  :hook
  (sh-mode . eglot-ensure)
  (bash-ts-mode . eglot-ensure))

Logging

The minimum logging level for the server can be adjusted using the BASH_IDE_LOG_LEVEL environment variable and through the general workspace configuration.

Development Guide

Please see docs/development-guide for more information.