docs/neovim-configuration.md
This document describes all available configuration options for the RustOwl Neovim plugin.
The minimal configuration for RustOwl using lazy.nvim:
{
'cordx56/rustowl',
version = '*', -- Latest stable version
build = 'cargo install rustowl',
lazy = false, -- This plugin is already lazy
opts = {},
}
All configuration options are optional and have sensible defaults:
auto_attach (boolean)trueauto_enable (boolean)falsefalse, you need to manually enable highlighting using :Rustowl enable or require('rustowl').enable().idle_time (number)500highlight_style (table)'undercurl' or 'underline'.colors (table)'#ff0000').lifetime: Color for variable lifetime highlights (default: '#00cc00' - green)imm_borrow: Color for immutable borrow highlights (default: '#0000cc' - blue)mut_borrow: Color for mutable borrow highlights (default: '#cc00cc' - purple)move: Color for value move highlights (default: '#cccc00' - yellow)call: Color for function call highlights (default: '#cccc00' - yellow)outlive: Color for lifetime error highlights (default: '#cc0000' - red)client (table)vim.lsp.start. This follows the same structure as Neovim's LSP client configuration.Default highlight style is straight underline except for maybe live and errors.
The default color scheme uses the following colors that correspond to the visual legend:
#00cc00): Variable's lifetime#0000cc): Immutable borrowing#cc00cc): Mutable borrowing#cccc00): Value moved / function call#cc0000): Lifetime errorsTo customize colors, specify them in the colors table:
opts = {
colors = {
lifetime = '#32cd32', -- Lime green
imm_borrow = '#4169e1', -- Royal blue
mut_borrow = '#ff69b4', -- Hot pink
move = '#ffa500', -- Orange
call = '#ffd700', -- Gold
outlive = '#dc143c', -- Crimson
},
}
Colors must be specified as hex color strings:
'#ff0000', '#00ff00', '#0000ff''red', 'rgb(255,0,0)', '#f00'You can customize only specific colors while keeping the defaults for others:
opts = {
colors = {
lifetime = '#90ee90', -- Light green for better visibility
outlive = '#ff4500', -- Orange red for errors
-- Other colors will use defaults
},
}
{
'cordx56/rustowl',
version = '*',
build = 'cargo install rustowl',
lazy = false,
opts = {},
}
{
'cordx56/rustowl',
version = '*',
build = 'cargo install rustowl',
lazy = false,
opts = {
auto_enable = true,
colors = {
lifetime = '#90ee90', -- Light green
imm_borrow = '#87ceeb', -- Sky blue
mut_borrow = '#dda0dd', -- Plum
move = '#f0e68c', -- Khaki
call = '#ffd700', -- Gold
outlive = '#ff6347', -- Tomato
},
},
}
{
'cordx56/rustowl',
version = '*',
build = 'cargo install rustowl',
lazy = false,
opts = {
auto_enable = false,
idle_time = 300,
highlight_style = {
definitely_live = 'underline',
maybe_initialized = 'undercurl',
},
colors = {
outlive = '#ff0000', -- Bright red for errors
},
client = {
on_attach = function(_, buffer)
vim.keymap.set('n', '<leader>ro', function()
require('rustowl').toggle(buffer)
end, { buffer = buffer, desc = 'Toggle RustOwl' })
vim.keymap.set('n', '<leader>re', function()
require('rustowl').enable(buffer)
end, { buffer = buffer, desc = 'Enable RustOwl' })
vim.keymap.set('n', '<leader>rd', function()
require('rustowl').disable(buffer)
end, { buffer = buffer, desc = 'Disable RustOwl' })
end
},
},
}
{
'cordx56/rustowl',
version = '*',
build = 'cargo install rustowl',
lazy = false,
opts = {
colors = {
lifetime = '#50fa7b', -- Dracula green
imm_borrow = '#8be9fd', -- Dracula cyan
mut_borrow = '#ff79c6', -- Dracula pink
move = '#f1fa8c', -- Dracula yellow
call = '#ffb86c', -- Dracula orange
outlive = '#ff5555', -- Dracula red
},
},
}
If you're using init.vim instead of init.lua, you can configure RustOwl using Vim script:
lua << EOF
require('lazy').setup({
{
'cordx56/rustowl',
version = '*',
build = 'cargo install rustowl',
lazy = false,
opts = {
colors = {
lifetime = '#00ff00',
imm_borrow = '#0080ff',
mut_borrow = '#ff00ff',
move = '#ffff00',
call = '#ffa500',
outlive = '#ff0000',
},
},
},
})
EOF
When opening a Rust file, the following commands become available:
:Rustowl start_client - Start the RustOwl LSP client:Rustowl stop_client - Stop the RustOwl LSP client:Rustowl restart_client - Restart the RustOwl LSP client:Rustowl enable - Enable RustOwl highlighting:Rustowl disable - Disable RustOwl highlighting:Rustowl toggle - Toggle RustOwl highlightingYou can also use the Lua API:
require('rustowl').enable() -- Enable highlighting
require('rustowl').disable() -- Disable highlighting
require('rustowl').toggle() -- Toggle highlighting
require('rustowl').is_enabled() -- Check if enabled