@@ -2,6 +2,14 @@ let s:use_vim_popup = has('patch-8.1.1517') && g:lsp_preview_float && !has('nvim
2
2
let s: use_nvim_float = exists (' *nvim_open_win' ) && g: lsp_preview_float && has (' nvim' )
3
3
let s: use_preview = ! s: use_vim_popup && ! s: use_nvim_float
4
4
5
+ function ! s: import_modules () abort
6
+ if exists (' s:Markdown' ) | return | endif
7
+ let s: Markdown = vital#lsp#import (' VS.Vim.Syntax.Markdown' )
8
+ let s: MarkupContent = vital#lsp#import (' VS.LSP.MarkupContent' )
9
+ let s: Window = vital#lsp#import (' VS.Vim.Window' )
10
+ let s: Text = vital#lsp#import (' VS.LSP.Text' )
11
+ endfunction
12
+
5
13
let s: winid = v: false
6
14
let s: prevwin = v: false
7
15
let s: preview_data = v: false
@@ -386,6 +394,11 @@ function! lsp#ui#vim#output#preview(server, data, options) abort
386
394
doautocmd <nomodeline> User lsp_float_opened
387
395
endif
388
396
397
+ if l: ft == ? ' markdown'
398
+ call s: import_modules ()
399
+ call s: Window .do (s: winid , {- >s: Markdown .apply ()})
400
+ endif
401
+
389
402
if ! g: lsp_preview_keep_focus
390
403
" set the focus to the preview window
391
404
call win_gotoid (s: winid )
@@ -406,7 +419,6 @@ function! lsp#ui#vim#output#append(data, lines, syntax_lines) abort
406
419
return ' markdown'
407
420
elseif type (a: data ) == # type (' ' )
408
421
call extend (a: lines , split (s: escape_string_for_display (a: data ), " \n " , v: true ))
409
-
410
422
return ' markdown'
411
423
elseif type (a: data ) == # type ({}) && has_key (a: data , ' language' )
412
424
let l: new_lines = split (s: escape_string_for_display (a: data .value), ' \n' )
@@ -418,11 +430,15 @@ function! lsp#ui#vim#output#append(data, lines, syntax_lines) abort
418
430
endwhile
419
431
420
432
call extend (a: lines , l: new_lines )
421
-
422
433
return ' markdown'
423
434
elseif type (a: data ) == # type ({}) && has_key (a: data , ' kind' )
424
- call extend (a: lines , split (s: escape_string_for_display (a: data .value), ' \n' , v: true ))
425
-
435
+ if a: data .kind == ? ' markdown'
436
+ call s: import_modules ()
437
+ let l: detail = s: MarkupContent .normalize (a: data .value)
438
+ call extend (a: lines , s: Text .split_by_eol (l: detail ))
439
+ else
440
+ call extend (a: lines , split (s: escape_string_for_display (a: data .value), ' \n' , v: true ))
441
+ endif
426
442
return a: data .kind == ? ' plaintext' ? ' text' : a: data .kind
427
443
endif
428
444
endfunction
0 commit comments