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
44 changes: 23 additions & 21 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,21 +117,37 @@ 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),
},
}
} else {
return null
}
}

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

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 {
this.connection.console.log(
`Asked for definition at ${pos.position.line}:${pos.position.character}`,
Expand Down