-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to open hyperlinks in lsp-ui-doc #452
Comments
I've been trying to figure this out. It appears that the doc frame contains a buffer in markdown mode, but it does not actually contain markdown text. The text has already been forcibly font-locked by Not sure how to fix it though... |
Could be related to #379 |
@sebastiencs That works because the raw URL is in the text, so lsp-ui-doc--make-clickable-link can recognize it. The gopls server returns markdown with links like this:
The markdown rendering replaces the markdown link with just the font-locked anchor text, so there's no raw URL left to find. The rendered text isn't markdown at all, there are some font-lock hints left behind so markdown-mode tries to follow on a mouse click, but it searches for the original markdown |
Here's a workaround: (defun markdown-raw-links (&rest ignore)
"Convert link markup [ANCHOR](URL) to raw URL
so lsp-ui-doc--make-clickable-link can find it"
(save-excursion
(goto-char (point-min))
(while (re-search-forward markdown-regex-link-inline nil t)
(replace-match (replace-regexp-in-string "\n" "" (match-string 6))))))
(advice-add 'lsp--render-markdown :before #'markdown-raw-links) This replaces the markdown link with the raw URL before rendering, so it gives this: It would be better to get the rendering process to respect markdown links properly rather than post-processing in lsp-ui-doc to restore clickability only to raw URLs. Here's what it should look like - but this doesn't work if you click. |
@alanconway I tried to setup the go environment with lsp-mode, but without success. Can you see if it works ? |
@sebastiencs Works perfectly! Thanks for the very rapid fix 👍 |
Seems like this should go in lsp-mode to handle |
My guess would be to use another function than |
Uninformed speculation here: lsp-doc-ui is sort-of-but-not-actually using markdown-mode. It's only using it for font locking in the render phase, then it displays a font-locked string in the ui-doc window. Is it possible to change that? Have the ui-doc window display a real markdown-mode buffer with real markdown text? It is a much bigger fix but it has bigger benefits - no more playing catch-up to re-implement lost markdown-mode features (link following may not be the only such problem), and less coupling to the innards of markdown mode (text-property names) so less likely to be broken by future markdown-mode versions. Also that all applies for free to any other display mode you might need to use in future. |
Yes, we need to introduce a second function in lsp-mode for doing that. The current function does this odd stuff because the overlays do not support handling invisible string so we kind of strip that upfront. |
Actually, most likely we have to fix what we have how and use current logic only for the sideline. |
@alanconway markdown-mode is used to format the documentation: It sets the colors, text size, font etc. Using a markdown-mode buffer will bring some issues: |
Yep - using the full mode would save you implementing link-following etc. but also drag in a lot of other stuff you don't need, which is risky. Your evaluation of the trade-off is certainly better informed than mine :) Keep up the good work, I depend on this tool to supplement my ageing memory! Cheers, |
It's frustrating. I can hover my mouse over a link, and it shows the url in the bottom, but there doesn't seem to be a way to actually browse to the url! |
Oh! I found that |
Can we close this issue? 😕 |
|
We should probably update |
💯 That would be great. I tend to not use lsp-ui-doc. Does this call for a bug report at the main lsp repo? I would write it, but I feel like others would be better able to provide clarity on how to fix it, given that it's fixed here in lsp-ui. |
Yes, please file a bug/feature request there. Btw, calling |
Still an issue for me, on
Maybe it's because the link itself defines a keymap (at least in lsp-haskell). If I focus the frame and C-h c I get a text property |
… buffers (#3844) * Fix markdown link navigation in *lsp-help* buffers Fix emacs-lsp/lsp-ui#452 * Treat all markdown link types the same - markdown-link-face, markdown-url-face and markdown-plain-url-face * Inhibit read-only in lsp--fix-markdown-links for Emacs27 * Use markdown-find-next-prop instead of text-property-search-forward which is missing on Emacs26 * Start searching from point-min in lsp--fix-markdown-links
When I click on any hyperlink in
lsp-ui-doc
buffers, I observe this in my messages bufffer:And the link does not open in my browser.
Here is my environment info:
The text was updated successfully, but these errors were encountered: