Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 00d79a5

Browse files
Show hover information for builtins
1 parent a5e6a94 commit 00d79a5

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

‎server/src/builtins.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export const LIST = [
6262
'wait',
6363
]
6464

65+
export function isBuiltin(word: string): boolean {
66+
return LIST.find(builtin => builtin === word) !== undefined
67+
}
68+
6569
export async function documentation(builtin: string): Promise<string> {
6670
const errorMessage = `No help page for ${builtin}`
6771
try {

‎server/src/server.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,23 @@ export default class BashServer {
107107

108108
const word = this.getWordAtPoint(pos)
109109

110-
return this.executables.isExecutableOnPATH(word)
111-
? this.executables.documentation(word).then(doc => ({
112-
contents: {
113-
language: 'plaintext',
114-
value: doc,
115-
},
116-
}))
117-
: null
110+
if (Builtins.isBuiltin(word)) {
111+
return Builtins.documentation(word).then(doc => ({
112+
contents: {
113+
language: 'plaintext',
114+
value: doc,
115+
},
116+
}))
117+
} else if (this.executables.isExecutableOnPATH(word)) {
118+
return this.executables.documentation(word).then(doc => ({
119+
contents: {
120+
language: 'plaintext',
121+
value: doc,
122+
},
123+
}))
124+
} else {
125+
return null
126+
}
118127
}
119128

120129
private onDefinition(pos: LSP.TextDocumentPositionParams): LSP.Definition {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /