gaenseklein / repfiles

plugin for micro text editor - filemanager for projects (git-repositorys)
GNU General Public License v3.0
3 stars 0 forks source link

Would it be possible to use nerdfonts icons? #1

Open taconi opened 10 months ago

taconi commented 10 months ago

Would there be a way to integrate the file icons into the visualization?

Something like that: (print taken from the filemanager2 plugin) image

I can contribute to this if it makes sense.

gaenseklein commented 10 months ago

hi, thx for the feedback

i took a look at filemanager2 plugin and it has the logic all externalized. that made it easy to integrate. but it needs nerdfonts installed. i want repfiles by default to be as much portable as possible and therefore test the used icons on different machines and os i have access to / work with. also it is too big for my taste - it has tons of regex it has to parse to find the right one icon. i work with old machines too and therefore want something smaller, easier by default.

but i am not against expanding or theming either. in fact i think this is the best opportunity to bring in a little theming. i wrote a simpler version of icon.lua which serves as a starting point and example of what you could do - following the same API as the icon.lua from filemanager2. therefore you could replace the default icon.lua with the one from filemanger2.lua to get the version with nerdfonts running. i copied the icon.lua from filemanager2 to filemanager2-icon.lua and commented out the unneccessary checks so just copy this file over the standard icon.lua file and you should be done. (remember that you have nerdfonts to be installed)

this theming works fine - but there is one thing more to theming and that is changing the syntax.yaml, because there i use the icons for the files to differenciate between dir and files, text-files and binarys. i integrated the ones from filemanager2, but any further icon-change has to be reflected there.

best way would be to programmaticaly change the line-colors instead of using syntax.yaml but i did not found out how.

please give feedback if everything is working. i dont have nerdfonts installed so i could not "see" the exact result but it should work

taconi commented 10 months ago

In order to not make it mandatory to install nerdfonts, logic similar to that of filemanager2 could be used to have a configuration to activate the use of icons, such as "repfiels.nerdfonts": true.

Regarding portability to operating systems, nerdfonts supports Mac, Windows and Linux, so I believe there would be no problem, but it could be added as a test warning that errors may occur and that errors are reported in the issues.

Regarding the syntax, there is the function config.PluginAddRuntimeFileFromMemory, the plugin literate would be an example of use, there a pure string is used but it could be a template file.

gaenseklein commented 10 months ago

In order to not make it mandatory to install nerdfonts, logic similar to that of filemanager2 could be used to have a configuration to activate the use of icons, such as "repfiels.nerdfonts": true.

you can now set repfiles.nerdfonts to true and it uses filemanager2-icon.lua instead of icon.lua. maybe i should rename filemanager2-icon.lua to something more obvious then.

Regarding portability to operating systems, nerdfonts supports Mac, Windows and Linux, so I believe there would be no problem, but it could be added as a test warning that errors may occur and that errors are reported in the issues.

thats not my point. if i ssh somewhere i would like to have a running micro with minimal effort. installing a font would bother me. i would do that on my local machine - but then i would not mind to overwrite the icon.lua with something i would prefere with much more detail. so the default should mostly work out of the box. i integrated the option now, but i still think it would be better to do it manualy to have the reminder that you have to also install a font to make it work. simply turning the option "nerdfonts" to true does not install automagically nerdfonts and does not work therefore. but i dont care too much. if it helps you here it is.

Regarding the syntax, there is the function config.PluginAddRuntimeFileFromMemory, the plugin literate would be an example of use, there a pure string is used but it could be a template file.

looks good. i still think an option to highlight programmatically would be way better and this still feels like an ugly hack - but it works. thanks. what i dont like is that now theming of style-syntax is in two places - one in syntax.yaml and the other programmatically though and its part of theming. urgh, i really would like to have programmatically highlightning. would be way easier to make it configurable and such...

gaenseklein commented 9 months ago

as i found out now that the icons i used are not widely adapted in fonts i would recommend nerdfonts. maybe building a small package of nerdfonts with only the really necesary icons used in repfiles and ship it with repfiles directly. right now i would recommend installing https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/NerdFontsSymbolsOnly.zip