mirror of
https://github.com/vim-airline/vim-airline.git
synced 2026-03-13 10:20:39 +08:00
extensions: Add a nerdfont.vim extension (#2741)
Some checks failed
CI / Test (v7.4) (push) Has been cancelled
CI / Test (v8.0.0000) (push) Has been cancelled
CI / Test (v8.1.0000) (push) Has been cancelled
CI / Test (v8.2.0000) (push) Has been cancelled
CI / Test (v8.2.1000) (push) Has been cancelled
CI / Test (v9.0.0000) (push) Has been cancelled
CI / Test (v9.1.0000) (push) Has been cancelled
reviewdog / runner / vint (push) Has been cancelled
Some checks failed
CI / Test (v7.4) (push) Has been cancelled
CI / Test (v8.0.0000) (push) Has been cancelled
CI / Test (v8.1.0000) (push) Has been cancelled
CI / Test (v8.2.0000) (push) Has been cancelled
CI / Test (v8.2.1000) (push) Has been cancelled
CI / Test (v9.0.0000) (push) Has been cancelled
CI / Test (v9.1.0000) (push) Has been cancelled
reviewdog / runner / vint (push) Has been cancelled
This commit is contained in:
@@ -177,6 +177,11 @@ function! airline#extensions#load()
|
||||
call add(s:loaded_ext, 'netrw')
|
||||
endif
|
||||
|
||||
if get(g:, 'loaded_nerdfont', 0) && get(g:, 'airline#extensions#nerdfont#enabled', 1)
|
||||
call airline#extensions#nerdfont#init(s:ext)
|
||||
call add(s:loaded_ext, 'nerdfont')
|
||||
endif
|
||||
|
||||
" fzf buffers are also terminal buffers, so this must be above term.
|
||||
if exists(':FZF') && get(g:, 'airline#extensions#fzf#enabled', 1)
|
||||
call airline#extensions#fzf#init(s:ext)
|
||||
|
||||
46
autoload/airline/extensions/nerdfont.vim
Normal file
46
autoload/airline/extensions/nerdfont.vim
Normal file
@@ -0,0 +1,46 @@
|
||||
" MIT License. Copyright (c) 2026-2026 Wu Zhenyu et al
|
||||
" Plugin: https://github.com/lambdalisue/nerdfont.vim
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
if !get(g:, 'loaded_nerdfont', 0)
|
||||
finish
|
||||
endif
|
||||
|
||||
function! airline#extensions#nerdfont#fileformat() abort
|
||||
if &fileformat ==# 'dos'
|
||||
return nerdfont#platform#find('windows')
|
||||
endif
|
||||
if &fileformat ==# 'mac'
|
||||
return nerdfont#platform#find('macos')
|
||||
endif
|
||||
if &fileformat ==# 'unix'
|
||||
if has('unix')
|
||||
return nerdfont#platform#find()
|
||||
else
|
||||
return nerdfont#platform#find('linux')
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#nerdfont#ffenc() abort
|
||||
let expected = get(g:, 'airline#parts#ffenc#skip_expected_string', '')
|
||||
let bomb = &bomb ? '[BOM]' : ''
|
||||
let noeolf = &eol ? '' : '[!EOL]'
|
||||
let ff = strlen(&ff) ? '['.&ff.']' : ''
|
||||
if expected is# &fenc.bomb.noeolf.ff
|
||||
return ''
|
||||
else
|
||||
return &fenc.bomb.noeolf.' '.airline#extensions#nerdfont#fileformat()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#nerdfont#init(ext) abort
|
||||
call airline#parts#define_function('ffenc', 'airline#extensions#nerdfont#ffenc')
|
||||
call a:ext.add_statusline_func('airline#extensions#nerdfont#apply')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#nerdfont#apply(...) abort
|
||||
call airline#extensions#append_to_section('x', ' %{nerdfont#find()}')
|
||||
endfunction
|
||||
@@ -0,0 +1,7 @@
|
||||
let g:airline#extensions#tabline#formatters#nerdfont#formatter = get(g:, 'airline#extensions#tabline#formatters#nerdfont#formatter', 'default')
|
||||
|
||||
function! airline#extensions#tabline#formatters#nerdfont#format(bufnr, buffers) abort
|
||||
" Call original formatter.
|
||||
let originalFormatter = airline#extensions#tabline#formatters#{g:airline#extensions#tabline#formatters#nerdfont#formatter}#format(a:bufnr, a:buffers)
|
||||
return originalFormatter . printf(' %s', nerdfont#find(bufname(a:bufnr)))
|
||||
endfunction
|
||||
@@ -955,6 +955,18 @@ neomake <https://github.com/neomake/neomake>
|
||||
* neomake warning >
|
||||
let g:airline#extensions#neomake#warning_symbol = 'W:'
|
||||
<
|
||||
------------------------------------- *airline-nerdfont*
|
||||
NerdFont <https://github.com/lambdalisue/nerdfont.vim>
|
||||
|
||||
* enable/disable nerdfont integration >
|
||||
let g:airline#extensions#nerdfont#enabled = 1
|
||||
< default: 1
|
||||
|
||||
* nerdfont's tabline formatter >
|
||||
let g:airline#extensions#tabline#formatter = 'nerdfont'
|
||||
let g:airline#extensions#tabline#formatters#nerdfont#formatter = 'default'
|
||||
< default: 'default'
|
||||
|
||||
------------------------------------- *airline-nerdtree*
|
||||
NerdTree <https://github.com/preservim/nerdtree.git>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user