概要
CSS Intellisense for HTML
Web・アプリ開発できること
- Completion for class and id attributes, with the CSS rule shown as documentation
- Picks up stylesheets linked or written inline in the current file, local or remote
- Global stylesheets and CSS frameworks via style_sheets
- Hover, go to definition, and peek (open the CSS rule in a floating window)
計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- -1
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナル☕ Neovim HTML & CSS Support
CSS IntelliSense for HTML
✨ Features
- Completion for
classandidattributes, with the CSS rule shown as documentation - Picks up stylesheets linked or written inline in the current file, local or remote
- Global stylesheets and CSS frameworks via
style_sheets - Hover, go to definition, and peek (open the CSS rule in a floating window)
- Per-project config through
.nvim.lua
Works with any completion engine that reads LSP results (nvim-cmp with cmp-nvim-lsp, blink.cmp's lsp source, built-in completion). The plugin runs a small in-process LSP called html-css-lsp.
⚡️ Requirements
- Neovim 0.10+
curl(for remote stylesheets)- Treesitter parsers:
htmlandcss, plustsx/javascriptif you use JSX
📦 Installation
vim.pack
vim.pack.add({ "https://github.com/Jezda1337/nvim-html-css" })
require("html-css").setup({
enable_on = { "html" }, -- file extensions
})
lazy.nvim
{
"Jezda1337/nvim-html-css",
dependencies = { "nvim-treesitter/nvim-treesitter" },
main = "html-css",
opts = {
enable_on = { "html" }, -- file extensions
},
}
Don't lazy-load it with ft or event: the file that triggers loading won't get completion until you reopen it.
enable_on takes file extensions, not filetypes. For example: "html", "vue", "svelte", "astro", "tsx", "jsx", "php" (includes Blade), "erb", "templ", "tmpl", "gohtml". Django templates are usually .html.
🎨 Where styles come from
- Automatically: stylesheets linked or written inline in the file you're editing. These only apply to that file.
style_sheets: anything else, such as a globalmain.cssor a framework your bundler includes. These apply to every enabled file.
style_sheets = {
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",
"./src/styles/main.css", -- relative to the folder you started nvim in
}
@imports inside local stylesheets are followed.
🔧 Per-project config
Put a .nvim.lua in the folder you start nvim from:
vim.g.html_css = {
style_sheets = { "./src/styles/main.css" },
}
The first time, Neovim asks whether to trust the file (:trust to allow it). Values here override your global setup.
⌨️ Hover, definition and peek
The plugin doesn't map any keys itself, but some things work out of the box through Neovim's LSP defaults (0.10+):
- Hover:
K - Go to definition:
<C-]>gdis not an LSP default in Neovim (it's Vim's built-in "go to local declaration"). To usegd, or to set your own hover key, usehandlers:
handlers = {
hover = { bind = "K" },
definition = { bind = "gd" },
}
These keymaps only apply in enabled files. If the word under the cursor isn't a known class or id, they fall back to your other LSP servers' hover and definition.
Peek opens the CSS rule in an editable floating window. It has no default key, so map the :HtmlCssPeek command yourself:
vim.keymap.set("n", "<leader>cp", "<cmd>HtmlCssPeek<CR>", { desc = "Peek CSS" })
Close it with q or <Esc>. It won't close while it has unsaved changes.
⚙️ All options
require("html-css").setup({
enable_on = { "html" }, -- file extensions
style_sheets = {}, -- extra stylesheets (URLs or paths)
handlers = {}, -- e.g. { hover = { bind = "K" }, definition = { bind = "gd" } }
-- hover also takes: wrap, border, position ("cursor" | "editor")
peek = {
enabled = true, -- creates :HtmlCssPeek
border = "rounded",
position = "center", -- "center" | "cursor"
width = 0.5, -- fraction of the editor
height = 0.5,
focus = true, -- move the cursor into the float
style = "minimal",
},
notify = false, -- log fetches (debugging)
})
Run :checkhealth html-css if something doesn't work.
関連プロジェクトを探す
読み込み中…