nvim-tree / nvim-web-devicons

lua `fork` of vim-web-devicons for neovim
MIT License
1.92k stars 181 forks source link

feat: add many icons #433

Closed hasecilu closed 2 months ago

hasecilu commented 2 months ago

Still WIP I'm looking at more icons, I want to hear some ideas. Also I'm waiting for new Nerd Fonts release that includes some new icons. 3.2.0 ver. released, I included the KDE, posmarketOS & Qt logos that are new.

https://github.com/ryanoasis/nerd-fonts/releases/tag/v3.2.0


For example in:

local filetypes = {
  ["avif"] = "avif",
  ["bzl"] = "bzl",
...
}

Would be possible to create groups, for example create a single icon entry and use it various times for different file extensions to simplify the code? For example the open PR with music extensions, maybe a group of video, compressed files. In my case in this PR check the FreeCAD and KiCad extensions.

Something like:

local filetypes = {
...
  ["fcmacro"] = "freecad",
  ["fcmat"] = "freecad",
  ["fcparam"] = "freecad",
  ["fcstd"] = "freecad",
...
}
hasecilu commented 2 months ago

Rebased, I think now only need to update local filetypes = {}

alex-courtis commented 2 months ago

Looking good...

Some of the darks ones are... too dark to see.

XTerm.vt100.reverseVideo:   true
XTerm.termName: xterm-256color

20240407_130819

XTerm.vt100.reverseVideo:   true
XTerm.termName: xterm-direct

20240407_130925

I encountered the same with linux and fixed them here: #408

I just poked around the website until I found another theme colour that was more dark friendly.

alex-courtis commented 2 months ago

Fails at startup when using xterm defaults i.e. nothing in xrdb. Master is OK.

xterm -rv is OK.

Error detected while processing VimEnter Autocommands for "*":
E5108: Error executing lua [string ":lua"]:1: VimEnter Autocommands for "*"..OptionSet Autocommands for "background": Vim(append):Error executing lua callback: vim/shared.lua:0: after the second argument: expected table, got nil
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'tbl_extend'
        ...ite/pack/packer/start/hasecilu/lua/nvim-web-devicons.lua:39: in function 'refresh_icons'
        ...ite/pack/packer/start/hasecilu/lua/nvim-web-devicons.lua:567: in function <...ite/pack/packer/start/hasecilu/lua/nvim-web-devicons.lua:566>
        [C]: in function '__newindex'
        [string ":lua"]:1: in main chunk
stack traceback:
        [C]: in function '__newindex'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue
hasecilu commented 2 months ago

I was about to update local filetypes = {} but I noticed that a lot of extensions are missing and even some don't appear in the table as "dosbatch", what's the diffenrence for filetype and file extension?

alex-courtis commented 2 months ago

what's the diffenrence for filetype and file extension?

It's just a mapping of vim filetypes to something - extension, name, os

It's not well maintained.

alex-courtis commented 2 months ago

This is working now. Everything is following existing patterns so not worth digging deeper...

hasecilu commented 2 months ago

More changes, let me know if something is missing

alex-courtis commented 2 months ago

There are some vim filetype mappings we can add e.g. gtkrc

Can you please look through /usr/share/nvim/runtime/syntax and find any others to map?

hasecilu commented 2 months ago

Sure, maybe an instruction to redirect to /usr/share/nvim/runtime/syntax would be useful

alex-courtis commented 2 months ago

Sure, maybe an instruction to redirect to /usr/share/nvim/runtime/syntax would be useful

Sorry, I mean add them to

-- Map of filetypes -> icon names
local filetypes = {
  ["avif"] = "avif",
hasecilu commented 2 months ago

What I meant it was to put an instructions for contributors that doesn't know of the existance of those files, like me :sweat_smile: I used this to find coincidences:

lua_file="$HOME/git/github/nvim-web-devicons/lua/nvim-web-devicons/icons-default.lua"
ft="$HOME/git/github/nvim-web-devicons/lua/nvim-web-devicons.lua"
while IFS= read -r line; do
if [[ $line =~ \[\"(.+)\"\] ]]; then
    key="${BASH_REMATCH[1]}"
    # Search for the key in the main file
    line=$(grep -F "\"$key\"" "$ft")
    if [ -n "$line" ]; then
        continue
    else
        # echo "$key" | lolcat
        [ -f "/usr/share/nvim/runtime/syntax/$key.vim" ] && echo "$key.vim"
    fi
fi
done <"$lua_file"
alex-courtis commented 2 months ago

What I meant it was to put an instructions for contributors that doesn't know of the existance of those files, like me 😅 I used this to find coincidences:

lua_file="$HOME/git/github/nvim-web-devicons/lua/nvim-web-devicons/icons-default.lua"
ft="$HOME/git/github/nvim-web-devicons/lua/nvim-web-devicons.lua"
while IFS= read -r line; do
if [[ $line =~ \[\"(.+)\"\] ]]; then
  key="${BASH_REMATCH[1]}"
  # Search for the key in the main file
  line=$(grep -F "\"$key\"" "$ft")
  if [ -n "$line" ]; then
      continue
  else
      # echo "$key" | lolcat
      [ -f "/usr/share/nvim/runtime/syntax/$key.vim" ] && echo "$key.vim"
  fi
fi
done <"$lua_file"

Oh nice. Maybe drop it in scripts. There's an existing one but it doesn't seem to be very useful.