Extra rust tools for writing applications in neovim using the native lsp. This plugin adds extra functionality over rust analyzer. The features mirror VsCode.
neovim 0.5+
(nightly)nvim-lspconfig
rust-analyzer
using vim-plug
Plug 'neovim/nvim-lspconfig'
Plug 'simrat39/rust-tools.nvim'
" Optional dependencies
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Look at the configuration information below to get started.
Please configure nvim-lspconfig for rust
before using this plugin.
This plugin is more of WYSIWYG right now but more configuration options will slowly be added.
local opts = {
-- automatically set inlay hints (type hints)
-- There is an issue due to which the hints are not applied on the first
-- opened file. For now, write to the file to trigger a reapplication of
-- the hints or just run :RustSetInlayHints.
-- default: true
autoSetHints = true,
-- All opts that go into runnables (scroll down a bit) can also go here,
-- these apply to the default RustRunnables command
runnables = {
-- whether to use telescope for selection menu or not
-- default: true
use_telescope = true
-- rest of the opts are forwarded to telescope
},
-- All opts that go into inlay hints (scroll down a bit) can also go here,
-- these apply to the default RustSetInlayHints command
inlay_hints = {
-- wheter to show parameter hints with the inlay hints or not
-- default: true
show_parameter_hints = true,
},
}
require('rust-tools').setup(opts)
RustSetInlayHints
RustRunnables
RustExpandMacro
RustOpenCargo
RustParentModule
RustJoinLines
RustHoverActions
RustMoveItemDown
RustMoveItemUp
" Deprecated
RustRunnablesTelescope
-- Command:
-- RustSetInlayHints
local opts = {
-- whether to show parameter hints with the inlay hints or not
-- default: true
show_parameter_hints = true,
}
require('rust-tools.inlay_hints').set_inlay_hints(opts)
-- Command:
-- RustRunnables
local opts = {
-- whether to use telescope for selection menu or not
-- default: true
use_telescope = true
-- rest of the opts are forwarded to telescope
}
require('rust-tools.runnables').runnables(opts)
-- DEPRECATED !!!
-- The command above automatically detects if telescope is installed and uses that by default
-- Needs telescope.nvim
-- The theme part is optional
--
-- Command:
-- RustRunnablesTelescope
require('rust-tools.runnables').runnables_telescope(require('telescope.themes').get_dropdown({}))
-- Command:
-- RustExpandMacro
require'rust-tools.expand_macro'.expand_macro()
-- Command:
-- RustMoveItemUp
-- RustMoveItemDown
local up = true -- true = move up, false = move down
require'rust-tools.move_item'.move_item(up)
-- this needs the experimental hoverActions capability set
-- while configuring your rust-analyzer:
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.experimental = {}
capabilities.experimental.hoverActions = true
nvim_lsp.rust_analyzer.setup({
capabilities = capabilities,
})
------------------------------------------------------------------
-- Actual call
-- Command:
-- RustHoverActions
require'rust-tools.hover_actions'.hover_actions()
-- Command:
-- RustOpenCargo
require'rust-tools.open_cargo_toml'.open_cargo_toml()
-- Command:
-- RustParentModule
require'rust-tools.parent_module'.parent_module()
-- Command:
-- RustJoinLines
require'rust-tools.join_lines'.join_lines()
This plugin draws inspiration from akinsho/flutter-tools.nvim