hydeik / bash-language-server

A language server for Bash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bash Language Server

Bash language server implementation based on Tree Sitter and its grammar for Bash with explainshell integration.

Features

  • Jump to declaration
  • Find references
  • Code Outline & Show Symbols
  • Highlight occurrences
  • Code completion
  • Simple diagnostics reporting
  • Documentation for flags on hover
  • Rename symbol

Installation

npm i -g bash-language-server

If you encounter EACCESS errors on installation, similarly to what's described in #93, you may need to solve either or both of the following issues:

The workaround for the missing semver@5.3.0 dependency described in the Arch Linux Bug report, is best workaround by running npm install in /usr/lib/node_modules/node-gyp.

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->[&shell, &shellcmdflag, 'bash-language-server start']},
        \ 'whitelist': ['sh'],
        \ })
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 w0rp/ale add the following configuration to your .vimrc:

let g:ale_linters = {
    \ 'sh': ['language_server'],
    \ }

Neovim

Install the plugin autozimu/LanguageClient-neovim and add the following configuration to init.vim:

let g:LanguageClient_serverCommands = {
    \ 'sh': ['bash-language-server', 'start']
    \ }

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

Development Guide

Please see docs/development-guide for more information.

About

A language server for Bash

License:MIT License


Languages

Language:TypeScript 80.8%Language:Shell 17.2%Language:JavaScript 1.4%Language:Makefile 0.5%