Giter Site home page Giter Site logo

bzy-debug / bash-language-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bash-lsp/bash-language-server

1.0 0.0 0.0 3.65 MB

A language server for Bash

License: MIT License

Shell 5.50% JavaScript 1.31% Python 0.02% TypeScript 93.16%

bash-language-server's Introduction

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

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

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 or 500ms).

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.

bash-language-server's People

Contributors

skovhus avatar renovate[bot] avatar mads-hartmann avatar mcecode avatar dependabot[bot] avatar renovate-bot avatar shabbyrobe avatar nikita-skobov avatar otreblan avatar chrismwendt avatar naksyl avatar rcjsuen avatar deathaxe avatar jfcherng avatar thomasjm avatar a5ob7r avatar yamaton avatar jerabaul29 avatar dmerc avatar hak33m16 avatar the-mikedavis avatar maximbaz avatar akurtakov avatar joshlay avatar adelarsq avatar mikesmithgh avatar rmpr avatar robertrossmann avatar supersandro2000 avatar skalt avatar

Stargazers

Haoxiang Fei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.