Skip to content

Conversation

@Bakudankun
Copy link

This is a PR for #4.

The g:nerdfont#filetype#defaults was made by the next script and some necessary hand-picking.
No docs and tests yet, but I'll add them before very long...

" filetype_icons.vim
" Create a dictionary that maps filetypes to icons by converting path icons.
" Place this file into the project root directory and run the next command:
" vim --clean -S filetype_icons.vim
" Then check g:filetype_icons.

set encoding=utf-8

source ./autoload/nerdfont/path/extension.vim
source ./autoload/nerdfont/path/basename.vim

let g:filetype_icons = {}


function! s:add_filetype_icon(filename, icon)
  execute 'new' fnameescape(a:filename)
  let filetype = &filetype
  quit

  if !has_key(g:filetype_icons, filetype) 
    let g:filetype_icons[filetype] = a:icon
    return
  endif

  " If the filetype is duplicate, make a list to contain all icons
  " for later hand-picking.
  if type(g:filetype_icons[filetype]) == v:t_string
    if g:filetype_icons[filetype] ==# a:icon
      return
    endif

    let g:filetype_icons[filetype] = [g:filetype_icons[filetype]]
  endif

  if index(g:filetype_icons[filetype], a:icon) < 0
    call add(g:filetype_icons[filetype], a:icon)
  endif
endfunction


for [ext, icon] in items(g:nerdfont#path#extension#defaults)
  call s:add_filetype_icon('hoge.' .. ext, icon)
endfor

for [filename, icon] in items(g:nerdfont#path#basename#defaults)
  call s:add_filetype_icon(filename, icon)
endfor

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant