Setting up code lens for Rust.
CodeLens is a very useful feature for developers to easily identify the actions or references in a particular file. This article explores using the Neovim LSP code lens and hover action features to run or debug Rust applications.
I use Neovim 0.6 and configure rust-analyzer as the language server. Since I have already gone through the configuration in previous articles, the details are skipped here.
You can check out the following articles for the instructions.
Neovim LSP Enhanced
Additional features to enhance your LSP experience in Neovim.
Code lens is not supported by all language servers. Normally we should check if the capability is supported before setting any custom configuration.
E.g. I checked if the code lens feature is supported before setting any key mappings.
- Now open a Rust project and type
- You should see the options to Run or Debug the methods and tests.
- You are prompted to choose the code lens action.