mhinz / vim-startify

:link: The fancy start screen for Vim.
MIT License
5.31k stars 186 forks source link

Show devicons using nvim-web-devicons not vim-devicons #471

Closed lalitmee closed 3 years ago

lalitmee commented 3 years ago

How can I show devicons using nvim-web-devicons? I am trying to use plugins which are written in lua so I am trying to loose vim-devicons.

I am trying to use something like this. I don't know how to write viml or lua.

function! StartifyEntryFormat()
  return luaeval(
          \ "require('nvim-web-devicons').get_icon(vim.fn.fnamemodify(' " .. absolute_path .. "', ':e')) or ' '"
          \ ) . " " . entry_path
endfunction

Am I doing something wrong?

Mathijs-Bakker commented 3 years ago

This works:

Put this in your vimrc:

lua << EOF
function _G.webDevIcons(path)
  local filename = vim.fn.fnamemodify(path, ':t')
  local extension = vim.fn.fnamemodify(path, ':e')
  return require'nvim-web-devicons'.get_icon(filename, extension, { default = true })
end
EOF

function! StartifyEntryFormat() abort
  return 'v:lua.webDevIcons(absolute_path) . " " . entry_path'
endfunction

Or pure Lua: --> Startify/init.lua

lalitmee commented 3 years ago

@Mathijs-Bakker , thanks for your solution. I got the same answer from a recent Reddit post. I solved it.

Thank you so much. :+1: