Explicitly hide default icon so third-party icon plugins work right

This commit is contained in:
Danielle McLean 2023-10-23 13:50:24 +11:00
parent 1b0937ee8e
commit 4c4116c6af
Signed by: 00dani
GPG key ID: 52C059C3B22A753E

View file

@ -2,6 +2,13 @@ vim9script
import autoload ($XDG_CACHE_HOME .. '/vim/pack/minpac/start/vim-crystalline/autoload/crystalline.vim') as cr import autoload ($XDG_CACHE_HOME .. '/vim/pack/minpac/start/vim-crystalline/autoload/crystalline.vim') as cr
def DropIfDefault(status: string, default: string): string
if status == default
return ''
endif
return status
enddef
def PrependIfVisible(status: string, prefix: string): string def PrependIfVisible(status: string, prefix: string): string
if empty(status) if empty(status)
return '' return ''
@ -41,7 +48,7 @@ def StatuslineLeft(window: number, inactive: bool): string
const bufnr = window->winbufnr() const bufnr = window->winbufnr()
const b = bufnr->getbufvar('&') const b = bufnr->getbufvar('&')
const fileName = [ const fileName = [
bufname(bufnr)->g:nerdfont#find()->AppendIfVisible(' '), bufname(bufnr)->g:nerdfont#find()->DropIfDefault(g:nerdfont#default)->AppendIfVisible(' '),
b.buftype == '' ? '%t' : '%f', b.buftype == '' ? '%t' : '%f',
b.modifiable && b.modified ? cr.ModeHiItem('Modified') .. '+' .. cr.ModeHiItem('Fill') : '', b.modifiable && b.modified ? cr.ModeHiItem('Modified') .. '+' .. cr.ModeHiItem('Fill') : '',
b.readonly ? " \uf023" : '', # nf-fa-lock b.readonly ? " \uf023" : '', # nf-fa-lock
@ -78,7 +85,6 @@ enddef
def ConfigurePlugins(): void def ConfigurePlugins(): void
g:battery#component_format = '%s %v%%' g:battery#component_format = '%s %v%%'
g:nerdfont#default = ''
g:crystalline_theme = 'gruvbox8' g:crystalline_theme = 'gruvbox8'
enddef enddef
@ -107,12 +113,13 @@ def InitTab()
width += 2 width += 2
endif endif
const icon = bufname(bufnr)->g:nerdfont#find()->PrependIfVisible(' ') const icon = bufname(bufnr)->g:nerdfont#find()->DropIfDefault(g:nerdfont#default)->PrependIfVisible(' ')
if width + strchars(icon) >= maxWidth const iconWidth = strchars(icon)
if width + iconWidth >= maxWidth
return [tabDisplay, width] return [tabDisplay, width]
endif endif
return [icon .. tabDisplay, width + strchars(icon)] return [icon .. tabDisplay, width + iconWidth]
enddef enddef
enddef enddef