Code Monkey home page Code Monkey logo

nvim-colorizer.lua's Introduction

NvChad

Neovim Minimum Version GitHub Issues Discord Matrix Telegram

Showcase

What is it?

  • NvChad is a neovim config written in lua aiming to provide a base configuration with very beautiful UI and blazing fast startuptime (around 0.02 secs ~ 0.07 secs). We tweak UI plugins such as telescope, nvim-tree etc well to provide an aesthetic UI experience.

  • Lazy loading is done 93% of the time meaning that plugins will not be loaded by default, they will be loaded only when required also at specific commands, events etc. This lowers the startuptime and it was like 0.07~ secs tested on an old pentium machine 1.4ghz + 4gb ram & HDD.

  • NvChad is supposed to be used with its starter config, so nvchad main repo ( this repo ) can be imported as a plugin via lazy's import feature and then you can easily use this repo's modules like autocmds etc.

Theme Showcase

Images (Click to expand!)

4 themes radium 1 radium 2 radium 3

(Note: these are just 4-5 themes, NvChad has around 56 themes)

UI related plugins used

Images (Click to expand!)

Nvim-tree.lua

Fast file tree:

Telescope-nvim

A fuzzy file finder, picker, sorter, previewer and much more:

Our own statusline written from scratch

NvChad UI

Tabufline (our own pertab bufferline)

  • Here's a video that showcases it.

NvCheatsheet ( our UI Plugin )

Plugins list

History

  • I (@siduck i.e creator of NvChad) in my initial days of learning to program wanted a lightweight IDE for writing code, I had a very low end system which was like 1.4ghz pentium + 4gb ram & HDD. I was into web dev stuff so many suggested me to use vscode but that thing was very heavy on my system, It took more ram than my browser! ( minimal ungoogled chromium ) so I never tried it again, sublime text was nice but the fear of using proprietary software XD for a linux user bugged me a lot. Then I tried doom-emacs which looked pretty but it was slow and I was lost within its docs, I tried lunarvim but too lazy to read the docs. Doom-emacs and lunarvim inspired me to make a config which is the prettiest + very fast and simple.

  • I'm decent at ricing i.e customizing system and making it look pretty so I posted my neovim rice on neovim subreddit, my neovim-dotfiles github repo blew up and then I had to come up with a name, I was amazed by the chad meme lol so I put NvChad as the name, the chad word in here doesnt literally mean the chad guy but in the sense such as chad linux vs windows i.e meaning superior, best etc. NvChad was made for my personal use but it gained some popularity which inspired me to make a public config i.e config usable by many and less hassle to update as everyone's going to use the same base config (NvChad) with their custom modifications (which are gitignored so that wont mess up), without the custom config stuff users would have to keep a track of every commit and copy paste git diffs to manually update nvchad.

💝 Support

If you like NvChad and would like to support & appreciate it via donation then I'll gladly accept it.

kofi paypal buymeacoffee patreon

Credits

  • Elianiva helped me with NeoVim Lua related issues many times, helped me in my initial neovim journey!
  • @lorvethe for making the beautiful NvChad logo.

nvim-colorizer.lua's People

Contributors

akianonymus avatar akinsho avatar br1anchen avatar chao-0 avatar darwinsenior avatar filipekiss avatar jcrd avatar kwshi avatar lasse16 avatar mathisto avatar mushfiq814 avatar rolv-apneseth avatar siduck avatar sindrets avatar sitiom avatar soupersauce avatar stelcodes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nvim-colorizer.lua's Issues

[Feature] Display Tailwind Colors

Describe the bug
When using tailwind, the names of the colors aren't displayed.

To Reproduce
Here's my colorizer.lua file:

local colorizer = require_clean("colorizer")
colorizer.setup({
  RGB = true, -- #RGB hex codes
  RRGGBB = true, -- #RRGGBB hex codes
  names = true, -- "Name" codes like Blue or blue
  RRGGBBAA = true, -- #RRGGBBAA hex codes
  rgb_fn = true, -- CSS rgb() and rgba() functions
  hsl_fn = true, -- CSS hsl() and hsla() functions
  css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
  css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
  -- Available modes: foreground, background, virtualtext
  mode = "background", -- Set the display mode.
})

Expected behavior
I expect the color names in CSS to be displayed, like this reddit post.

Operating System:
EndeavourOS 5.19.4

Neovim Version:
NVIM v0.8.0-dev-973-g253f0ffd8d

Colorizer Version:
84aa4ad

Bug: default_user_settings not applied for 'names'

Describe the bug
When setting names = false in default_user_settings, color names are still highlighted. It works correctly if specified for the particular filetype, just not the defaults. I'll try to dig into more this evening.

To Reproduce

local colorizer = require('colorizer')

-- red blue green
colorizer.setup({
  default_user_settings = {
    names = false,
  },
  filetypes = {
    'css',
    'html',
    'typescriptreact',
    'lua',
  },
})

Expected behavior
Color names would not be highlighted.

Screenshots
image
image

Operating System:
Arch Linux

Neovim Version:
NVIM v0.8.2

Colorizer Version:
760e27df4dd966607e8fb7fd8b6b93e3c7d2e193

Bug:

Describe the bug
A clear and concise description of what the bug is.

Errors on PackerCompile.

To Reproduce
Your configuration and/or a small reproducible test, and/or the steps required to reproduce.

Run :PackerCompile

Expected behavior
A clear and concise description of what you expected to happen.

No error

Screenshots
If applicable, add screenshots to help explain your problem.

image

Operating System:
e.g. Ubuntu 16.04

macOS v12.3.1

Neovim Version:
e.g. 0.4.2

0.7.2

Colorizer Version:
Paste the output of

find ~/.config/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;

Empty output, latest master (not an issue before)

Additional context
Add any other context about the problem here.

Bug: Nothing but hex colors works

Describe the bug
Only hex codes in the form of #abcdef, #abc and #abcdef00 are working.

To Reproduce
I replaced my whole neovim configuration for this:

local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'

if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

local ok, lazy = pcall(require, 'lazy')
if not ok then
  vim.notify('Could not require lazy!', vim.log.levels.ERROR)
  vim.notify('Exiting from plugins/init.lua', vim.log.levels.ERROR)
  return
end

lazy.setup({
  {
    'NvChad/nvim-colorizer.lua',
    cmd = {
      'ColorizerToggle',
      'ColorizerAttachToBuffer',
      'ColorizerDetachFromBuffer',
      'ColorizerReloadAllBuffers',
    },
    config = function()
      vim.opt.termguicolors = true
      require('colorizer').setup({
        filetypes = { 'conf' },
        user_default_options = {
          -- foreground, background,  virtualtext
          mode = 'background',

          names = true,
          RGB = true, -- #RGB hex codes
          RRGGBB = true, -- #RRGGBB hex codes
          RRGGBBAA = true, -- #RRGGBBAA hex codes
          AARRGGBB = true, -- 0xAARRGGBB hex codes
          rgb_fn = true, -- CSS rgb() and rgba() functions
          hsl_fn = true, -- CSS hsl() and hsla() functions
          css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
          css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
          -- Available methods are false / true / "normal" / "lsp" / "both"
          -- True is same as normal
          tailwind = true, -- Enable tailwind colors
          -- parsers can contain values used in |user_default_options|
          sass = { enable = true, parsers = { 'css' } }, -- Enable sass colors
          virtualtext = '■',
        },
      })
    end,
  },
})

Expected behavior
When I open a file with things like rgb(123456), I expected it to be colored.

Screenshots
If applicable, add screenshots to help explain your problem.

Operating System:
Fedora 39

Neovim Version:
0.9.5

Colorizer Version:
85855b3

Here is a screenshot of a file I'm editing:

image

Bug: Does not work with autocmd

plugin installed, and using this to automatically activate it in css files.
with this config, the plugin does not work at all. :ColorizerAttachToBuffer also has no effect.

vim.opt.termguicolors = true
require("colorizer").setup {}

vim.api.nvim_create_autocmd("FileType", {
	pattern = {"css"},
	callback = function ()
		require("colorizer").attach_to_buffer(0, {
			mode = "background",
			css = true,
		})
	end
})

leaving out the autocmd:

vim.opt.termguicolors = true
require("colorizer").setup {}

the plugin works, but of course this requires me to manually activate it in every css file with attach_to_buffer

I dunno, maybe I am missing something, but I went through the docs twice and cannot find what I might be missing here.

Operating System:

macOS 12.5.1 (M1)
neovim 0.8.0 (homebrew install)
colorizer: 36c610a9717cc9ec426a07c8e6bf3b3abcb139d6

Bug:

Describe the bug

Sometimes the color spills over or is displayed in the wrong place when the document is edited.

To Reproduce
Does happen from time to time when editing documents

Expected behavior
Display the color in the right place

Screenshots
screenshot-2022-08-25:10:31

Operating System:
Arch Linux

Neovim Version:
NVIM v0.7.2

Colorizer Version:
Paste the output of

find ~/.config/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;
3e7c1e0

Additional context
Add any other context about the problem here.

Bug: ChartReuse instead of Chartreuse

Describe the bug
This plugin highlights ChartReuse instead of Chartreuse.

To Reproduce
Type ChartReuse and Chartreuse and see that only one gets colorized.

Expected behavior
ChartReuse is not a color name, and should not be colorized. Chartreuse is, and should be.

Screenshots
image

Operating System:
openSUSE Tumbleweed v20221003

Neovim Version:
NVIM v0.7.2

Colorizer Version:
e851cdc4fbb0b77da794f5f348751b2036860356

Additional context
May also affect CornflowerBlue but that seems to be implemented as CornFlowerBlue in certain documents defining web / X11 colors.

Bug: Applying css features via filetype table doesn't override defaults

Application Versions:

OS: WSL2 Ubuntu 22.04
Neovim: NVIM v0.10.0-dev

Colorizer Version::

Note: This didn't work with my setup.
find ~/.config/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;

The provided command outputted: b1f99fc618c2f4f262dde607785c3eac9fc61933
This is the actual installed version: dde3084

Describe the bug

This might be tangentially related to #48.

For my config I don't like names or RGB to be globally enabled, but for css filetypes these can be helpful.
So I figured the css = true option would be a concise way to allow those features to be limited to only css filetypes.

This does not work, requiring the user to explicitly override the disabled options defined in user_default_options.

setup = {
  user_default_options = {
    RGB = false, -- annoying in some contexts
    names = false, -- annoying in some contexts
    mode = "background",
  },
  filetypes = {
    "*", -- Use default options for all other filetypes

    -- This should be sufficient to ensure all css features are enabled
    -- css = { css = true },

    -- Unfortunately, these settings need to be explicitly enabled to override user_default_options
    css = { css = true, names = true, RGB = true },
  },
}

config makes no effect when disable in certain filetypes

What I want is to disable it in golang files, and I config as below:

require 'colorizer'.setup {
    filetypes = {
        '*', -- Highlight all files, but customize some others.
        '!go', -- Exclude golang from highlighting.
        '!golang',
        -- Exclusion Only makes sense if '*' is specified!
    },
}

But it makes no effect on golang files, it still colored in these files. Any help?

Bug: setting tailwind to 'lsp' throws an error when starting nvim

Describe the bug
Setting tailwind to 'lsp' throws an error when starting nvim.

To Reproduce
It is happening using the following config:

local colorizer = require('colorizer')

colorizer.setup(
  {
    user_default_options = {
      rgb_fn = true,
      hsl_fn = true,
      tailwind = 'lsp',
      sass = { enable = true },
    },
  }
)

Expected behavior
No errors and the tailwind classes to be highlighted using the tailwind LSP server.

Screenshots

Error executing lua callback: ...cker/start/nvim-col
orizer.lua/lua/colorizer/tailwind.lua:83: attempt to index a nil value
stack traceback:
        ...cker/start/nvim-colorizer.lua/lua/colorizer/tailwind.lua:83: in function 'tailwind_setup_lsp'
        ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:151: in function 'highlight'
        ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:258: in function 'rehighlight_buffer'
        ...e/pack/packer/start/nvim-colorizer.lua/lua/colorizer.lua:263: in function 'attach_to_buffer'
        ...e/pack/packer/start/nvim-colorizer.lua/lua/colorizer.lua:411: in function 'COLORIZER_SETUP_HOOK'
        ...e/pack/packer/start/nvim-colorizer.lua/lua/colorizer.lua:452: in function <...e/pack/packer/start/nvim-colorizer.lua/l
ua/colorizer.lua:451>

Operating System:
MacOS M1 12.4

Neovim Version:
NVIM v0.8.0-dev-1059-g2d6735d8c

Colorizer Version:
44e7a24

Additional context
These lines seem to cause the problem, cleanup is called, which sets the TAILWIND[buf] to nil, which is then being accessed right after.


tailwind.cleanup(buf)

TAILWIND[buf].AU_ID[1] = api.nvim_create_autocmd("LspAttach", {

sass mode throwing error on virtual text mode

Describe the bug

Error executing vim.schedule lua callback: ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:112: col value outside range                    
stack traceback:                                                                                                                                       
        [C]: in function 'buf_set_virtual_text'                                                                                                        
        ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:112: in function 'add_highlight'                                                   
        ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:149: in function 'highlight'                                                       
        ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:259: in function 'rehighlight'                                                     
        ...k/packer/start/nvim-colorizer.lua/lua/colorizer/sass.lua:208: in function 'callback'                                                        
        .../packer/start/nvim-colorizer.lua/lua/colorizer/utils.lua:153: in function 'on_change'                                                       
        .../packer/start/nvim-colorizer.lua/lua/colorizer/utils.lua:167: in function ''                                                                
        vim/_editor.lua: in function <vim/_editor.lua:0> j

To Reproduce

I can trigger the error if I have two scss files, one referencing variables in the other (see screenshot).

  1. Open both files
  2. rename variable $foo: #fefefe; to $oo: #fefefe; and save
  3. go to the other file and :e to reload it
  4. go back to the edited file and change $oo back to $foo and save to trigger error

Expected behavior

no error :)

Screenshots
Screenshot 2023-01-03 at 8 12 41 PM

Operating System:

MacOS Ventura 13.1

Neovim Version:

$ nvim --version
NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.8.2/share/nvim"

Run :checkhealth for more info

Colorizer Version:

$ find ~/.local/share/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;
cddef405becd72deef72219db005a8bbf0603919

Additional context

require 'colorizer'.setup({            
  filetypes = { "css", "scss" },       
  user_default_options = {             
    RGB = true, -- #RGB hex codes      
    RRGGBB = true, -- #RRGGBB hex codes
    css = false,                       
    rgb_fn = true,                     
    hsl_fn = true,                     
    mode = "virtualtext",              
    names = false,                     
    sass = {                           
      enable = true,                   
      parsers = {                      
        RGB = true,                    
        RRGGBB = true,                 
        css = false,                   
        rgb_fn = true,                 
        hsl_fn = true,                 
        mode = "virtualtext",          
        names = false,                 
      },                               
    },                                 
    virtualtext = ""                  
  }                                    
})

Bug: Plugin does not attach on initial buffer if lazy loaded

Describe the bug
Plugin does not attach on initial buffer if lazy loaded with Lazy.

To Reproduce

Using Lazy plugin manager, configure your nvim-colorizer like so:

  { 'NvChad/nvim-colorizer.lua',
    config = function() require'colorizer'.setup{} end,
    event = 'VeryLazy',
  },

Then, create a sample file:

echo "#111" > foo

Open it with Neovim:

nvim cos

You won't see #111 colorized.

Expected behavior

#111 is colorized.

Colorizer Version:
dde3084

Additional context
I've added the following to my config to address this issue, but I think it'd be worthwhile to just do it upstream in setup.

	{ 'NvChad/nvim-colorizer.lua',
		config = function()
			local c = require'colorizer'
			c.setup{}

			-- nvim-colorizer doesn't work on the initial buffer if we lazy load, so force it to attach
			-- on load.
			local bufnr = vim.api.nvim_get_current_buf()
			if bufnr and not c.is_buffer_attached(bufnr) then
				c.attach_to_buffer(bufnr)
			end
		end,
		event = 'VeryLazy',},

Bug: tailwind colors do not include new 950 shades

Describe the bug
The new 950 shades included in tailwind v3.3 are not highlighted.

To Reproduce
Use a classname like text-red-950.

Expected behavior
The text is colorized.

Screenshots
image

Operating System:
MacOS

Neovim Version:
NVIM v0.8.3
Build type: Release
LuaJIT 2.1.0-beta3

Colorizer Version:
dde3084

Additional context
I installed this plugin in tandem with roobert/tailwindcss-colorizer-cmp.nvim in order to see colors of tailwind classes in my code. When going through the options, I noticed that it had the same issue because the tailwind colors were hardcoded. Luckily js-everts created cmp-tailwind-colors, which is the same but gets the colors from tailwind directly instead of hardcoding a list of values. I can see in the tailwind.lua file of this plugin that you might be doing something similar for user defined colors, but I'm not sure. If possible, not using hardcoded colors seems like a good thing to get working. If not, just updating the colors with the new shade in tailwind v3.3 would be fine :-)

FR: Support for hexadecimal strings

Many applications require use of hexadecimal representation for colors (for example 0x0000aa).
Currently nvim-colorizer does not highlight these. This feature request is about adding support for hexadecimal color representation and highlighting them as well.
Example:
image

[Feature Request]: add inlay hints option

Hi, recently neovim added native support for lsp inlay hints. I was wondering if it would be possible to add an similar option for displaying colors like in this image:

image

Thanks.

`css = true` behaviour is confusing

If you configure with the following:

names = false,
css = true

Then names gets set to true. This took me a long time to figure out, as I wanted to disable just names and nothing else. I figured that none of my options were being applied.

Having one property overwrite another is unintuitive behaviour.

This has caused confusion before

Would it be better to have individual properties like names override group properties like css?

Bug: latest update - gives 'attempt to index lcoal 'conf' (nil ) error

Describe the bug
Latest nvim-colorizer.lua update (03.09.2023) introduced error message at neovim startup:
obraz

To Reproduce
config:

use {
   -- "norcalli/nvim-colorizer.lua",  -- original repo - not maintained
   "NvChad/nvim-colorizer.lua",
   config = function()
     require("colorizer").setup()
   end,
 } --color highlighter

I'm on quite recent daily build on NVIM.

nvim-colorizer.lua error

Describe the bug
Nvim colorizer error when opening special file

To Reproduce
Steps to reproduce the behavior:

  1. echo "#---" > test.ini
  2. nvim test.ini
  3. See error

Expected behavior
No error when opening test.ini.

Screenshots
image

Desktop (please complete the following information):

  • docker(alpine:edge)
  • sh
  • 0.7.2

Additional context
Add any other context about the problem here.

Bug: Tailwind does not work when `names` option is false

Describe the bug
I wanted to set up this plugin to give colorizing support to tailwind classes but, I don't want to colorize every word matching with a color name, but tailwind option only seems to work when names option is true
image

To Reproduce
Set names option as false and then tailwind colorizing won't work anymore

Expected behavior
With names option set as false it should still work for tailwind classes

Screenshots

  • tailwind option set as true and names option to default
    image
  • tailwind option set as true and names options also set as true
    image

Operating System:
Ubuntu 22.10 x86_64

Neovim Version:
v0.9.0

Colorizer Version:
Command below does not print anything
find ~/.config/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;
here's the installation data (from lazy)
image

Additional context
N/A

Bug: breaks when buffer temporary lose "buflisted" option

Describe the bug
It breaks when i hide buffer from buffer list. It doesn't restore highlihting even after option restoration.

Works on minimal.lua config from Lazy.

To Reproduce
Open file with color highlights and type:

:set nobuflisted | set buflisted

Expected behavior
It will highlight (after option restoration at least)

Screenshots
before:
image

after:
image

Operating System:
Archlinux

Neovim Version:
v0.8.3

Colorizer Version:
dde3084 [master]

Bug: ram usage spikes when scrolling

Describe the bug
Neovim ram usage spikes when scrolling with Colorizer plugin loaded. This behavior disappears when Colorizer is not loaded.

To Reproduce

  1. Using neovim with nvim-colorizer.lua loaded to open a file
  2. Open another terminal running htop to monitor the ram usage of this neovim process. At this point it should be 20MB or so.
  3. On neovim, use your mouse to scroll
  4. You can see on htop that the ram goes up to about 200MB. If the file is long enough and you keep scrolling, it would go up to a few GBs easily and fast. Until it's got terminated by 00ram killer.

Expected behavior
Not taking so much ram.

Operating System:
Arch Linux x86_64

Neovim Version:
NVIM v0.8.2

Colorizer Version:
760e27d 3 months ago

Config Content

require("colorizer").attach_to_buffer(0, { mode = "background", css = true})
require("colorizer").setup {
    filetypes = { "*" },
    user_default_options = {
        RGB = true, -- #RGB hex codes
        RRGGBB = true, -- #RRGGBB hex codes
        names = false, -- "Name" codes like Blue or blue
        RRGGBBAA = true, -- #RRGGBBAA hex codes
        AARRGGBB = true, -- 0xAARRGGBB hex codes
        rgb_fn = true, -- CSS rgb() and rgba() functions
        hsl_fn = true, -- CSS hsl() and hsla() functions
        css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
        css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
        -- Available modes for `mode`: foreground, background,  virtualtext
        mode = "background", -- Set the display mode.
        -- Available methods are false / true / "normal" / "lsp" / "both"
        -- True is same as normal
        tailwind = true, -- Enable tailwind colors
        virtualtext = "■",
    },
    -- all the sub-options of filetypes apply to buftypes
    buftypes = {},
}

Question: Is it possible to preview color in float window?

Thanks for the great tool! 💯 for this fork.

I mean this
with preview2

I know that this fork support tailwind colorization, i.e. colorize text-teal-200, but previewing colors from float window would be super useful as seen in the above screenshot. It allows you to see colors before selecting one.

For example, the prose-* property for typography includes set of color values (screenshot above).

The original repo from @norcalli supports color previewing in float window
with preview

The float windows from sample screenshots come from nvim-cmp plugin.
I'm quite new to Neovim. I'm not sure how to identify buftype or filetype of the float window. The filetype for the float window buffer is cmp_docs according to this doc https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt.

Here's my setup script

local ok, colorizer = pcall(require, 'colorizer')
if not ok then
  return
end

colorizer.setup({
  filetypes = {
    '*';
    '!vim';
  },
  user_default_options = {
    rgb_fn = true,
    tailwind = 'both',
  },
  buftypes = {
    '*', -- seems like this doesn't work with the float window, but works with the other `buftype`s. 
         -- Not sure if the window has a `buftype` at all
  },
})

Debounce coloring

When going through (<c-n>/<c-p>) Tailwind completion items that have color, colorizer tries to show each color. If I go through them quickly, I see a color every once in a while, but once I finally stop, it will rapidly show each color that was passed by. Perhaps debouncing would be a good solution for this.

Bug: Telescope conflict

Describe the bug
This commit is messing with Telescope's results window while sorting.

To Reproduce
Try searching with Telescope's find_files, grep_string, etc. This is more evident when there are many items on the results list and you type an exact match.

Expected behavior
Telescope's results window working properly

Operating System:
Archlinux

Neovim Version:
0.8.3

Colorizer Version:
master

Bug: User defined Tailwind colors are not shown

Describe the bug
If the user defines a color it is not shown as the background.

To Reproduce
Define a user variable like 'gray-light' and use it e.g. 'from-gray-light'

Expected behavior
The color used should be the background color of the text.

Screenshots
image

Operating System:
Arch

Neovim Version:
NVIM v0.8.3

Bug: Only activates on current buffer

Describe the bug
When I load up a previous session with multiple tabs/windows, only the first active buffer is colorised.

To Reproduce
I use projections to load my sessions, however I imagine the same issue would occur with any sort of session manager.

Expected behavior
All buffers should be colorised

Screenshots
(See the split on the left is not colorised)
image

Operating System:
Windows 10

Neovim Version:
v0.8.0

Bug: `names = false` is not respected

Describe the bug
I have the following config:

return {
  "NvChad/nvim-colorizer.lua",
  event = { "BufReadPost", "BufNewFile" },
  config = function()
    require("colorizer").setup({ "*" }, {
      RGB = true, -- #RGB hex codes
      RRGGBB = true, -- #RRGGBB hex codes
      names = false, -- "Name" codes like Blue
      RRGGBBAA = true, -- #RRGGBBAA hex codes
      rgb_fn = true, -- CSS rgb() and rgba() functions
      hsl_fn = true, -- CSS hsl() and hsla() functions
      css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
      css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
      mode = "background", -- Set the display mode.
    })
  end,
}

But it does not respect the names field and I don't understand why?

image

To Reproduce
The config above

Expected behavior
names = false should not colorize named colors.

Operating System:
e.g. Ubuntu 23.04

Neovim Version:
e.g. v0.9.4

Colorizer Version:
Paste the output of

master @ 36c610a

Recent force-push of master may not include commits from earlier

I was unable to update nvim-colorizer.lua recently through a packer update. Looking at the git history, it appears there was recently a force-push to master. The history has since diverged. Changes that were on master may no longer be there. Potentially impacted issues may be #12. [Edit: I see that change still made it.]

The most recent commit I have from the old master is 2d85588. The newest commit on master today is 2664070. Their most recent ancestor is 84aa4ad. You might want to check the commits from the old branch and make sure they're contents are also on the new branch.

Below is a git log --graph of the two branches.

❯ git log --graph master origin/master
* 2664070 - (origin/master, origin/HEAD) Minor README tweaks including updating the doc links (#19) (2 days ago) <Rolv Apneseth>
*   4c8998c - Merge pull request #17 from Rolv-Apneseth/master (3 days ago) <Sidhanth Rathod>
|\
| * 9bda301 - Updated packer example use line to point to the NvChad fork of nvim-colorizer.lua (3 days ago) <rolv>
| * 633cd09 - Minor fix for example options given in README.md so that it is valid Lua (3 days ago) <rolv>
|/
* b23c0f2 - tailwind: Fix detach when attach is executed multiple times (3 days ago) <Akianonymus>
* 007f0ef - Make sure to use existing options when attaching buffer (3 days ago) <Akianonymus>
* a9aacd3 - Fix reload on au ColorScheme | Check if buffer is valid before attaching (4 days ago) <Akianonymus>
* 6323689 - tailwind: Do not use LspAttach method if vim version <= 7 (4 days ago) <Akianonymus>
* 7d3e620 - docs: Use name in Last Updated | Cleanup | Improve insert mode perf (4 days ago) <Akianonymus>
| * 2d85588 - (HEAD -> master) tailwind: Use true for normal mode (5 days ago) <Akianonymus>
| * 6111aed - buffer_utils: Validate rgb_hex too | trie: Add exact param to longest_prefix (5 days ago) <Akianonymus>
| * 43bfc7b - utils: Improve percent_or_hex function (5 days ago) <Akianonymus>
| * e6c1315 - Fix https://github.com/NvChad/nvim-colorizer.lua/issues/12 | Add support for tailwind colors (5 days ago) <Akianonymus>
* | 125e499 - tailwind: Use true for normal mode (5 days ago) <Akianonymus>
* | 1807b78 - buffer_utils: Validate rgb_hex too | trie: Add exact param to longest_prefix (5 days ago) <Akianonymus>
* | 34061b1 - utils: Improve percent_or_hex function (6 days ago) <Akianonymus>
* | 5f7680e - Fix https://github.com/NvChad/nvim-colorizer.lua/issues/12 | Add support for tailwind colors (6 days ago) <Akianonymus>
| * 448f281 - Update URLs. (7 days ago) <Dan Sully>
|/
* 84aa4ad - colorizer: Make sure it works without giving any config (9 days ago) <Akianonymus>

Feel free to close this if everything seems in order, this is just a friendly heads-up.

Thanks for maintaining this plugin!

Bug: Colors only get loaded after resizing the window

Describe the bug
A clear and concise description of what the bug is.
when opening a file like: vim myfile.css nothing happens:

image

once I resize my terminal or switch between different buffers the cloros get displayed like:

image

To Reproduce
Your configuration and/or a small reproducible test, and/or the steps required to reproduce.

require("colorizer").setup {
	filetypes = { "*" },
	user_default_options = {
		RGB = true,
		RRGGBB = true,
		names = false,
		RRGGBBAA = false,
		AARRGGBB = false,
		rgb_fn = false,
		hsl_fn = false,
		mode = "background",
		css = false,
		css_fn = false,
		sass = { enable = false, parsers = { "css" }, },
		tailwind = false,
		virtualtext = "",
		always_update = false
	},
	buftypes = {},
}

Expected behavior
A clear and concise description of what you expected to happen.
they should be displayed once I open the file and I shouldn't have to resize my terminal for that to happen

Operating System:
NixOS unstable

Neovim Version:

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/grcfjxsgxjajc1ws6ip2jkkhd238dx77-neovim-unwrapped-0.9.1/share/nvim
"

Run :checkhealth for more info

Colorizer Version:

rev: dde3084

Bug: when `setup` is called twice, toggling colorizer no longer works

Describe the bug
A clear and concise description of what the bug is.

if you call require('colorizer').setup() again, the buffers that had colorizer turned on, will no longer turn off.

note that buffers that had it 'off' will continue to work.

I tried running

vim.api.nvim_buf_clear_namespace(0, require('colorizer').DEFAULT_NAMESPACE, 0, -1)

it clears the colorizer, and calling toggle again will switch it back on, but then won't switch it off..

Bug: colors improperly highlighted in cmp menu

Describe the bug
Colors are randomly highlighted in cmp menu when used with tailwindcss-colorizer-cmp.nvim.

To Reproduce

  {
    "hrsh7th/nvim-cmp",
    dependencies = {
      { "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
    },
    opts = function(_, opts)
      local format_kinds = opts.formatting.format
      opts.formatting.format = function(entry, item)
        format_kinds(entry, item)
        return require("tailwindcss-colorizer-cmp").formatter(entry, item)
      end
    end,
  },
  {
    "NvChad/nvim-colorizer.lua",
    opts = {
      user_default_options = {
        tailwind = true,
      },
    },
  },

Expected behavior
I would expect the tailwind colors to not be highlighted in the completion menu.

Screenshots
Screen Recording 2023-03-26 at 5 20 36 PM

Operating System:
MacOS 13.2

Neovim Version:
0.9.0 nightly

Colorizer Version:
dde3084

Additional context
Add any other context about the problem here.

Add support for hsl functions without percentage signs

Describe the bug
Writing hsl(83, 17%, 48%) works, but when writing something like hsl(20, 80, 20), there's no highlighting. I have a lua codebase where I use something like this, and I would like it to be highlighted.

Operating System:
Arch Linux

Neovim Version:
0.8.0

Colorizer Version:
latest

Additional context
Add any other context about the problem here.

Bug: Incorrect tailwind lsp colors when applying selectors

Describe the bug
lsp colors are only applied to the dark: selector when custom colors are defined. This occurs when tailwind is set to tailwind="both" during configuration.

To Reproduce
nvim-colorizer config:

  {
    "NvChad/nvim-colorizer.lua",
    opts = {
      user_default_options = {
        names = false,
        tailwind = "both",
      },
    },
  },

Configure custom colors within tailwind.config:

extend: {
    colors: {
        gray: {
          700: "#AC50EF",
          800: "#2ECFF6",
        }
    }
}

Expected behavior
I would expect lsp colors to take precedence over hardcoded colors upon loading.

Screenshots
image
image

Operating System:
MacOS Ventura 13.3

Neovim Version:
0.9.0

Colorizer Version:
dde3084

Additional context

Bug: not color if variable

does not output a color if it is assigned to a variable, and outputs the color of lines that are not quite colors example text_black

Operating System:
Fedora 37 x64

Neovim Version:
0.8.0
Colorizer Version:
latest
Снимок экрана от 2022-11-15 15-04-07
Снимок экрана от 2022-11-15 15-09-04
my settings

require("colorizer").attach_to_buffer(0, { mode = "background", css = true })
local colorizer = require('colorizer')
colorizer.setup {
  filetypes = { "dart" },
  user_default_options = {
    RGB = true, -- #RGB hex codes
    RRGGBB = true, -- #RRGGBB hex codes = true, -- "Name" codes like Blue or blue
    RRGGBBAA = true, -- #RRGGBBAA hex codes
    AARRGGBB = true, -- 0xAARRGGBB hex codes
    rgb_fn = true, -- CSS rgb() and rgba() functions
    hsl_fn = true, -- CSS hsl() and hsla() functions== --, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
    css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
    -- Available modes for `mode`: foreground, background, virtualtext
    mode = "virtualtext", --Set the display mode.
                      -- Available methods are false / true / "normal" / "lsp" / "both"
                      -- True is same as normal
    tailwind = false, -- Enable tailwind colors
        -- parsers can contain values used in |user_default_options|
    sass = { enable = false, parsers = { css }, }, -- Enable sass colors
    virtualtext = "■",
  }, 
  -- all the sub-options of filetypes apply to buftypes
  buftypes = {
    "*",
    "!prompt",
    "!popup"
  },
}

Feature request: support for #rgba shortcut

Hi and thank you for your work. The plugin already supports 6 character hex colours, 3 character hex shortcut, and 8 character hex color with alpha component. It would be great to also add support for 4 character hex color with alpha channel.

Example

body {
  color: #ff0000;
  color: #f00;
  color: #ff000000;
  color: #f000; /* not highlighted */
}

Related MDN documentation about hex color

Thanks!

Bug: tan() function gets colorized

A function named tan() gets colorized. This isn't referring to a color, so I expect it to not get colorized. Maybe this can be fixed by checking for a trailing parenthesis.

Screenshots
image

Neovim Version:
0.8.1

Colorizer Version:
760e27d

Bug: rgb function not show color preview

Describe the bug
rgb function not show color preview

To Reproduce

  • install plugin
  • set config like this:
require("colorizer").setup {
    filetypes = { "*" },
    user_default_options = {
      RGB = true, -- #RGB hex codes
      RRGGBB = true, -- #RRGGBB hex codes
      names = true, -- "Name" codes like Blue or blue
      RRGGBBAA = false, -- #RRGGBBAA hex codes
      AARRGGBB = false, -- 0xAARRGGBB hex codes
      rgb_fn = true, -- CSS rgb() and rgba() functions
      hsl_fn = false, -- CSS hsl() and hsla() functions
      css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
      css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
      -- Available modes for `mode`: foreground, background,  virtualtext
      mode = "background", -- Set the display mode.
      -- Available methods are false / true / "normal" / "lsp" / "both"
      -- True is same as normal
      tailwind = false, -- Enable tailwind colors
      -- parsers can contain values used in |user_default_options|
      sass = { enable = false, parsers = { css }, }, -- Enable sass colors
      virtualtext = "",
    },
    -- all the sub-options of filetypes apply to buftypes
    buftypes = {},
}

create a file with content

#css #color 

# White
- #e0e5ec

# blue
rgb(0, 172, 238)

Expected behavior
rgb function show color preview

Screenshots
image

Operating System:
Ubuntu 22

Neovim Version:
0.8

Colorizer Version:
760e27d

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.