-
Notifications
You must be signed in to change notification settings - Fork 25
Support inline virtual text #46
Comments
Testers needed for the TODO yield every 5ms on the main 'render' loop. Ref |
@lvimuser I would like to test it. Do you mind sharing instructions on how to apply the patch on neovim In neovim repo directory I do: $ wget https://patch-diff.githubusercontent.com/raw/neovim/neovim/pull/23426.patch && git apply 23426.patch --allow-overlap --reject --whitespace=fix
$ make CMAKE_BUILD_TYPE=RelWithDebInfo Fails with error: mkdir -p build
touch build/.ran-deps-cmake
ninja -C .deps
ninja: Entering directory `.deps'
[4/10] Performing download step (download, verify and extract) for 'libuv'
FAILED: build/src/libuv-stamp/libuv-download /Users/lukasz.kurpiewski/Projects/neovim/.deps/build/src/libuv-stamp/libuv-download
cd /Users/lukasz.kurpiewski/Projects/neovim/.deps/build/src && /opt/homebrew/Cellar/cmake/3.26.3/bin/cmake -P /Users/lukasz.kurpiewski/Projects/neovim/.deps/build/src/libuv-stamp/download-libuv.cmake && /opt/homebrew/Cellar/cmake/3.26.3/bin/cmake -P /Users/lukasz.kurpiewski/Projects/neovim/.deps/build/src/libuv-stamp/verify-libuv.cmake && /opt/homebrew/Cellar/cmake/3.26.3/bin/cmake -P /Users/lukasz.kurpiewski/Projects/neovim/.deps/build/src/libuv-stamp/extract-libuv.cmake && /opt/homebrew/Cellar/cmake/3.26.3/bin/cmake -E touch /Users/lukasz.kurpiewski/Projects/neovim/.deps/build/src/libuv-stamp/libuv-download
-- Downloading...
dst='/Users/lukasz.kurpiewski/Projects/neovim/.deps/build/downloads/libuv/62c2374a8c005ce9e42088965f8f8af2532c177b.tar.gz'
timeout='none'
inactivity timeout='none'
-- Using src='https://github.com/libuv/libuv/archive/62c2374a8c005ce9e42088965f8f8af2532c177b.tar.gz'
-- verifying file...
file='/Users/lukasz.kurpiewski/Projects/neovim/.deps/build/downloads/libuv/62c2374a8c005ce9e42088965f8f8af2532c177b.tar.gz'
-- SHA256 hash of
/Users/lukasz.kurpiewski/Projects/neovim/.deps/build/downloads/libuv/62c2374a8c005ce9e42088965f8f8af2532c177b.tar.gz
does not match expected value
expected: 'cd97aff8e7073fb128aef7a45e9183264ccaf07945a6cb430053070bd03ff200'
actual: 'c7e89137da65a1cb550ba96b892dfeeabea982bf33b9237bcf9bbcd90f2e70a1'
-- Hash mismatch, removing...
(...) If I just apply the patch without 2023-05-11 15:10:52 (1.35 MB/s) - ‘23426.patch’ saved [137917]
error: patch failed: runtime/doc/news.txt:52
error: runtime/doc/news.txt: patch does not apply |
|
I've pushed a commit, could you try it out?
Try to experiment with different values of highlight in the formatter function, perhaps virt_text_formatter = function(label, hint, opts, client_name)
...
local vt = {}
vt[#vt + 1] = hint.paddingLeft and { " ", "Normal" } or nil
vt[#vt + 1] = { label, opts.highlight }
vt[#vt + 1] = hint.paddingRight and { " ", "Normal" } or nil
return vt
end, if not, then it's probably aa1fee3#diff-35ff978c429cae2ed9217298ef4810beb45307b1baee86f83eb7233f60109fbaL132 |
I've checked the newest commit and now it works well. vt[#vt + 1] = hint.paddingLeft and { " ", "None" } or nil
vt[#vt + 1] = { label, opts.highlight }
vt[#vt + 1] = hint.paddingRight and { " ", "None" } or nil or even vt[#vt + 1] = hint.paddingLeft and { " " } or nil
vt[#vt + 1] = { label, opts.highlight }
vt[#vt + 1] = hint.paddingRight and { " " } or nil works just as intended. Thanks and that all from my side |
If you have hints at the end of a line, it means that you have this plugin version from "main" branch and you need version from "anticonceal" branch. Packer has "brach" option you can add in your config to install plugin version from branch ("lazy" should have something similar) |
thanks for the info @KostkaBrukowa! Works now. |
This seems to work great, with one issue: calling |
The anticonceal feature has been merged to master neovim/neovim#20130 |
woo I am excited for this update |
If you didn't know, you could use the |
Very nice plugin, thank you. Edit: workaround: |
Tested and works with lua, cpp, TS with anticonceal, was not successful with rust, anyone else got it working ? EDIT: should probably state the issue, nothing is showing at all with the anticonceal branch everything works fine on master. |
Tested on TS also and had no issues, super thanks! |
Thanks, it's way better.
Not sure... I'll look into it on the weekend. |
I wonder if this also happens with neovim/neovim#23736...? If so, it's probably a bug in core |
It seems like the hints only show up after making some change to the file. but then they update normally EDIT: does it have something to do with the fact that when inlayhints tries to render initially, rust_analyzer is probably still stuck indexing, so it fails, and then only updates on edit. is there a change related to that in the anticonceal branch? |
@IndianBoy42 Yes you are correct, editing the file does resolve the problem, interesting. |
@A-Lamia You can try https://github.com/junnplus/lsp-setup.nvim#inlay-hints, I have tested it on Rust and it should work. |
Things are working pretty well, but with a few caveats:
|
It might also be worth it to think about the future of this plugin when this pr exists |
Seem to not have any luck with I'm guessing the rust configuration, still the same problem where you need to edit to get things to show up. |
@ rust-analyzer. Does it happen only on the first buffer, or on each new buffer? |
Huh, I dont know what happened but now it just works from the first buffer |
Using anticonceal branch on nightly (NVIM v0.10.0-dev-411+g9dd48f783), rust-analyzer inlay hints don't seem to work until rust-analyzer is stopped and started again. Anyone experience something similar, or have a fix? Config: {
"lvimuser/lsp-inlayhints.nvim",
event = "LspAttach",
branch = "anticonceal",
opts = {},
config = function(_, opts)
require("lsp-inlayhints").setup(opts)
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("LspAttach_inlayhints", {}),
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, args.buf)
end,
})
end,
}, |
You're creating the autocommand after the LspAttach event, so it'll only trigger on subsequent events... Think about the loading order. You can
Details
{
"lvimuser/lsp-inlayhints.nvim",
branch = "anticonceal",
opts = {},
lazy = true,
init = function()
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("LspAttach_inlayhints", {}),
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, args.buf)
end,
})
end,
} |
for lazy.nvim you want |
this is still not supported yet right? as well what neovim version am I required for the inline virtual text? |
Thanks @lvimuser and @IndianBoy42, this worked: Details {
"lvimuser/lsp-inlayhints.nvim",
event = "LspAttach",
branch = "anticonceal",
opts = {},
init = function()
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("LspAttach_inlayhints", {}),
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, args.buf)
end,
})
end,
}, |
depends on what you consider supported
nightly |
I mean if it will work like vscode, jetbrains, visual studion, etc. if I implement this now to my nvim to have the inlay hints right inside where the parameters go instead of being outside. |
Have you tried the anticonceal branch mentioned in the second comment? |
would this plugin/branch still be necessary after neovim/neovim#23984 ? No. The core implementation is miles better than this plugin. I'll archive this repo. |
The feature I looked for is displaying inlay hints for current line only. And that is not possible with neovim core yet. Edit: Neither does it allow to change the placement of hints. |
Same issue with https://github.com/mrcjkb/rustaceanvim : with the main branch, I only get hints at the end of the line. With anticonceal, I get nothing, even when I modify the file. See my dotfiles here, my plugin config here and my rust config here. |
@nicos68 You can try the recently-added vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
vim.lsp.inlay_hint.enable(ev.buf, true)
end
end,
) |
Yeah I know I can switch to 0.10 where inlay hints have been added, but I’m using this plugin precisely because I don’t want to bother building neovim myself, I thought the goal of this plugin was to bring inlay hints for pre-0.10 neovim, is it not the case ? |
Yeah, that's exactly my thought when I first saw this feature being developed in nightly versions and couldn't wait to try it out, but then I found that they release a development build every day using github actions! I am actually using the appimage I downloaded a few month ago.
Exactly! It's just that, from my experience, trying nightly is the easiest way to get this fantastic feature! |
Inline virtual text will soon be merged into master: neovim/neovim#23426
This Plugin is of course the perfect candidate for implementing this feature.
The text was updated successfully, but these errors were encountered: