Closed sophiabrandt closed 3 years ago
How are you opening the css file? Are you doing it as nvim *.css
? If you do :e
to reload the file (outside of any other commands), does it add the highlighting?
Basically it's set with FileType autocmds which may not trigger for the first file you open correctly. I have in the past considered just attaching to the first buffer available as a "fix".
Hm. I open nvim from terminal with the file directly.
For example: nvim css/style.css
.
Filetype is set correctly:
set ft?
> filetype=css
Neither :redraw!
nor re-opening the buffer with :e
make any difference.
As you said, I can attach to the buffer with :ColorizerAttachToBuffer
.
I even get auto-complete suggestion in Ex mode.
For example, as soon as I type :Colo
, Nvim sugests the nvim-colorizer.lua
commands.
If you don't have any other ideas, you can close the issue, if you like.
Thanks for your help.
I worked around this issue by using the VimEnter autocmd. From there I call a function, which runs the colorizer setup() function and then runs an initial filetype detect
which retriggers the FileType autocmds.
A followup: What's working for me is loading the plugin with a key binding. (VimEnter command would also work.)
Something like this:
nnoremap <LocalLeader>c :<C-u>lua require 'nvim-colorizer'<CR>:<C-u>ColorizerAttachToBuffer<CR>
I've delegated the setup to a lua function which seems to avoid common pitalls.
I've made a separate folder called lua
and added a file called nvim-colorizer.lua
with the following content (adjust to your needs):
require 'colorizer'.setup ({
'css';
'html';
'javascript';
'javascriptreact';
'typescript';
'typescriptreact';
}, {
mode = 'background';
names = true;
css = true;
css_fn = true;
})
First, thanks for the plugin. I was using
Hexokinase
before, but didn't want to upgrade to the new version due to the required dependencies.I have a question regarding setup.
Description I have installed the plugin with minpac. My
init.vim
sources a file where I load all plugins:I load
nvim-colorizer.lua
in theplugins.vim
file:When I open a css file, I see no color highlighting. If I call
:ColorizerAttachToBuffer
or:ColorizerToggle
manually from within the buffer, I get syntax highlighting.:messages
doesn't print errors.I'm unsure on how to debug this. Is there a command or a lua function I can call?
Expected behavior
nvim-colorizer.lua
should highlight as soon as NeoVim enters the buffer, without having to call a command.Operating System: Linux 4.19.85-1-MANJARO x86_64 GNU/Linux
Neovim Version: NVIM v0.4.3 Build type: Release LuaJIT 2.0.5
Colorizer Version: cfe8c495452272ed88da29a6babd906c483accf4