Skip to content
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

webdevicons - support for custom icons #392

Closed
adelarsq opened this issue Apr 13, 2020 · 13 comments · Fixed by #654
Closed

webdevicons - support for custom icons #392

adelarsq opened this issue Apr 13, 2020 · 13 comments · Fixed by #654

Comments

@adelarsq
Copy link

I'm creating a plugin (vim-emoji-icon-theme) that use webdevicons behind the scenes to allow use of emojis for filetypes instead of patched fonts.

For example NERDTree shows like this:

Captura de Tela 2020-04-13 às 10 32 26

To support clap my plugin needs that this plugin use the icons provided by webdevicons (using something like the WebDevIconsGetFileTypeSymbol(absolute_file_path) function for example).

Is it possible?

@liuchengxu
Copy link
Owner

liuchengxu commented Apr 13, 2020

Hmm, that could be partially supported. It's possible for the sync filter, I can make the icons used in vimscript overridable.

let g:clap#icon#extensions = {

But it's impossible to configure the icons used in Rust code https://github.com/liuchengxu/vim-clap/blob/master/crates/icon/src/constants.rs. I'm not sure if people can bare with these inconsistent icons.

If people do want to change the icons used in Rust, the process is not convenient at present. He can update https://github.com/liuchengxu/vim-clap/blob/master/crates/icon/exactmatch_map.json, run python3 update_constants.py and recompile the maple binary.

@adelarsq
Copy link
Author

adelarsq commented Apr 13, 2020

But it's impossible to configure the icons used in Rust code https://github.com/liuchengxu/vim-clap/blob/master/crates/icon/src/constants.rs. I'm not sure if people can bare with these inconsistent icons.

They can't. This turns the plugin unusable with clap at the moment. One on the objectives from the plugin (for the far future) is to create a interface that is consistent across plugins, even if is there no relation between each. For example a icon for a buffer from one plugin is the same for another plugin.

If people do want to change the icons used in Rust, the process is not convenient at present. He can update https://github.com/liuchengxu/vim-clap/blob/master/crates/icon/exactmatch_map.json, run python3 update_constants.py and recompile the maple binary.

What about to read this values from a json without use Python? Just a *.json file passed as argument for the Rust code with the desired icons. So EXTENSION_ICON_TABLE and EXACTMATCH_ICON_TABLE can be filled at runtime.

@liuchengxu
Copy link
Owner

I'm reluctant as that's not the way of having optimal performance. If you can provide a JSON of emojis, I can consider make it a new builtin option.

@adelarsq
Copy link
Author

adelarsq commented Apr 14, 2020

I'm reluctant as that's not the way of having optimal performance.

Definitely. But maybe that this is not so noticeable.

If you can provide a JSON of emojis, I can consider make it a new builtin option.

I can provide.

Some emojis need to have a space together to render properly on Vim/NeoVim ('🅱' for example need to be writed as '🅱 '). So for now the chars need to be writted as strings. This can be done? I did see on the clap plugin and appears that is already done on this way, but I don't know if I am right.

@liuchengxu
Copy link
Owner

liuchengxu commented Apr 14, 2020

You are right, an extra space is neccessary when rendering, https://github.com/liuchengxu/vim-clap/blob/302dd2d718/autoload/clap/provider/grep.vim#L33.

@adelarsq
Copy link
Author

adelarsq commented Apr 14, 2020

Yes. But not all chars ('💡' for example works fine, but '🅱' don't). Also some are fine on MacOS but are wrong on Linux. So I have to test each char for each platform. About Windows I don't know since I don't have one anymore, but last time that I did a test was working fine with GVim.

If necessary I can provide a different json list for each platform, let's see.

@adelarsq
Copy link
Author

I have added some support for vim-clap:

Captura de Tela 2020-04-23 às 20 49 10

@adelarsq
Copy link
Author

At moment I trying to figure out why Vim/NeoVim has so many problems rendering emojis. Some emojis are rendered just half, others keep showing on the screen (tests on Linux, Windows and Mac)... This is more complex than this issue on Clap, since we need to change on the Vim/NeoVim code base side.

So I decided to create another plugin for icons based on NerdFonts and I will close this issue for now. I will turn public the new plugin until next week.

@adelarsq
Copy link
Author

adelarsq commented Jun 1, 2020

I found a way to "solve". Basically some icons render right an others dont. So I need to use just the right icons. It will need some work, but works!

@liuchengxu I will reopen this issue and provide a custom JSON to be used on this plugin.

@adelarsq adelarsq reopened this Jun 1, 2020
Repository owner deleted a comment from github-actions bot Aug 1, 2020
@liuchengxu
Copy link
Owner

Hi @adelarsq, any progress on this issue?

@adelarsq
Copy link
Author

adelarsq commented Jan 23, 2021

I plan to do a refactoring, to read all chars from a generated json, on next months. But I will need to detect the terminal for a good behaviour. So we will have a good behaviour even on Windows I think.

At moment I'm using vim-clap with vim-emoji-icon-theme daily and it's behaving well on iTerm. Need some more testing on Kitty since I don't use so often.

Edit:
Also I did change g:clap_current_selection_sign (using ) and g:clap_current_selection_sign (using ) chars to avoid issues on vim-clap.

@liuchengxu
Copy link
Owner

With #654, you can use the custom icons easier, just modify the json file in https://github.com/liuchengxu/vim-clap/tree/master/crates/icon directly and recompile the Rust binary. But PR is still welcome :(.

liuchengxu added a commit that referenced this issue Mar 8, 2021
* Generate the icon const table using build.rs

Close #392

* Commit build.rs

* Update CHANGELOG.md

* .

* .
@adelarsq
Copy link
Author

adelarsq commented Mar 8, 2021

@liuchengxu Nice! Thanks! I will add this feature on the next weeks 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants