norcalli / nvim-colorizer.lua

The fastest Neovim colorizer.
Other
2.25k stars 117 forks source link

Doesn't work for *.conf filetypes (and maybe others?) #9

Closed filipekiss closed 4 years ago

filipekiss commented 4 years ago

I installed your plugin and was working with a *.conf file and noticed the colors weren't working. I thought I was messing the configuration, but it works when I'm on a *.sass file. Here's a gist with both files and a minimal.vimrc for reproduction.

Great plugin, btw!

Sass File Conf File
image image
norcalli commented 4 years ago

I can confirm this problem! I have no idea why, yet, though, but I'm working on another few issues, so I'll try to address it very soon. And thanks :)

filipekiss commented 4 years ago

@norcalli I think I found out the problem: The .conf file has no filetype in vim. If you set ft=conf the colors come up as if magic!

--- edit ---

I think this is not colorizer fault, but maybe we can add the information on the README that won't work for buffers without filetype? (since the AutoCmds won't be run)

norcalli commented 4 years ago

The problem probably originates in the FileType autocmd [EDIT: as you just mentioned, haha].

The setup function is just a thin wrapper around calling colorizer.attach_to_buffer().

If you do :lua require'colorizer'.attach_to_buffer(0), it will highlight the current buffer.

You can use this with options too (as the second parameter). In the meantime, it would seem that making an autocmd for BufReadPost *.conf setl ft=conf would work.

filipekiss commented 4 years ago

Yeah, adding the filetype solves the problem for me. Great plugin ♥️ Thank you so much!

norcalli commented 4 years ago

@filipekiss yeah, adding it to the README is a good idea. I'll keep this issue open for now for future travelers.

filipekiss commented 4 years ago

Made a pull-request with the information. :D Hope it helps.