GithubHelp home page GithubHelp logo

bash-lsp / bash-language-server Goto Github PK

View Code? Open in Web Editor NEW
2.0K 22.0 118.0 3.78 MB

A language server for Bash

License: MIT License

TypeScript 93.77% JavaScript 1.18% Shell 5.03% Python 0.02%
language-server bash

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

shfmt integration

The indentation used by shfmt is whatever has been configured for the current editor session, so there is no shfmt-specific configuration variable for this. If your editor is configured for two-space indents then that's what it will use. If you're using tabs for indentation then shfmt will use that.

The shfmt integration also supports configuration via .editorconfig. If any shfmt-specific configuration properties are found in .editorconfig then the config in .editorconfig will be used and the language server config will be ignored. This follows shfmt's approach of using either .editorconfig or command line flags, but not both. Note that only shfmt-specific configuration properties are read from .editorconfig - indentation preferences are still provided by the editor, so to format using the indentation specified in .editorconfig make sure your editor is also configured to read .editorconfig. It is possible to disable .editorconfig support and always use the language server config by setting the "Ignore Editorconfig" configuration variable.

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

a5ob7r avatar akurtakov avatar chris-reeves avatar chrismwendt avatar deathaxe avatar dependabot[bot] avatar dmerc avatar hak33m16 avatar jerabaul29 avatar jfcherng avatar jimmyscene avatar joshlay avatar krassowski avatar mads-hartmann avatar maximbaz avatar mcecode avatar mikesmithgh avatar naksyl avatar nikita-skobov avatar otreblan avatar rcjsuen avatar renovate-bot avatar renovate[bot] avatar rmpr avatar shabbyrobe avatar shane-xb-qian avatar skovhus avatar the-mikedavis avatar thomasjm avatar yamaton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bash-language-server's Issues

Take variables introduces in for-statements into account

Go to declaration at references to project doesn't work.

for project in $(ls ~/dev/${kind}); do
    path="${HOME}/dev/${kind}/${project}"
    echo "Checking project ${path}"
    # Check if there are any unpushed branches
    if is-git-repository; then
        cd "${path}" && git log --branches --not --remotes --no-walk --decorate --oneline
    fi
done

Travis CI build is failing

Looks like the build failed.

$ npm run check:bail

> @ check:bail /home/travis/build/mads-hartmann/bash-language-server
> npm run lint:bail && npm run test

> @ lint:bail /home/travis/build/mads-hartmann/bash-language-server
> tslint --project vscode-client && tslint --project server

> @ test /home/travis/build/mads-hartmann/bash-language-server
> jest --runInBand --forceExit

 FAIL  server/src/__tests__/analyzer.test.ts
  ● Test suite failed to run

    Cannot find module 'source-map-support' from 'install.js'
      
      at Resolver.resolveModule (node_modules/jest/node_modules/jest-cli/node_modules/jest-runtime/node_modules/jest-resolve/build/index.js:169:17)
      at Object.<anonymous> (node_modules/ts-jest/dist/install.js:3:24)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.156s
Ran all test suites.

Dependencies incomplete in development-guide.md

Hi there,

Started looking at building this myself on WSL after attempting to install with npm i -g bash-language-server failed.

It may be academic, but in the build process I had to work out for myself that I would need node (v6 or greater), make and g++ installed. Probably not unique to WSL, but I'm a bit of a novice when it comes to building things that aren't .NET 😉

Allow to configure path to bash-language-server

When using a version manager like nvm VS Code will not have the npm I am using in the PATH, only the shell. Since I have many versions of node/npm installed, I would like to tell the VS Code extension to use a specific one. This could also be useful for debugging.

VSCode prompts non-sense.

I am using Bash IDE extension in VSCode. And installed bash-language-server as descripted in its details.

Now I have two problems. One is apparently something is wrong. The other is "I am not sure".

  1. Code prompt are all non-sense. For example, I typed "then", I got "thinkjettopbm". I typed "case", I got "catchsegv".

  2. Code completion does not work. In my idea, this is something like, when I typed "case", it would insert the "esac". But in my IDE, it does not. Just marks a bunch of lines "syntax error" red underlines.

What should I do?

"Can't find bash-language-server on your PATH...." on Windows

I've installed the package as advised but the extension fails with this error:

image

PS C:\Users\fakui> npm i -g bash-language-server
C:\Users\fakui\AppData\Roaming\npm\bash-language-server -> C:\Users\fakui\AppData\Roaming\npm\node_modules\bash-language-server\bin\main.js
+ [email protected]
updated 1 package in 1.253s
PS C:\Users\fakui> node -v
v10.0.0
PS C:\Users\fakui> (Get-ChildItem Env:Path).Value
C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Python36\Scripts\;C:\Program Files\Python36\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Common Files\Autodesk Shared\;D:\Program_Files\Strawberry\c\bin;D:\Program_Files\Strawberry\perl\site\bin;D:\Program_Files\Strawberry\perl\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Users\fakui\AppData\Local\Microsoft\WindowsApps;;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\fakui\AppData\Roaming\npm

Use yarn instead of npm (in vscode-client)

If yarn is used for development (see #21 ), maybe it will be also good to make the project itself use yarn by default?
Currently (especially in vscode-client) npm is used by default, and the underlying bash-language-server is located using npm bin -g.

Is it possible to replace (or extend) this by yarn global bin etc.?

Extension shows error on hovering

Hovering over 21:22
[Error - 10:43:37 PM] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Error: connect ECONNREFUSED 127.0.0.1:5000
  Code: -32603 

What should I do?

ENOENT error on kcov coverage results directory

Hello,

while using Bash IDE 1.3.2 I keep getting these kind of errors from the bash-language-server component (v1.5.2):

[...]
Analyzing file:///home/user/myproject/target/coverage/bash-helper.sh
fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/home/user/myproject/target/coverage/run_tests.sh'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at paths.forEach.p (/usr/lib/node_modules/bash-language-server/out/analyser.js:64:91)
    at Array.forEach (<anonymous>)
    at glob (/usr/lib/node_modules/bash-language-server/out/analyser.js:60:27)
    at f (/usr/lib/node_modules/bash-language-server/node_modules/once/once.js:25:25)
    at Glob.<anonymous> (/usr/lib/node_modules/bash-language-server/node_modules/glob/glob.js:151:7)
    at emitOne (events.js:116:13)
    at Glob.emit (events.js:211:7)
    at Glob._finish (/usr/lib/node_modules/bash-language-server/node_modules/glob/glob.js:197:8)
Analyzing file:///home/user/myproject/target/coverage/run_tests.sh
[Error - 11:29:29] Connection to server got closed. Server will not be restarted.

This is due to the fact that the /home/user/myproject/target/coverage/run_tests.sh is a symlink to a directory, that kcov automatically created to mimic the name of the file that originated the report. This causes the language server to crash continuously, reaching the retry attempts limit, as noted in the last line of output.
As suggested also in #47, I think that using the mime type information or, in any case, performing some kind of check on the file prior to opening it for analysis would solve this issue too.
I'm running on a Slackware64 Linux 14.2 box, using VS Code 1.25.0.

Trouble installing on Mac OSX

VS Code: 1.28.2
OSX: 10.12.6
BashIDE: 1.3.3
NPM: 5.6.0 (installed via MacPorts)
MacPorts: 2.4.2

The output is:

mymac:~ root# npm install -g bash-language-server
/opt/local/bin/bash-language-server -> /opt/local/lib/node_modules/bash-language-server/bin/main.js

[email protected] install /opt/local/lib/node_modules/bash-language-server/node_modules/tree-sitter
prebuild-install || node-gyp rebuild

prebuild-install WARN install EACCES: permission denied, access '/var/root/.npm'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/opt/local/lib/node_modules/bash-language-server/node_modules/tree-sitter/build'
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/opt/local/bin/node" "/opt/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /opt/local/lib/node_modules/bash-language-server/node_modules/tree-sitter
gyp ERR! node -v v9.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: prebuild-install || node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Thanks for the help!

Improve code completetion

Just installed this, and it works really nicely! Jump to definition and parsing errors are really nice.

Would be nice to improve the code completions. VS Code per default autocompletes on words, but this is disabled when using a language server I guess. : )

Ideas from the TODO file:

  • Based on symbols in the file
  • Based on all symbols in the workspace
  • Based on programs in your PATH
  • path completions, e.g. on foo/b should return bar if you have a file named bar inside of a folder named foo

Ideas from the source code :

  • Look up man pages for commands
  • For builtins look up the docs
  • For functions, parse their comments?

More file extensions than just "*.sh"?

It would be great if the user could provide more file extensions to parse. At the moment, only *.sh files are found and parsed:

https://github.com/mads-hartmann/bash-language-server/blob/00941c001ca342c8a9c1b647b2a1b7ea703e5fc6/server/src/analyser.ts#L47

When working with Bash scripts that use a different extension, e.g. .bash, the bash language server currently does not work.

It would be great if there was a configuration option that would allow to list the extensions that should be scanned...

Windows support

Seeing this when I switch to a bash file, in Visual Studio Code 1.20.1, Windows 10, extension v. 1.1.4:

module.js:672
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: \\?\C:\Users\asampaleanu\.vscode\extensions\mads-hartmann.bash-ide-vscode-1.1.4\server\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node is not a valid Win32 application\\?\C:\Users\asampaleanu\.vscode\extensions\mads-hartmann.bash-ide-vscode-1.1.4\server\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node
    at Object.Module._extensions..node (module.js:672:18)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\asampaleanu\.vscode\extensions\mads-hartmann.bash-ide-vscode-1.1.4\server\node_modules\tree-sitter\index.js:1:125)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
[Info  - 9:28:54 AM] Connection to server got closed. Server will restart.
module.js:672
  return process.dlopen(module, path._makeLong(filename));

Please make "mute" the default setting for tooling output/logging

I plugged in the docker "explain shell" container today and almost every time I move the cursor or type something the terminal window re-opens and prints out loads of text I don't need to see.

Or better yet, I "could see it if I choose" and otherwise I expect that kind of noise to sit in the background. It almost makes the Bash-IDE unsuable.

Can't install on ubuntu 18.04

I'm not familiar with npm but your installation instructions looked easy. However I am getting errors when trying to install the bash language server on ubuntu 18.04. (my eventual goal is to try using this via the emacs lsp-sh mode)

Running the stated installation command gives:

[tree of packages to install]
npm ERR! Linux 4.4.0-134-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "i" "-g" "bash-language-server"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! path /usr/local/lib
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/len/npm-debug.log

Running as administrator doesn't help:

$ sudo npm i -g bash-language-server
loadDep:lodash            | |##################################################---------------------------------------------------------------------------------------------------------------------------------------------------|
loadDep:tr46 -> request   \ |##############################################################---------------------------------------------------------------------------------------------------------------------------------------|
loadDep:vscode-languagese \ |######################################################################-------------------------------------------------------------------------------------------------------------------------------|
/usr/local/bin/bash-language-server -> /usr/local/lib/node_modules/bash-language-server/bin/main.js

> [email protected] install /usr/local/lib/node_modules/bash-language-server/node_modules/tree-sitter-bash
> prebuild-install || node-gyp rebuild

/usr/bin/env: ‘node’: No such file or directory
/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:354:16)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.4.0-134-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/bash-language-server/node_modules/tree-sitter-bash
gyp ERR! node -v v4.2.6
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
/usr/local/lib
`-- (empty)

npm ERR! Linux 4.4.0-134-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "i" "-g" "bash-language-server"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'prebuild-install || node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tree-sitter-bash package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     prebuild-install || node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs tree-sitter-bash
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls tree-sitter-bash
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/len/npm-debug.log
npm ERR! code 1

Looks like 18.04 node may be too old. After updating nodejs to the latest it still doesn't work:

$ sudo npm i -g bash-language-server
/usr/bin/bash-language-server -> /usr/lib/node_modules/bash-language-server/bin/main.js

> [email protected] install /usr/lib/node_modules/bash-language-server/node_modules/tree-sitter
> prebuild-install || node-gyp rebuild

prebuild-install WARN install EACCES: permission denied, mkdir '/usr/lib/node_modules/bash-language-server/node_modules/tree-sitter/build'
gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/len/.node-gyp/10.11.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/bash-language-server/node_modules/tree-sitter/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/bash-language-server/node_modules/tree-sitter/.node-gyp'
gyp ERR! System Linux 4.4.0-134-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/bash-language-server/node_modules/tree-sitter
gyp ERR! node -v v10.11.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/len/.npm/_logs/2018-10-02T20_51_16_481Z-debug.log

Please help?

Improve outline view

Currently the outline view simply shows a flat list of all symbols in the file. I believe that you can get a hierarchical view if you return a bit more information (I think it's the name of the parent)

Silently ignore the error when EXPLAINSHELL_ENDPOINT is unavailable

EXPLAINSHELL_ENDPOINT is there to configure the source of the explainshell service, whether it would point to explainshell.com or a local Docker container. I would envision people to configure this environment variable somewhere globally, do it once and forget.

However, there could be times when the explainshell service is not running: Docker container image is stopped, or you have no internet access at the moment.

Currently, when EXPLAINSHELL_ENDPOINT is set, but the endpoint is not available, the editor is being spammed with an error:

image

I would like to propose to silently ignore this specific case, when the endpoint is not available, and just continue to try the other existing methods of getting the hover information.

What do you think?

Python may be required for development

Are developers expected to have Python installed? If yes, could this be mentioned in the README.md somewhere?

> git clone https://github.com/mads-hartmann/bash-language-server.git
Cloning into 'bash-language-server'...
remote: Counting objects: 125, done.
remote: Compressing objects: 100% (82/82), done.
remote: Total 125 (delta 64), reused 94 (delta 39), pack-reused 0
Receiving objects: 100% (125/125), 62.22 KiB | 0 bytes/s, done.
Resolving deltas: 100% (64/64), done.

> cd bash-language-server

> npm install
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8060) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
npm WARN prefer global [email protected] should be installed with -g

> [email protected] postinstall bash-language-server
> cd server && npm install && cd ../vscode-client && npm install && cd ..


> [email protected] install bash-language-server\server\node_modules\tree-sitter
> node-gyp rebuild


bash-language-server\server\node_modules\tree-sitter>if not defined npm_config_node_gyp (node "npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:449:14)
gyp ERR! stack     at npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:404:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd bash-language-server\server\node_modules\tree-sitter
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
[email protected] bash-language-server\server
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| |   +-- [email protected]
| |   `-- [email protected]
| +-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
`-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | `-- [email protected]
  `-- [email protected]

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v8.9.4
npm ERR! npm  v3.10.7
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tree-sitter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs tree-sitter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls tree-sitter
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     bash-language-server\server\npm-debug.log

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v8.9.4
npm ERR! npm  v3.10.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: `cd server && npm install && cd ../vscode-client && npm install && cd ..`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'cd server && npm install && cd ../vscode-client && npm install && cd ..'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bash-language-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cd server && npm install && cd ../vscode-client && npm install && cd ..
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bash-language-server
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bash-language-server
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     bash-language-server\npm-debug.log

Failure to parse array index expansion

local key
local -A assArray=(['a']=0 ['b']=1)
for key in "${!assArray[@]}"; do
  printf 'Key: %s, Value: %s\n' "${key}" "${assArray[${key}]}"
done

"${!assArray[@]}" Fails to parse due to the index expansion operator, !.

This feature was added to bash in version 3.0.

LanguageClient-neovim: Request textDocument/... fails

Hi, I use LanguageClient-neovim + deoplete for completions in neovim. I get the following error when I try to access documentation:
Request textDocument/hover failed with message: undefined is not a valid argument for URI also, I do not get any completion for flags, i.e. grep -| (cursor at |) does not trigger anything.
textDocument/DocumentSymbols also gives missing field `kind` . Other features seem to work well.

Vim client

How can I use it in vim?
If not, is there plan to support vim?

! char in ${!var} shows as invalid

I am using Bash IDE in VSCode and below code shows as invalid code while it is valid code

TEST_VAR=1
TEST_VAR1=1
declare -a list_of_variables=("TEST_VAR" "TEST_VAR1")
for var in ${list_of_variables[@]}
do
	echo "${var}=${!var}"
done

When I hover over ! char then it show 'Failed to parse expression' in tooltip

Doesn't work when installed via npm

When I install the tool via npm, my editor doesn't display any information from bash-language-server, as if I don't have it installed. When I compile the latest master from source, everything works.

I also tried npm install bash-language-server (so that it installs locally a fresh installation) and pointing my editor to the binary, still no luck.

I'm honestly puzzled, and the first thing I want to ask is this: is it possible that whatever got on npm.com doesn't match the current master?

Bash-language-server and explainshell container

Hello Everyone,

So I'm having some fun trying to get the bash language server with the explainshell integration working.

I have the explainshell container running and my settings look like:

{
    "files.autoSave": "afterDelay",
    "editor.tabSize": 2,
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/secrets": true
    },
    "ruby.lint": {
        "rubocop": true,
        "ruby": true, //Runs ruby -wc
    },
    "python.pythonPath": "/usr/local/opt/python@2/bin/python2.7",
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.linting.enabled": true,
    "python.linting.pylintPath": "/usr/local/bin/pylint",
    "bashIde.explainshellEndpoint": "http://localhost:5000"
}

If I browse to localhost:5000 in my browser everything works 100%. The container access logs only show the browser requests and I do not see bash-language-server trying to communicate at all.

Thoughts?

Can't install on Manjaro Linux 17.10

For the life of me, I can't get this package to install in NPM. Maybe I'm just doing this really incredibly wrong, or my system needs to be configured differently.

  1. Install command: sudo npm i -g bash-language-server

  2. While the project is installing, I see TONS of these error messages:

gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/bash-language-server/node_modules/tree-sitter/.node-gyp/10.4.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/bash-language-server/node_modules/tree-sitter/.node-gyp"
  1. After the installer finishes, I get a fatal error:
    npm-error.txt

  2. Here's the debug.log:
    2018-06-11T18_11_37_553Z-debug.log

Extension reports errors everywhere, not just where they happen

This one seems to be related to this extension rather then tree-sitter, correct me if I am wrong.

Bash IDE highlights the whole function (or even the whole file!) as erroneous, despite parsing error actually happens only in a single line of the function. Example:

ex3

And even worse when it is the whole file

ex2

So the issue here is the line [[ "$x" == *"something something"* ]]. If I remove it, the underline will be gone. It is a Tree-sitter issue and this is fine, I will report it and hope they will fix it.

What is puzzling here is why Bash IDE has highlighted the whole file in red, rendering it impossible to spot the problematic place. I would expect Bash IDE to only highlight the line, where the error has happened. Maybe also the function name.

But not all the lines in the function and definitely not all the lines in the file.

As bash developer I really want to see those highlights, because it helps to spot error early, but they need to be meaningful to be useful.

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.