aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/_inlay_hint.lua
diff options
context:
space:
mode:
authorAkin <22454918+akinsho@users.noreply.github.com>2023-06-21 09:55:19 +0200
committerGitHub <noreply@github.com>2023-06-21 00:55:19 -0700
commite42fdaad21a87d0aaf882f1ad836b00d2eccd21a (patch)
tree53006c5647b59c3e508386d19c9a2eeff8d19316 /runtime/lua/vim/lsp/_inlay_hint.lua
parent1b679ac192877ae21e531d2eaa88ef0918f1dfe1 (diff)
downloadrneovim-e42fdaad21a87d0aaf882f1ad836b00d2eccd21a.tar.gz
rneovim-e42fdaad21a87d0aaf882f1ad836b00d2eccd21a.tar.bz2
rneovim-e42fdaad21a87d0aaf882f1ad836b00d2eccd21a.zip
fix(lsp): add spacing for inlay hints separately #24079
Problem: Spacing around inlay hints has the same highlight as the hint itself. The LSP spec for inlay hints specifically mentions the padding should not be coloured: /** Render padding before the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint. */ paddingLeft?: boolean; /** Render padding after the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint. */ paddingRight?: boolean; Solution: Add the space as separate parts of the virtual text, don't add the space to the text itself.
Diffstat (limited to 'runtime/lua/vim/lsp/_inlay_hint.lua')
-rw-r--r--runtime/lua/vim/lsp/_inlay_hint.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/runtime/lua/vim/lsp/_inlay_hint.lua b/runtime/lua/vim/lsp/_inlay_hint.lua
index e7cc8ba7ae..8edf14e707 100644
--- a/runtime/lua/vim/lsp/_inlay_hint.lua
+++ b/runtime/lua/vim/lsp/_inlay_hint.lua
@@ -252,18 +252,18 @@ api.nvim_set_decoration_provider(namespace, {
text = text .. part.value
end
end
+ local vt = {}
if hint.paddingLeft then
- text = ' ' .. text
+ vt[#vt + 1] = { ' ' }
end
+ vt[#vt + 1] = { text, 'LspInlayHint' }
if hint.paddingRight then
- text = text .. ' '
+ vt[#vt + 1] = { ' ' }
end
api.nvim_buf_set_extmark(bufnr, namespace, lnum, hint.position.character, {
virt_text_pos = 'inline',
ephemeral = false,
- virt_text = {
- { text, 'LspInlayHint' },
- },
+ virt_text = vt,
hl_mode = 'combine',
})
end