A Neovim plugin for the Maud HTML template engine that provides CSS autocomplete, go-to-definition, hover previews, and reference finding directly inside html! {} macros. It operates without a dedicated CSS language server, using a fallback architecture inspired by nvim-html-css.
- ripgrep (rg): This plugin relies strictly on
ripgrepfor instantaneous file scanning. It completely ignores.venvandtargetdirectories natively to ensure Neovim never freezes, even in massive multi-project monorepos.
- Context-Aware Autocomplete: Intelligent
nvim-cmpsource that dynamically indexes all stylesheets in yourassets/directory. It knows exactly what you are typing: suggesting.classesin class attributes or dot notation, and exclusively suggesting--tokenswhen you are inside avar()function. - Transparent LSP Fallback: Built with advanced heuristics to recognize standard Rust code (like
let,use, or field access likecss.route). If the cursor is on Rust code—or if a CSS class/token simply isn't found—the plugin silently and instantly hands the request back torust-analyzer. - Go To Definition (
vim.lsp.buf.definition()): Intercepts Neovim's native LSP definition command. Triggering it on a CSS class or CSS token inside a Rust file instantly jumps to the.cssfile and line where it is defined. - Find References (
vim.lsp.buf.references()): Bidirectional usage tracking for both classes and variables.- From CSS: Trigger references on a class or token in your
.cssfile to populate a list with every Rust file that uses it. - From Rust: Trigger references on a class or token in your
.rsfile to see everywhere else that component/utility is used across your codebase.
- From CSS: Trigger references on a class or token in your
- Hover / Peek (
vim.lsp.buf.hover()): Intercepts Neovim's native LSP hover command. Triggering it on a CSS class or token opens a floating window showing the exact CSS block or token declaration.
Install using lazy.nvim.
{
"bryanmaina/maud-css.nvim",
dependencies = { "hrsh7th/nvim-cmp" },
config = function()
require("maud_css").setup()
end,
}
or for development:
{
dir = "~/path/to/maud-css.nvim",
name = "maud-css",
dependencies = { "hrsh7th/nvim-cmp" },
config = function()
require("maud_css").setup()
end,
}After calling setup(), you must tell nvim-cmp to actively use the newly registered source. Add "maud_css" to your sources list in your existing cmp configuration:
local cmp = require("cmp")
cmp.setup({
-- ... your other cmp settings ...
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "maud_css" }, -- Add this line!
{ name = "luasnip" },
}, {
{ name = "buffer" },
}),
})
There are no custom keymaps to memorize. The plugin hooks directly into Neovim's core LSP API, respecting whatever keybinds you already use for your language servers (e.g., gd for definition, gr for references, K for hover).
Inside a .rs file, within an html! {} macro:
- Type
div.orclass="to trigger thenvim-cmpCSS class autocomplete menu. - Type
style="color: var(to trigger the CSS token autocomplete menu. - Place your cursor over a class (like
.btn-primary) or token (like--color-bg) and trigger your Hover command to see the CSS block in a floating window. - Place your cursor over a class or token and trigger your Definition command to jump to the CSS file where it is defined.
- Place your cursor over a class or token and trigger your References command to open a list showing every Rust and CSS file utilizing it.
- Place your cursor over a standard Rust variable (like
css.route) and trigger any LSP command—rust-analyzerhandles it perfectly!
Inside a .css file:
- Place your cursor over a CSS class or token and trigger your References command to open a list showing every file where you applied it.
- Jezda1337/nvim-html-css for the brilliant native LSP fallback and wrapper architecture.