Skip to content

How add icon in default statusline? #164

Answered by T-727
DinkyTrady asked this question in Q&A
Discussion options

You must be logged in to vote

This's a fairly open-ended question but here's what I can tell you:

  1. statusline plugins are usually pretty optimized and shouldn't slowdown opening files
  2. adding the icon is pretty much replicating what a statusline plugin does but on a smaller scale

here're some examples if you want to get started:

  • Easiest, but has unnecessary updates :
vim.o.statusline = [[%<%f %{luaeval('require"nvim-web-devicons".get_icon_by_filetype(vim.bo.filetype)')}%h%m%r%=%-14.(%l,%c%V%) %P]]
  • Less updates, but slightly more complicated:
vim.api.nvim_create_autocmd("BufEnter", {
    callback = function ()
    vim.o.statusline =
    "%<%f "..
    require"nvim-web-devicons".get_icon_by_filetype(vim.bo.filetype)..

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by DinkyTrady
Comment options

You must be logged in to vote
1 reply
@T-727
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #163 on October 04, 2022 13:13.