]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
fix: the markdown break line maybe ugly
authorshane.xb.qian <shane.qian@foxmail.com>
Mon, 14 Nov 2022 12:01:38 +0000 (20:01 +0800)
committershane.xb.qian <shane.qian@foxmail.com>
Mon, 14 Nov 2022 12:01:38 +0000 (20:01 +0800)
autoload/lsp/markdown.vim
ftplugin/lspgfm.vim

index 47a70f448a259ffea4430c5059cc276899cc8d02..330a69456ac1c8af2f49289ea8c8aa828e0cf279 100644 (file)
@@ -545,7 +545,7 @@ def CloseBlocks(document: dict<list<any>>, blocks: list<dict<any>>, start: numbe
   endfor
 enddef
 
-export def ParseMarkdown(data: list<string>): dict<list<any>>
+export def ParseMarkdown(data: list<string>, width: number = 80): dict<list<any>>
   var document: dict<list<any>> = {content: [], syntax: []}
   var open_blocks: list<dict<any>> = []
 
@@ -618,9 +618,9 @@ export def ParseMarkdown(data: list<string>): dict<list<any>>
     if line =~ thematic_break
       CloseBlocks(document, open_blocks)
       if &g:encoding == "utf-8"
-       document.content->add({text: "\u2500"->repeat(80)})
+       document.content->add({text: "\u2500"->repeat(width)})
       else
-       document.content->add({text: "-"->repeat(80)})
+       document.content->add({text: "-"->repeat(width)})
       endif
       last_block = "hr"
       continue
index 52b63ddaebd2737e1a6c71db0e827f30153597dd..75d7fd14d3b4d730766eb572dbcc502a4bfd2b91 100644 (file)
@@ -8,7 +8,7 @@ var document: dict<list<any>>
 
 try
   popup_id = bnr->getbufinfo()[0].popups[0]
-  document = md.ParseMarkdown(bnr->getbufline(1, '$'))
+  document = md.ParseMarkdown(bnr->getbufline(1, '$'), winwidth(popup_id))
 catch /.*/
   b:markdown_fallback = v:true
   finish