Skip to content
프로젝트

소개

CSS Intellisense for HTML

웹 및 앱 개발

이 수치를 측정하는 방법

What you can do

  • 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)

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

☕ Neovim HTML & CSS Support

CSS IntelliSense for HTML

image

✨ Features

  • 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)
  • 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: html and css, plus tsx / javascript if 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 global main.css or 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-]> gd is not an LSP default in Neovim (it's Vim's built-in "go to local declaration"). To use gd, or to set your own hover key, use handlers:
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.

관련 프로젝트 살펴보기

불러오는 중…