@@ -6,6 +6,7 @@ import * as Builtins from './builtins'
6
6
import * as config from './config'
7
7
import Executables from './executables'
8
8
import { initializeParser } from './parser'
9
+ import * as ReservedWords from './reservedWords'
9
10
10
11
/**
11
12
* The BashServer glues together the separate components to implement
@@ -161,6 +162,12 @@ export default class BashServer {
161
162
} ) )
162
163
}
163
164
165
+ if ( ReservedWords . isReservedWord ( word ) ) {
166
+ return ReservedWords . documentation ( word ) . then ( doc => ( {
167
+ contents : getMarkdownHoverItem ( doc ) ,
168
+ } ) )
169
+ }
170
+
164
171
if ( this . executables . isExecutableOnPATH ( word ) ) {
165
172
return this . executables . documentation ( word ) . then ( doc => ( {
166
173
contents : getMarkdownHoverItem ( doc ) ,
@@ -203,6 +210,17 @@ export default class BashServer {
203
210
204
211
const symbolCompletions = this . analyzer . findSymbolCompletions ( params . textDocument . uri )
205
212
213
+ // TODO: we could do some caching here...
214
+
215
+ const reservedWordsCompletions = ReservedWords . LIST . map ( reservedWord => ( {
216
+ label : reservedWord ,
217
+ kind : LSP . SymbolKind . Interface , // ??
218
+ data : {
219
+ name : reservedWord ,
220
+ type : 'reservedWord' ,
221
+ } ,
222
+ } ) )
223
+
206
224
const programCompletions = this . executables . list ( ) . map ( ( s : string ) => {
207
225
return {
208
226
label : s ,
@@ -225,6 +243,7 @@ export default class BashServer {
225
243
226
244
// TODO: we have duplicates here (e.g. echo is both a builtin AND have a man page)
227
245
const allCompletions = [
246
+ ...reservedWordsCompletions ,
228
247
...symbolCompletions ,
229
248
...programCompletions ,
230
249
...builtinsCompletions ,
@@ -269,6 +288,9 @@ export default class BashServer {
269
288
} else if ( type === 'builtin' ) {
270
289
const doc = await Builtins . documentation ( name )
271
290
return getMarkdownCompletionItem ( doc )
291
+ } else if ( type === 'reservedWord' ) {
292
+ const doc = await ReservedWords . documentation ( name )
293
+ return getMarkdownCompletionItem ( doc )
272
294
} else {
273
295
return item
274
296
}
0 commit comments