Open norcalli opened 4 years ago
TODO:
For the record, based on the reddit comment timestamps, it took me only an hour to implement :P
Ass [sic] suggested by https://www.reddit.com/r/neovim/comments/djfpke/nvimcolorizerlua_fast_colorizer_with_no_external/f4rjt77/
Thanks @norcalli !
I'm guessing that the autocmd
can go in my .vimrc
, but I'm unsure what to do with the setup file step.
@alxndr It depends on how you were doing your setup already. Here's an example:
lua << EOF
require 'colorizer'.setup {
'*';
scss = { custom_matcher = require'colorizer/sass'.variable_matcher };
}
EOF
It depends on how you were doing your setup already.
I'm using vim-plug, and I've set termguicolors
, added these lines to my init.vim
, and then :so % | PlugInstall
...
Plug 'norcalli/nvim-colorizer.lua', {'do': ':lua require''colorizer''.setup()'}
autocmd FileType scss lua require'colorizer/sass'.attach_to_buffer()
I haven't yet used Lua with Neovim so I'm unfamiliar with what else might be involved in setting up a plugin that uses it.
@alxndr Putting it in the do
block is not correct here. It'll only run once when you install it. You should put it after the plug#end()
statement in your vimrc so it's sourced every time.
Okay, thanks. So I've got the Plug
line, then I've done PlugInstall
, and then added to my init.vim
:
set termguicolors
lua require'colorizer'.setup()
autocmd FileType scss lua require'colorizer/sass'.attach_to_buffer()
lua << EOF
require 'colorizer'.setup {
'*';
scss = { custom_matcher = require'colorizer/sass'.variable_matcher };
}
EOF
However when I start up Neovim I see this error at the top of a long stack trace (?):
Error detected while processing /Users/x/.config/nvim/init.vim:
line 206:
E5105: Error while calling lua chunk: [string "<VimL compiled string>"]:3: module 'colorizer/sass' not found:
no field package.preload['colorizer/sass']
no file '/Users/x/.config/nvim/lua/colorizer/sass.lua'
no file '/Users/x/.config/nvim/lua/colorizer/sass/init.lua'
[...many more "no file" lines listing files in other plugins I have installed...]
(Line 206 is the last line of the snippet I shared above, with just EOF
on the line.)
Thanks for looking into this!
@alxndr You're going to want to use Plug 'norcalli/nvim-colorizer.lua', { 'branch': 'sass-variable-matcher' }
for the correct branch.
Aha, thank you! Here's the bare-bones init file I used to get this working:
set termguicolors
call plug#begin("~/.config/nvim/plugged")
Plug 'norcalli/nvim-colorizer.lua', { 'branch': 'sass-variable-matcher' }
call plug#end()
lua << EOF
require'colorizer'.setup({
'*';
'lua';
scss = { custom_matcher = require'colorizer/sass'.variable_matcher };
css = { css = true; };
}, { mode = 'background'; })
EOF
autocmd FileType scss lua require'colorizer/sass'.attach_to_buffer()
@alxndr have you been using this branch? I'm interested in trying to get it merged and I want to hear any feedback first.
@alxndr have you been using this branch? I'm interested in trying to get it merged and I want to hear any feedback first.
I've been using it on and off, and it's very nice!
Minor bug?
I'm using this to open a floating window with a terminal; between when I exit
that terminal and when the floating window closes, this error appears in the status bar: Error executing lua callback: ...onfig/nvim/plugged/nvim-colorizer.lua//lua/colorizer.lua:523: Index out of bounds
General feedback
notermguicolors
to fit in with my current theme. rgba()
would be great... (I don't have any bright ideas about how to represent the opacity)Looks amazing! Any chance of getting it merged at some point? Thanks for great plugin @norcalli!
I have implemented sass support in my repo, loosely based on this pr. Along with support for imports, recursive imports and variables.
Usage will be in two parts:
Setting your setup file:
Attaching to a buffer to trigger updating the dictionary.
Demo https://github.com/norcalli/github-assets/raw/master/colorizer-demo-sass.gif
https://github.com/norcalli/github-assets/raw/master/colorizer-demo-sass.mp4
Only the buffers which have been attached will be considered for variable definitions.