simrat39 / rust-tools.nvim

Tools for better development in rust using neovim's builtin lsp
MIT License
2.17k stars 159 forks source link

fix(inlay_hints): disable strict_indexing for nvim_buf_get_lines #353

Open arindas opened 1 year ago

arindas commented 1 year ago

The last parameter of vim.api.nvim_buf_get_lines() is a boolean called strict_indexing. It causes the following behaviour:

So we set strict_indexing to false.

Now nvim_buf_get_lines() returns an array, which might be empty. So attempting to access the first element (our line) could evaluate to nil.

So we use "" as the fallback line string value.

Fixes #349

pgherveou commented 1 year ago

Thanks for this, it fixed the same issue I had 👍

PSeitz commented 1 year ago

Can confirm, this fixes the issue

tbodt commented 1 year ago

@simrat39

MunifTanjim commented 1 year ago

I've pulled this in https://github.com/MunifTanjim/rust-tools.nvim/tree/patched

arindas commented 1 year ago

I wasn't aware of the strict indexing feature. Thank you. Is there anything actionable from my end?

MunifTanjim commented 1 year ago

You can update this PR with the suggestion. But until @simrat39 gets back, nobody can merge this.

In the meantime, if you want to use rust-tools.nvim with a few fixes from various PRs, you can use my patched branch: https://github.com/MunifTanjim/rust-tools.nvim/commits/patched

ryo33 commented 1 year ago

I also start forking at https://github.com/ryo33/rust-tools.nvim-nightly-. But I don't recommend this to most people because I don't mind my fork being broken by eagerly merging many pull-requests without my own review or compatibility check.