Sunday , January 24 2021
Breaking News

norcalli / nvim-colorizer.lua, Hacker News


                    

        

luadoc

A high-performance color highlighter for Neovim which hasno external dependencies! Written in performant Luajit.

Demo.gif

Demo.mp4

Installation and Usage

Use your plugin manager or clone directly into yourruntimepath.

Plug''norcalli / nvim-colorizer.lua'

As long as you havemalloc ()andfree ()on your system, this will work. Which includes Linux, OSX, and Windows.

One line setup. This will create anautocmdforFileType *to highlight every filetype.

luarequire'colorizer'.setup()

Why another highlighter?

Mostly,RAW SPEED.

This has no external dependencies, which means you install it andit just works. Other colorizers typically were synchronous and slow, as well. Being written with performance in mind and leveraging the excellent LuaJIT and a handwritten parser, updates can be done in real time. There are plugins such ashexokinasewhich have good performance, but it has some difficulty with becoming out of sync. The downside is thatthis only works for Neovim, and that will never change.

Additionally, having a Lua API that’s available means users can use this as a library to do custom highlighting themselves.

Customization

The available highlight modes areforeground,background. The default isbackground.

Full options list:

  • no_names: Disable parsing names like “Blue”
  • rgb_fn: Enable parsingRGB (...)functions.
  • mode: Highlight mode. Valid options:foreground,background

For basic setup, you can use a command like the following.

-Attaches to every FileType moderequire'Colorizer'.setup()-Attach to certain Filetypes, add special configuration for `html`-Use `background` for everything else.require'Colorizer'.setup{   'CSS'';   'javascript'';   html={ mode=''foreground';   } }-Use the `default_options` as the second parameter, which uses-`foreground` for every mode. This is the inverse of the previous-setup configuration.require'Colorizer'.setup({   'CSS'';   'javascript'';   html={mode='background''}; }, {mode=''foreground'})-Use the `default_options` as the second parameter, which uses-`foreground` for every mode. This is the inverse of the previous-setup configuration.require'Colorizer'.setup{   '*'';-Highlight all files, but customize some others.  CSS={rgb_fn=true; };-Enable parsing rgb (...) functions in css.  html={no_names=true; }-Disable parsing "names" like Blue or Gray}

For lower level interface, see theLuaDocs for API detailsor use: h colorizer.luaonce installed.

TODO

  • Add more display modes?
  • Use a more space efficient trie implementation.
  • Create a COMMON_SETUP which does obvious things like enablergb_fnfor css

  

Brave Browser
Read More
Payeer

About admin

Leave a Reply

Your email address will not be published. Required fields are marked *