bash-lsp/bash-language-server

`shfmt` doesn't work in VS Code

lishaduck opened this issue · 3 comments

Code editor

VS Code

Platform

macOS

Version

v1.41.0

What steps will reproduce the bug?

  1. Open any shell script.
  2. Open command pallet with ⌘+⇧+P
  3. Run "Format document"

How often does it reproduce? Is there a required condition?

100% of the time.

What is the expected behavior?

Bash IDE would register itself as a formatting provider.

What do you see instead?

A message stating that "There is no formatter for 'shellscript' files installed." pops up.

Additional information

[Info  - 12:15:42 PM] 17:15:41.878 INFO BackgroundAnalysis: resolving glob "**/*@(.sh|.inc|.bash|.command)" inside "file:///Users/dukese01/Developer/node-elm-review"...
[Info  - 12:15:43 PM] 17:15:42.339 INFO BackgroundAnalysis: Glob resolved with 5 files after 0.461 seconds
[Info  - 12:15:43 PM] 17:15:42.365 INFO BackgroundAnalysis: Completed after 0.487 seconds.

The code shows that the server supports it, but the client hasn't hooked it up.
I think you need to call registerDocumentFormattingEditProvider() somewhere.

Everything else works, great extension!

It looks like the VS Code plugin (version 1.41.0) still depends upon bash-language-server version 5.2.0, which is the version before shfmt support was added. Unfortunately 1.41.0 has picked up the updated client code, including the configuration options for shfmt (which won't actually do anything right now as the bundled language server doesn't support it).

@skovhus It looks like we need to build an updated VS code extension after bumping the language server dependency.

This can be closed now that #1178 has been merged in.

Thank you!