A colorizer plugin for tailwindcss and any lsp servers that support textDocument/documentColor
!
For example tailwindcss, cssls, and dart support documentColor!
use { 'mrshmllow/document-color.nvim', config = function()
require("document-color").setup {
-- Default options
mode = "background", -- "background" | "foreground" | "single"
}
end
}
For a typical lspconfig setup...
local on_attach = function(client)
...
if client.server_capabilities.colorProvider then
-- Attach document colour support
require("document-color").buf_attach(bufnr)
end
...
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
-- You are now capable!
capabilities.textDocument.colorProvider = {
dynamicRegistration = true
}
-- Lsp servers that support documentColor
require("lspconfig").tailwindcss.setup({
on_attach = on_attach,
capabilities = capabilities
})
-- Toggle in current buffer
require("document-color").buf_toggle()
-- Attach to the current buffer (Turn on)
require("document-color").buf_attach()
-- Detach from current buffer (Turn off)
require("document-color").buf_detach()
-- Colorize
use { 'norcalli/nvim-colorizer.lua', config = function ()
require('colorizer').setup({
'*';
-- An example
'!css';
'!html';
'!tsx';
'!dart';
})
end }
When (or if) anti-conceal ever gets merged, it may be possible to have something like the tailwindcss vscode extension has
for now, we only have mode = "single"