-
Notifications
You must be signed in to change notification settings - Fork 246
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
replace multiple space into single space on markdown text in hover #844
replace multiple space into single space on markdown text in hover #844
Conversation
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
Hi, thanks a lot for looking into this issue. Thanks, |
Thanks for your response. I will try to preserve the space from string |
Thanks a lot. Please let me know how it goes, Hopefully the spaces can be preserved, otherwise it would have a big impact for our users. |
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
Hello @fabiodouek, As I am preserving the space from string. Please refer the attachment |
…tion-attribute-when-hovering-over-an-attribute
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
Hi @msivasubramaniaan , that's great, thanks a lot for that. Thanks, |
Hello @fabiodouek You can expect the release 1st week of March. The pre-release by end of next week. |
…tion-attribute-when-hovering-over-an-attribute
I don't think this is the right approach. The language server is behaving exactly per the spec. The problem is with the client not being able to handle the response. The language server returns a https://github.com/microsoft/vscode-languageserver-node/blob/release/client/7.0.0/client/src/common/protocolConverter.ts#L361 is probably what gets called to convert our hover LS response into a VS Code hover so I think we just need to figure out what's going wrong there. FWIW, I see that vscode-java properly deals with the hover and doesn't unescape the underscores. |
…tion-attribute-when-hovering-over-an-attribute
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
@@ -10,7 +10,8 @@ | |||
"sourceMaps": true, | |||
"outFiles": ["${workspaceRoot}/out/server/**/*.ts"], | |||
"protocol": "inspector", | |||
"trace": true | |||
"trace": true, | |||
"preLaunchTask": "watch typescript", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added pre launch check
@@ -86,9 +88,10 @@ export class YAMLHover { | |||
); | |||
|
|||
const createHover = (contents: string): Hover => { | |||
const regex = new RegExp(this.indentation, 'g'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is pretty reasonable, so feel free to merge when ready. If in the future we end up having to do more replacement (beyond just the indentation string), it might be good to create a separate helper method.
Seems this broke presentation in Neovim:
|
@polyzen , I'm guessing Neovim doesn't handle Markdown coming from the hovers ? @msivasubramaniaan , could #837 solve this issue ? |
https://neovim.io/doc/user/lsp.html#lsp-util Not really sure how it works. |
It mentions : ... Converts any of MarkedString | MarkedString[] | MarkupContent into a list of lines containing valid markdown. However, if you look at
The other thing to check is if we respect https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#hoverClientCapabilities , which allows the clients to set their preferred format through |
This comment was marked as resolved.
This comment was marked as resolved.
Yes @rgrunber I hope #837 will resolve. @polyzen Can you please share the |
I'm facing the same issue as polyzen
Actually neovim handles markdown from hovers and parses it a bit for better stylization. The thing is that it doesn't actually handle HTML escape sequences, so the Consider the following content returned from a {
"contents": {
"kind": "markdown",
"value": " # # # #   g i t l a b \\ - c i \n \n T h e   n a m e   o f   o n e   o r   m o r e   j o b s   t o   i n h e r i t   c o n f i g u r a t i o n   f r o m \\ . \n \n S o u r c e :   [ c i . j s o n ] ( h t t p s : / / g i t l a b . c o m / g i t l a b - o r g / g i t l a b / - / r a w / m a s t e r / a p p / a s s e t s / j a v a s c r i p t s / e d i t o r / s c h e m a / c i . j s o n ) "
},
"range": {
"end": {
"character": 9,
"line": 2377
},
"start": {
"character": 2,
"line": 2377
}
}
} The return itself is weird, containing In neovim we can treat this by adding a wrapper function to handle the local function hover_wrapper(err, request, ctx, config)
local bufnr, winnr = vim.lsp.handlers.hover(err, request, ctx, config)
local contents = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
contents = vim.tbl_map(
function(line)
return string.gsub(line, " ", " ")
end,
contents
)
contents = vim.lsp.util.trim_empty_lines(contents)
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, contents)
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
vim.api.nvim_win_set_height(winnr, #contents)
end
vim.lsp.handlers["textDocument/hover"] = hover_wrapper Even so, by replacing while replacing it with nothing I'm not sure I understand the reasoning behind replacing indentations with Aside from that, I also think that neovim can benefit from properly handling HTML escape sequences, I'll create an issue there as well about this. |
Oh yeah, I almost forgot. To reproduce this, here's a minimal local settings = {
yaml = {
schemas = {
["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = ".gitlab-ci.y*l",
},
hover = true,
}
}
vim.api.nvim_create_autocmd('FileType', {
pattern = "yaml",
callback = function(args)
vim.lsp.start({
name = 'yamlls',
cmd = { 'yaml-language-server', '--stdio' },
root_dir = vim.fn.fnamemodify('./.gitlab-ci.yaml', ':p:h'),
settings = settings
})
end
})
vim.keymap.set('n', '<space>', vim.lsp.buf.hover, {})
stages:
- hello
|
One small tweak to @Kasama's fix that will account for instances where there is no LSP information for a hover (e.g. a yaml file without an accompanying schema):
Prevents issues like:
|
Signed-off-by: msivasubramaniaan msivasub@redhat.com
What does this PR do?
This PR shows the description without escape sequence char even description has indentation on hover
What issues does this PR fix or reference?
redhat-developer/vscode-yaml#886
Is it tested? How?
Yes. Added UT