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 dc1df7b

Browse files
committed
Now man pages have syntax highlighting
1 parent dfe5d60 commit dc1df7b

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

‎server/src/server.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,22 @@ export default class BashServer {
134134
}
135135
}
136136

137+
const getMarkdownHoverItem = (doc: string) => ({
138+
// LSP.MarkupContent
139+
value: ['``` man', doc, '```'].join('\n'),
140+
// Passed as markdown for syntax highlighting
141+
kind: 'markdown' as const,
142+
})
143+
137144
if (Builtins.isBuiltin(word)) {
138145
return Builtins.documentation(word).then(doc => ({
139-
contents: {
140-
language: 'plaintext',
141-
value: doc,
142-
},
146+
contents: getMarkdownHoverItem(doc),
143147
}))
144148
}
145149

146150
if (this.executables.isExecutableOnPATH(word)) {
147151
return this.executables.documentation(word).then(doc => ({
148-
contents: {
149-
language: 'plaintext',
150-
value: doc,
151-
},
152+
contents: getMarkdownHoverItem(doc),
152153
}))
153154
}
154155

@@ -216,28 +217,24 @@ export default class BashServer {
216217
const {
217218
data: { name, type },
218219
} = item
220+
221+
const getMarkdownCompletionItem = (doc: string) => ({
222+
...item,
223+
// LSP.MarkupContent
224+
documentation: {
225+
value: ['``` man', doc, '```'].join('\n'),
226+
// Passed as markdown for syntax highlighting
227+
kind: 'markdown' as const,
228+
},
229+
})
230+
219231
try {
220232
if (type === 'executable') {
221233
const doc = await this.executables.documentation(name)
222-
return {
223-
...item,
224-
documentation: {
225-
// LSP.MarkupContent
226-
value: doc,
227-
// Passed as plaintext to not break man pages formatting
228-
kind: 'plaintext',
229-
},
230-
}
234+
return getMarkdownCompletionItem(doc)
231235
} else if (type === 'builtin') {
232236
const doc = await Builtins.documentation(name)
233-
return {
234-
...item,
235-
documentation: {
236-
// LSP.MarkupContent
237-
value: doc,
238-
kind: 'plaintext',
239-
},
240-
}
237+
return getMarkdownCompletionItem(doc)
241238
} else {
242239
return item
243240
}

0 commit comments

Comments
(0)

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