Skip to content

alexpasmantier/krust.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

krust.nvim

Neovim Lua

🦀 Nicer Rust diagnostics for Neovim.

krust.nvim screenshot

Why?

To be able to read complete Rust compiler diagnostics in Neovim with proper colors and formatting, similar to how they appear when running cargo in the terminal.

Installation

{
  "alexpasmantier/krust.nvim",
  ft = "rust",
}
use {
  "alexpasmantier/krust.nvim",
  ft = "rust",
}

Configuration

Krust automatically configures rust-analyzer to send colored diagnostics. No keybindings are set by default to avoid conflicts.

-- With lazy.nvim
{
  "alexpasmantier/krust.nvim",
  ft = "rust",
  opts = {
    keymap = "<leader>k",  -- Set a keymap for Rust buffers (default: false)
    float_win = {
      border = "rounded",    -- Border style: "none", "single", "double", "rounded", "solid", "shadow"
      auto_focus = false,    -- Auto-focus float (default: false)
    },
  },
}

Note: If rust-analyzer starts before krust.nvim loads, you may need :LspRestart for colors to appear. To avoid this, load krust.nvim before your LSP config.

Usage

Use the command:

:Krust

Or call from Lua:

require('krust').render()

Behavior

Krust tries to behave like LSP hover documentation windows:

  • First invocation: Opens the floating window (not focused)
  • Second invocation: Enters the floating window so you may scroll
  • q or <Esc>: Closes the window

Credits

This was inspired by rustaceanvim's diagnostic rendering.