Improve hover tool tips and function docs (#5538)
* Improve hover tool tips and function docs Signed-off-by: Nick Cameron <nrc@ncameron.org> * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) --------- Signed-off-by: Nick Cameron <nrc@ncameron.org> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -28,6 +28,7 @@ export default function lspHoverExt(
|
||||
'.cm-tooltip': {
|
||||
fontSize: '12px',
|
||||
maxWidth: '400px',
|
||||
padding: '2px',
|
||||
},
|
||||
}),
|
||||
]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Text } from '@codemirror/state'
|
||||
import { Marked } from '@ts-stack/markdown'
|
||||
import { Marked, MarkedOptions } from '@ts-stack/markdown'
|
||||
|
||||
import type * as LSP from 'vscode-languageserver-protocol'
|
||||
import { isArray } from '../lib/utils'
|
||||
@ -43,14 +43,18 @@ export function offsetToPos(doc: Text, offset: number) {
|
||||
}
|
||||
}
|
||||
|
||||
const markedOptions: MarkedOptions = {
|
||||
gfm: true,
|
||||
}
|
||||
|
||||
export function formatMarkdownContents(
|
||||
contents: LSP.MarkupContent | LSP.MarkedString | LSP.MarkedString[]
|
||||
): string {
|
||||
if (isArray(contents)) {
|
||||
return contents.map((c) => formatMarkdownContents(c) + '\n\n').join('')
|
||||
} else if (typeof contents === 'string') {
|
||||
return Marked.parse(contents)
|
||||
return Marked.parse(contents, markedOptions)
|
||||
} else {
|
||||
return Marked.parse(contents.value)
|
||||
return Marked.parse(contents.value, markedOptions)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user