Skip to content
Merged
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
48 changes: 25 additions & 23 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,7 @@ export default class BashServer {

const word = this.getWordAtPoint(pos)

if (Builtins.isBuiltin(word)) {
return Builtins.documentation(word).then(doc => ({
contents: {
language: 'plaintext',
value: doc,
},
}))
} else if (this.executables.isExecutableOnPATH(word)) {
return this.executables.documentation(word).then(doc => ({
contents: {
language: 'plaintext',
value: doc,
},
}))
} else if (process.env.EXPLAINSHELL_ENDPOINT !== '') {
if (process.env.EXPLAINSHELL_ENDPOINT !== '') {
const response = await this.analyzer.getExplainshellDocumentation({
pos,
endpoint: process.env.EXPLAINSHELL_ENDPOINT,
Expand All @@ -131,19 +117,35 @@ export default class BashServer {
this.connection.console.log(
'getExplainshellDocumentation returned: ' + JSON.stringify(response, null, 4),
)

return null
} else {
return {
contents: {
kind: 'markdown',
value: new TurndownService().turndown(response.helpHTML),
},
}
}
}

return {
if (Builtins.isBuiltin(word)) {
return Builtins.documentation(word).then(doc => ({
contents: {
kind: 'markdown',
value: new TurndownService().turndown(response.helpHTML),
language: 'plaintext',
value: doc,
},
}
} else {
return null
}))
}

if (this.executables.isExecutableOnPATH(word)) {
return this.executables.documentation(word).then(doc => ({
contents: {
language: 'plaintext',
value: doc,
},
}))
}

return null
}

private onDefinition(pos: LSP.TextDocumentPositionParams): LSP.Definition {
Expand Down