-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coloured devicons out of the box #158
Comments
Hey @zeorin I remember you mentioned this previously on chat. I really like how that looks and I wanted to add something like this to vimdevicons however @tiagofumo has created something since then that might make that work redundant, he wanted to do a separate repo it is here: https://github.com/tiagofumo/vim-nerdtree-syntax-highlight What do you think? Btw, I like your implementation it is very clean |
That would work only with NERDTree, I assume? As you can see on line https://github.com/zeorin/dotfiles/blob/e01cebf/.vimrc#L870, my addition allows you to choose the file types in which the highlighting happens. To add Startify highlighting I added a comma and a word. Also, I think having this as standard would be more appropriate than a separate repo/plugin. It's your call. I've got what I want already 😄 |
@zeorin your code looks very clean. When I created my solution for this I really didn't put much time to think where and how I would do it. I think I just got upset with the fact there was no syntax identifier for specific file types and I started by trying to add it. I also couldn't find anyone who cared enough about it at the time, so I just did whatever I thought was a good idea. There is one tiny little difference in your solution though. Your code focuses on adding the color to the icon, so the same icon cannot have different color for different files. Even though I do have same icons with different color sometimes (like the html5 icon is orange for html and red for rails' .html.erb, as one can see on the screenshot at my repo), I could just add different icons if needed (like the rails symbol to .html.erb files similar to other editors). I don't try at any point to justify my solution to this feature. Like I said, your code looks much better and clean, and I also think would be better if vim-devicons had this functionality by itself. But I just feel like you: "It's your call. I've got what I want already 😄" |
Ah sorry I did not know that!
I would be up for that actually. If either of you want to submit a PR I would be happy to get something merged in (even if https://github.com/tiagofumo/vim-nerdtree-syntax-highlight is around) Linking to https://github.com/tiagofumo/vim-nerdtree-syntax-highlight will/should still be done in the readme |
Sorry to bump this thread but I wanted to know if you are any close to implementing this? Could this also work for lightline (or any other statusbar, but I use lightline...)? Thank you in advance for answering my (maybe silly) question! :) |
I've not worked on this because it's working fine for me with my setup. However, it'd be really nice to have it in the plugin by default. I'll have a look at it, but don't expect anything right away ;-) |
Here is what I came up with I also got colored icons working for the lightline plugin HereI use it in my filenameMod component Do whatever you want with the code... I'm not sending a pull request as I have never done that before and I'm just a beginner in VimL, so I wouldn't really know where to put the code... ps: While testing my code, I found a small bug. svg-files should get the same icon as images imo! |
Sorry for the delayed responses all. @0phoff Looks pretty cool thanks. I understand your reasons for not sending a PR so no worries but feel free to change your mind as well 😉 Good catch on the svg icons! Yes you are correct those should be the same as the other images or some similar image icon. |
Hi zeorin , Great job. Is there a way you can write the installation procedure? How can i go about accomplishing what you have done with your .vimrc |
This worked great for me. I had to add the elixir icon but the DeviconsColors was super easy to read so that was simple 👍 |
How would I go about to get this feature? The links by @0phoff no longer work. |
https://github.com/tiagofumo/vim-nerdtree-syntax-highlight Edit: Nvm misread. |
Sorry, I completely overhauled my VIM settings since and got rid of these icons, in favor for a more minimal look ... 🤷♂️ Here are both links, which I took from previous commits of my DotFiles repo: |
Thanks, I wrote a similar solution but in lua (Neovim 0.5+) and I am reusing already existing groups. Funtion itself in local M = {}
function M.set_icon_colors(config, filetypes)
local joined_filetypes = table.concat(filetypes, ",")
vim.api.nvim_command('augroup DeviconsColors')
vim.api.nvim_command('autocmd!')
for group, icons in pairs(config) do
vim.api.nvim_command(string.format('autocmd FileType %s syntax match %s /\\v%s./ containedin=ALL', joined_filetypes, group, table.concat(icons, '.|')))
end
vim.api.nvim_command('augroup END')
end
return M Then you can use the following inside your configuration: let g:devicons_colors = {
\ 'String': [''],
\ 'Type': ['', '', ''],
\ 'Statement': ['', '', ''],
\ 'Number': ['', '', ''],
\ 'Function': ['', ''],
\ 'Identifier': [''],
\ 'Normal': ['', '', '', '', '', '', '', ''],
\}
lua require'devicons'.set_icon_colors(vim.g.devicons_colors, {'startify', 'fern'}) |
Thanks for the code. I've made a plugin for this which use a similar approach. |
I recently got introduced to As a follow up to @Shatur95 and @lambdalisue 's solutions, I've written a pure Vimscript plugin to generate and highlight the icons with the current colorscheme's common highlight groups. https://github.com/bryanmylee/vim-colorscheme-icons While there is not much customizability, it should allow you to instantly get decent colorization of the icons that match the current theme. |
@zeorin I used your code snippet you reference in this thread. Though when I change colorscheme, the devicon colors disappear. How would you go about resolving that. Update:
Further question: |
It'd be a cool feature if coloured devicons worked out of the box. Perhaps include some colour maps for the stock shipped colorschemes and some popular 3rd party ones, a mechanism for users to define their own colour map for colorschemes, falling back to standard terminal colours for terminal vim and the actual colours as per filetype's official colour for GUI vim (e.g. Gulp's
#cf4646
for the Gulp icon).By reading and adapting the section in the README, I've got coloured devicons set up.
I'm using the Solarized colorscheme, so I've chosen the colors that match the palette. You can look at https://github.com/zeorin/dotfiles/blob/e01cebf/.vimrc#L864-L900 for how I did this in my
.vimrc
.The text was updated successfully, but these errors were encountered: