Skip to content

Fix no diagnostics without WorkspaceFolders support #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Bash Language Server

## 3.0.5

- Fix Shellcheck issue when using vim-lsp https://github.com/bash-lsp/bash-language-server/pull/443

## 3.0.4

- Fix Windows support for analyzer https://github.com/bash-lsp/bash-language-server/pull/433
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A language server for Bash",
"author": "Mads Hartmann",
"license": "MIT",
"version": "3.0.4",
"version": "3.0.5",
"publisher": "mads-hartmann",
"main": "./out/server.js",
"typings": "./out/server.d.ts",
Expand Down
11 changes: 8 additions & 3 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class BashServer {
*/
public static async initialize(
connection: LSP.Connection,
{ rootPath }: LSP.InitializeParams,
{ rootPath, capabilities }: LSP.InitializeParams,
): Promise<BashServer> {
const parser = await initializeParser()

Expand All @@ -43,7 +43,7 @@ export default class BashServer {
Analyzer.fromRoot({ connection, rootPath, parser }),
new Linter({ executablePath: config.getShellcheckPath() }),
]).then(([executables, analyzer, linter]) => {
return new BashServer(connection, executables, analyzer, linter)
return new BashServer(connection, executables, analyzer, linter, capabilities)
})
}

Expand All @@ -53,17 +53,20 @@ export default class BashServer {

private documents: LSP.TextDocuments<TextDocument> = new LSP.TextDocuments(TextDocument)
private connection: LSP.Connection
private clientCapabilities: LSP.ClientCapabilities

private constructor(
connection: LSP.Connection,
executables: Executables,
analyzer: Analyzer,
linter: Linter,
capabilities: LSP.ClientCapabilities,
) {
this.connection = connection
this.executables = executables
this.analyzer = analyzer
this.linter = linter
this.clientCapabilities = capabilities
}

/**
Expand All @@ -83,7 +86,9 @@ export default class BashServer {
// Run shellcheck diagnostics:
let diagnostics: LSP.Diagnostic[] = []

const folders = await connection.workspace.getWorkspaceFolders()
const folders = this.clientCapabilities.workspace?.workspaceFolders
? await connection.workspace.getWorkspaceFolders()
: []
const lintDiagnostics = await this.linter.lint(change.document, folders || [])
diagnostics = diagnostics.concat(lintDiagnostics)

Expand Down