@@ -113,6 +113,11 @@ This only takes effect when `lsp-ui-doc-position' is 'top or 'bottom."
113113 :type 'integer
114114 :group 'lsp-ui-doc )
115115
116+ (defcustom lsp-ui-doc-webkit-max-width-px 600
117+ " Maximum width in pixels for the webkit frame."
118+ :type 'integer
119+ :group 'lsp-ui-doc )
120+
116121(defcustom lsp-ui-doc-max-height 13
117122 " Maximum number of lines in the frame."
118123 :type 'integer
@@ -305,7 +310,9 @@ Because some variables are buffer local.")
305310 (markdown-hr-display-char nil ))
306311 (cond
307312 (lsp-ui-doc-use-webkit
308- (if (and language (not (string= " text" language)))
313+ (if (and language
314+ (not (string= " text" language))
315+ (not (string= lsp/markup-kind-markdown language)))
309316 (format " ```%s \n %s \n ``` " language string)
310317 string))
311318 ; ; For other programming languages
@@ -364,9 +371,16 @@ We don't extract the string that `lps-line' is already displaying."
364371 (xwidget-webkit-mode)
365372 (xwidget-webkit-goto-uri (xwidget-at 1 )
366373 lsp-ui-doc-webkit-client-path)
374+ (lsp-ui-doc--webkit-set-width)
367375 (lsp-ui-doc--webkit-set-background)
368376 (lsp-ui-doc--webkit-set-foreground)))))
369377
378+ (defun lsp-ui-doc--webkit-set-width ()
379+ " Set webkit document max-width CSS property."
380+ (lsp-ui-doc--webkit-execute-script
381+ (format " document.documentElement.style.setProperty('--webkit-max-width-px', %d + 'px'); "
382+ lsp-ui-doc-webkit-max-width-px)))
383+
370384(defun lsp-ui-doc--webkit-set-background ()
371385 " Set background color of the WebKit widget."
372386 (lsp-ui-doc--webkit-execute-script
0 commit comments