Essentially what i'm trying to do is replace the 'tabnum' with the appropriate devicon. I found a couple functions on the vim-devicons site for lightline and the statusbar as shown below for file type and file format
let g:lightline = {
\ 'component_function': {
\ 'filetype': 'MyFiletype',
\ 'fileformat': 'MyFileformat',
\ }
\ }
function! MyFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype . ' ' . WebDevIconsGetFileTypeSymbol() : 'no ft') : ''
endfunction
function! MyFileformat()
return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
endfunction
So I tried essentially wrapping the MyFiletype function with the WebDevIconsGetFileTypeSymbol() function but that didnt work. I also tried just putting WebDevIconsGetFileTypeSymbol in the tabnum field of my formatting as shown here:
let g:lightline = {
\ 'colorscheme': 'deus',
\ 'component_function': {
\ 'filetype': 'MyFiletype',
\ 'fileformat': 'MyFileformat',
\ },
\ 'tab_component_function': {
\ 'tabnum': 'WebDevIconsGetFileTypeSymbol',
\ }
\ }
This is returning just the default devicon value and not the document value, however when i echo it in command mode it's fine and also the above function for the statusline also works. So I'm just a bit confused. Sorry about my limited knowledge here.
It may help looking into how this is implemented:
https://github.com/mengelbrecht/lightline-bufferline#glightlinebufferlineenable_devicons
The tab_component_function are evaluated with tab number argument while WebDevIconsGetFileTypeSymbol takes the filename. I don't have the fonts installed but try following sample.
let g:lightline = {
\ 'tab_component_function': {
\ 'tabnum': 'LightlineWebDevIcons',
\ },
\ }
function! LightlineWebDevIcons(n)
let l:bufnr = tabpagebuflist(a:n)[tabpagewinnr(a:n) - 1]
return WebDevIconsGetFileTypeSymbol(bufname(l:bufnr))
endfunction
The
tab_component_functionare evaluated with tab number argument whileWebDevIconsGetFileTypeSymboltakes the filename. I don't have the fonts installed but try following sample.let g:lightline = { \ 'tab_component_function': { \ 'tabnum': 'LightlineWebDevIcons', \ }, \ } function! LightlineWebDevIcons(n) let l:bufnr = tabpagebuflist(a:n)[tabpagewinnr(a:n) - 1] return WebDevIconsGetFileTypeSymbol(bufname(l:bufnr)) endfunction
This worked perfectly, thank you so much! Also thanks to @polyzen for pointing me in the right direction with that other project, I think I might have been able to get that working :)
Here's how it looks now: https://i.imgur.com/YQmbk2L.png
Most helpful comment
The
tab_component_functionare evaluated with tab number argument whileWebDevIconsGetFileTypeSymboltakes the filename. I don't have the fonts installed but try following sample.