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
}
What is "single" mode?
For people who don't like large bright chunks of their buffer un-colorschemed, single
column mode is a compromise until anti-conceal.
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()
- Disable nvim-colorizer.nvim in places its now redundent
-- Colorize
use { 'norcalli/nvim-colorizer.lua', config = function ()
require('colorizer').setup({
'*';
-- An example
'!css';
'!html';
'!tsx';
'!dart';
})
end }
- You should probably keep your existing colorizer plugin, this plugin does not replace it in many cases
- I am only using "color" and not "colour" because thats what the lsp specs say, not because i believe in such heresy to the queen
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"
- kabouzeid and his great dotfiles. Inspired by his reddit post, chunks of this plugin are from his dotfiles. ❤️
- https://github.com/norcalli/nvim-colorizer.lua