Transparent privilege elevation for Neovim without virtual URI hacks.
Unlike suda.vim, suda.nvim preserves the original file path instead of prefixing suda://, ensuring that LSP servers, Treesitter, formatters, and diagnostics continue to function normally.

/etc/hosts).:w and :wq: Intercepts writes on protected files automatically without requiring special commands.sudo credentials, avoiding repeated password prompts.sudo tee, preserving file modes, ownership, and symlinks.sudo (or doas){
"LongYinStudio/suda.nvim",
event = { "BufReadPre", "BufNewFile" },
cmd = { "SudaWrite", "SudaRead", "SudaEdit", "SudoWrite", "SudoRead", "SudoEdit" },
opts = {},
}
Default options:
require("suda").setup({
-- Command used for privilege elevation
cmd = "sudo",
-- Automatically elevate on :w for read-only / protected files
auto_save = true,
-- Automatically elevate when opening unreadable files (e.g. /etc/shadow)
auto_read = true,
-- Password prompt string
prompt = "[sudo] password: ",
-- Suppress write/read notifications
silent = false,
})
:SudaWrite [file] (alias :SudoWrite): Write buffer (or range) with sudo.:SudaRead [file] (alias :SudoRead): Read file into buffer with sudo.:SudaEdit <file> (alias :SudoEdit): Open and edit file with sudo.Supports range writes:
:'<,'>SudaWrite
MIT