mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-12-07 04:34:26 +08:00
Compare commits
3 Commits
master
...
cf0a7ec458
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf0a7ec458 | ||
|
|
f083d765d8 | ||
|
|
45b6334faf |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -11,7 +11,7 @@ on:
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
matrix:
|
||||
vim:
|
||||
|
||||
@@ -24,7 +24,6 @@ This is the Changelog for the vim-airline project.
|
||||
- coc extensions can also show additional status messages as well as the current function
|
||||
- [coc-git](https://github.com/neoclide/coc-git) extension integrated into hunks extension
|
||||
- rewrote parts using Vim9 Script for performance improvements
|
||||
- [vim-obsession](https://github.com/tpope/vim-obsession) allow to set paused indicator
|
||||
- Other
|
||||
- Changed CI from travis-ci.org to GitHub Actions
|
||||
- Introduce Vim script static analysis using [reviewdog](https://github.com/reviewdog/action-vint)
|
||||
|
||||
@@ -7,57 +7,30 @@ if !get(g:, 'loaded_fern', 0)
|
||||
finish
|
||||
endif
|
||||
|
||||
function! airline#extensions#fern#apply_active(...) abort
|
||||
" check if current buffer is both fern and active
|
||||
if (&ft =~# 'fern') && a:2.active ==# '1'
|
||||
call airline#extensions#fern#configure_sections(a:1, a:2)
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! airline#extensions#fern#apply_inactive(...) abort
|
||||
" check if referenced buffer is both fern and inactive
|
||||
if getbufvar(a:2.bufnr, '&filetype') ==# 'fern' && a:2.active ==# '0'
|
||||
call airline#extensions#fern#configure_sections(a:1, a:2)
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#fern#configure_sections(win, context) abort
|
||||
function! airline#extensions#fern#apply(...) abort
|
||||
if (&ft =~# 'fern')
|
||||
let spc = g:airline_symbols.space
|
||||
let fri = fern#fri#parse(bufname(a:context.bufnr))
|
||||
let abspath = ''
|
||||
" Replace uses fern-replacer filetype, do not try to parse in that case
|
||||
if &ft ==# 'fern' && fri.scheme ==# 'fern'
|
||||
let abspath = fern#fri#to#filepath(fern#fri#parse(fri.path))
|
||||
endif
|
||||
call a:win.add_section('airline_a', spc.'fern'.spc)
|
||||
let fri = fern#fri#parse(expand('%f'))
|
||||
|
||||
call a:1.add_section('airline_a', spc.'fern'.spc)
|
||||
if exists('*airline#extensions#branch#get_head')
|
||||
" because fern navigation changes an internal _fri_ and not the working directory
|
||||
" we need to give it some help so the branch name gets updated
|
||||
try
|
||||
if &ft ==# 'fern'
|
||||
execute 'lcd' fnameescape(abspath)
|
||||
endif
|
||||
catch /^Vim\%((\a\+)\)\=:E344:/
|
||||
call a:win.add_section('airline_b', '')
|
||||
endtry
|
||||
call a:win.add_section('airline_b', spc.'%{airline#extensions#branch#get_head()}'.spc)
|
||||
call a:1.add_section('airline_b', spc.'%{airline#extensions#branch#get_head()}'.spc)
|
||||
else
|
||||
call a:win.add_section('airline_b', '')
|
||||
call a:1.add_section('airline_b', '')
|
||||
endif
|
||||
if !(fri.authority =~# '^drawer')
|
||||
call a:win.add_section('airline_c', spc.fnamemodify(abspath, ':~'))
|
||||
call a:win.split()
|
||||
let abspath = substitute(fri.path, 'file://', '', '')
|
||||
call a:1.add_section('airline_c', spc.fnamemodify(abspath, ':~'))
|
||||
call a:1.split()
|
||||
if len(get(g:, 'fern#comparators', {}))
|
||||
call a:win.add_section('airline_y', spc.'%{fern#comparator}'.spc)
|
||||
call a:1.add_section('airline_y', spc.'%{fern#comparator}'.spc)
|
||||
endif
|
||||
endif
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#fern#init(ext) abort
|
||||
let g:fern_force_overwrite_statusline = 0
|
||||
call a:ext.add_statusline_func('airline#extensions#fern#apply_active')
|
||||
call a:ext.add_inactive_statusline_func('airline#extensions#fern#apply_inactive')
|
||||
call a:ext.add_statusline_func('airline#extensions#fern#apply')
|
||||
endfunction
|
||||
|
||||
@@ -47,7 +47,7 @@ endfunction
|
||||
|
||||
function! s:airline_nvimlsp_get_line_number(cnt, type) abort
|
||||
let severity = a:type == 'Warning' ? 'Warn' : a:type
|
||||
let num = v:lua.vim.diagnostic.get(0, { 'severity': severity })[0].lnum + 1
|
||||
let num = v:lua.vim.diagnostic.get(0, { 'severity': severity })[0].lnum
|
||||
|
||||
let l:open_lnum_symbol =
|
||||
\ get(g:, 'airline#extensions#nvimlsp#open_lnum_symbol', '(L')
|
||||
|
||||
@@ -14,14 +14,10 @@ if !exists('g:airline#extensions#obsession#indicator_text')
|
||||
let g:airline#extensions#obsession#indicator_text = '$'
|
||||
endif
|
||||
|
||||
if !exists('g:airline#extensions#obsession#indicator_text_paused')
|
||||
let g:airline#extensions#obsession#indicator_text_paused = '' " vim-obsession defaults to 'S'
|
||||
endif
|
||||
|
||||
function! airline#extensions#obsession#init(ext)
|
||||
call airline#parts#define_function('obsession', 'airline#extensions#obsession#get_status')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#obsession#get_status()
|
||||
return ObsessionStatus((g:airline#extensions#obsession#indicator_text . s:spc), (g:airline#extensions#obsession#indicator_text_paused . s:spc))
|
||||
return ObsessionStatus((g:airline#extensions#obsession#indicator_text . s:spc), '')
|
||||
endfunction
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:spc = g:airline_symbols.space
|
||||
|
||||
let s:current_bufnr = -1
|
||||
let s:current_tabnr = -1
|
||||
let s:current_modified = 0
|
||||
let s:current_tabline = ''
|
||||
let s:current_visible_buffers = []
|
||||
@@ -49,15 +49,14 @@ function! airline#extensions#tabline#buffers#invalidate()
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#buffers#get()
|
||||
let curbuf = bufnr('%')
|
||||
let curtab = tabpagenr()
|
||||
try
|
||||
call <sid>map_keys()
|
||||
catch
|
||||
" no-op
|
||||
endtry
|
||||
if curbuf == s:current_bufnr && curtab == s:current_tabnr && &columns == s:column_width
|
||||
if !g:airline_detect_modified || getbufvar(curbuf, '&modified') == s:current_modified
|
||||
let cur = bufnr('%')
|
||||
if cur == s:current_bufnr && &columns == s:column_width
|
||||
if !g:airline_detect_modified || getbufvar(cur, '&modified') == s:current_modified
|
||||
return s:current_tabline
|
||||
endif
|
||||
endif
|
||||
@@ -78,10 +77,10 @@ function! airline#extensions#tabline#buffers#get()
|
||||
let b.overflow_group = 'airline_tabhid'
|
||||
let b.buffers = airline#extensions#tabline#buflist#list()
|
||||
if get(g:, 'airline#extensions#tabline#current_first', 0)
|
||||
if index(b.buffers, curbuf) > -1
|
||||
call remove(b.buffers, index(b.buffers, curbuf))
|
||||
if index(b.buffers, cur) > -1
|
||||
call remove(b.buffers, index(b.buffers, cur))
|
||||
endif
|
||||
let b.buffers = [curbuf] + b.buffers
|
||||
let b.buffers = [cur] + b.buffers
|
||||
endif
|
||||
|
||||
function! b.get_group(i) dict
|
||||
@@ -130,7 +129,7 @@ function! airline#extensions#tabline#buffers#get()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let current_buffer = max([index(b.buffers, curbuf), 0])
|
||||
let current_buffer = max([index(b.buffers, cur), 0])
|
||||
let last_buffer = len(b.buffers) - 1
|
||||
call b.insert_titles(current_buffer, 0, last_buffer)
|
||||
|
||||
@@ -143,8 +142,7 @@ function! airline#extensions#tabline#buffers#get()
|
||||
|
||||
call airline#extensions#tabline#add_tab_label(b)
|
||||
|
||||
let s:current_bufnr = curbuf
|
||||
let s:current_tabnr = curtab
|
||||
let s:current_bufnr = cur
|
||||
let s:column_width = &columns
|
||||
let s:current_tabline = b.build()
|
||||
let s:current_visible_buffers = copy(b.buffers)
|
||||
|
||||
@@ -51,7 +51,6 @@ endfunction
|
||||
|
||||
function! s:conflict_marker()
|
||||
" Checks for git conflict markers
|
||||
" space required for jj conflict marker: #2727
|
||||
let annotation = '\%([0-9A-Za-z_.:]\+\)\?'
|
||||
if match(['rst', 'markdown', 'rmd'], &ft) >= 0
|
||||
" rst filetypes use '=======' as header
|
||||
|
||||
@@ -186,13 +186,6 @@ if !exists(":def") || !airline#util#has_vim9_script()
|
||||
call <sid>exec_separator({}, a:from, a:to, a:inverse, '')
|
||||
endfunction
|
||||
|
||||
function! airline#highlighter#remove_separators_for_bufnr(bufnr) abort
|
||||
" remove all separators, that have the buffer number in their name,
|
||||
" but do not be too greedy!
|
||||
let pat = 'c' . a:bufnr . '\(\D\|$\)'
|
||||
call filter(s:separators, 'v:key !~# pat')
|
||||
endfunction
|
||||
|
||||
function! s:exec_separator(dict, from, to, inverse, suffix) abort
|
||||
if pumvisible()
|
||||
return
|
||||
@@ -536,13 +529,6 @@ else
|
||||
s:exec_separator({}, from, to, inverse, '')
|
||||
enddef
|
||||
|
||||
def airline#highlighter#remove_separators_for_bufnr(bufnr: string): void
|
||||
# remove all separators, that have the bufnr in its name, make sure we
|
||||
# have a full match here
|
||||
const pat = $'c{bufnr}\(\D\|$\)'
|
||||
filter(s:separators, (k, v) => k !~# pat)
|
||||
enddef
|
||||
|
||||
def s:exec_separator(dict: dict<any>, from_arg: string, to_arg: string, inverse: bool, suffix: string): void
|
||||
if pumvisible()
|
||||
return
|
||||
|
||||
@@ -129,21 +129,15 @@ function! airline#init#bootstrap()
|
||||
call extend(g:airline_symbols, {
|
||||
\ 'readonly': "\ue0a2",
|
||||
\ 'whitespace': "\u2632",
|
||||
\ 'maxlinenr': "\u2261 ",
|
||||
\ 'maxlinenr': "\u2630 ",
|
||||
\ 'linenr': " \ue0a1:",
|
||||
\ 'colnr': " \u2105:",
|
||||
\ 'branch': "\ue0a0",
|
||||
\ 'notexists': "\u0246",
|
||||
\ 'dirty': "\u26a1",
|
||||
\ 'crypt': nr2char(0x1F512),
|
||||
\ 'executable': "\u2699",
|
||||
\ }, 'keep')
|
||||
" Note: If "\u2046" (Ɇ) does not show up, try to use "\u2204" (∄)
|
||||
if exists("*setcellwidths")
|
||||
" whitespace char 0x2632 changed to double-width in Unicode 16,
|
||||
" mark it single width again
|
||||
call setcellwidths([[0x2632, 0x2632, 1]])
|
||||
endif
|
||||
elseif &encoding==?'utf-8' && !get(g:, "airline_symbols_ascii", 0)
|
||||
" Symbols for Unicode terminals
|
||||
call s:check_defined('g:airline_left_sep', "")
|
||||
@@ -154,14 +148,13 @@ function! airline#init#bootstrap()
|
||||
call extend(g:airline_symbols, {
|
||||
\ 'readonly': "\u229D",
|
||||
\ 'whitespace': "\u2632",
|
||||
\ 'maxlinenr': "\u2261",
|
||||
\ 'maxlinenr': "\u2630",
|
||||
\ 'linenr': " \u33d1:",
|
||||
\ 'colnr': " \u2105:",
|
||||
\ 'branch': "\u16A0",
|
||||
\ 'notexists': "\u0246",
|
||||
\ 'crypt': nr2char(0x1F512),
|
||||
\ 'dirty': '!',
|
||||
\ 'executable': "\u2699",
|
||||
\ }, 'keep')
|
||||
else
|
||||
" Symbols for ASCII terminals
|
||||
@@ -179,7 +172,6 @@ function! airline#init#bootstrap()
|
||||
\ 'notexists': '?',
|
||||
\ 'crypt': 'cr',
|
||||
\ 'dirty': '!',
|
||||
\ 'executable': 'x',
|
||||
\ }, 'keep')
|
||||
endif
|
||||
|
||||
@@ -192,7 +184,6 @@ function! airline#init#bootstrap()
|
||||
call airline#parts#define_function('crypt', 'airline#parts#crypt')
|
||||
call airline#parts#define_function('spell', 'airline#parts#spell')
|
||||
call airline#parts#define_function('filetype', 'airline#parts#filetype')
|
||||
call airline#parts#define_function('executable', 'airline#parts#executable')
|
||||
call airline#parts#define('readonly', {
|
||||
\ 'function': 'airline#parts#readonly',
|
||||
\ 'accent': 'red',
|
||||
@@ -204,7 +195,7 @@ function! airline#init#bootstrap()
|
||||
endif
|
||||
call airline#parts#define_raw('path', '%F%m')
|
||||
call airline#parts#define('linenr', {
|
||||
\ 'raw': '%{g:airline_symbols.linenr}%2l',
|
||||
\ 'raw': '%{g:airline_symbols.linenr}%l',
|
||||
\ 'accent': 'bold'})
|
||||
call airline#parts#define('maxlinenr', {
|
||||
\ 'raw': '/%L%{g:airline_symbols.maxlinenr}',
|
||||
@@ -257,7 +248,7 @@ endfunction
|
||||
function! airline#init#sections()
|
||||
let spc = g:airline_symbols.space
|
||||
if !exists('g:airline_section_a')
|
||||
let g:airline_section_a = airline#section#create_left(['mode', 'crypt', 'paste', 'keymap', 'spell', 'capslock', 'xkblayout', 'iminsert', 'executable'])
|
||||
let g:airline_section_a = airline#section#create_left(['mode', 'crypt', 'paste', 'keymap', 'spell', 'capslock', 'xkblayout', 'iminsert'])
|
||||
endif
|
||||
if !exists('g:airline_section_b')
|
||||
if airline#util#winwidth() > 99
|
||||
|
||||
@@ -206,11 +206,3 @@ function! airline#parts#ffenc()
|
||||
return &fenc.bomb.noeolf.ff
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#parts#executable()
|
||||
if exists("*getfperm") && getfperm(bufname('%')) =~ 'x'
|
||||
return g:airline_symbols.executable
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -374,7 +374,6 @@ its contents. >
|
||||
let g:airline_symbols.colnr = ' ㏇:'
|
||||
let g:airline_symbols.colnr = ' ℅:'
|
||||
let g:airline_symbols.crypt = '🔒'
|
||||
let g:airline_symbols.executable = '⚙'
|
||||
let g:airline_symbols.linenr = '☰'
|
||||
let g:airline_symbols.linenr = ' ␊:'
|
||||
let g:airline_symbols.linenr = ' :'
|
||||
@@ -428,7 +427,7 @@ window.
|
||||
>
|
||||
variable names default contents
|
||||
---------------------------------------------------------------------------
|
||||
let g:airline_section_a (mode, crypt, paste, spell, iminsert, executable)
|
||||
let g:airline_section_a (mode, crypt, paste, spell, iminsert)
|
||||
let g:airline_section_b (hunks, branch)[*]
|
||||
let g:airline_section_c (bufferline or filename, readonly)
|
||||
let g:airline_section_gutter (csv)
|
||||
@@ -999,11 +998,8 @@ vim-obsession <https://github.com/tpope/vim-obsession>
|
||||
* enable/disable vim-obsession integration >
|
||||
let g:airline#extensions#obsession#enabled = 1
|
||||
|
||||
* set marked window indicator string when recording session>
|
||||
* set marked window indicator string >
|
||||
let g:airline#extensions#obsession#indicator_text = '$'
|
||||
|
||||
* set marked window indicator string when recording session is paused>
|
||||
let g:airline#extensions#obsession#indicator_text_paused = ''
|
||||
<
|
||||
------------------------------------- *airline-omnisharp*
|
||||
OmniSharp <https://github.com/OmniSharp/omnisharp-vim>
|
||||
@@ -1211,7 +1207,7 @@ Note: Not displayed if the number of tabs is less than 1
|
||||
In default mode, when the variable is 1 Up to 10 mappings will be
|
||||
exposed. Note: As 10 and 1 have same prefix, we use 0 to replace 10. So,
|
||||
<leader>0 will jump to tenth buffer. Those mappings are not automatically
|
||||
created, vim-airline just exposes those `<Plug>AirlineSelectTab` keys
|
||||
created, vim-airline just exposes those `<Plug>AirlineSeelctTab` keys
|
||||
for you to map to a convenient key >
|
||||
|
||||
let g:airline#extensions#tabline#buffer_idx_mode = 1
|
||||
@@ -1922,7 +1918,6 @@ The following list of parts are predefined by vim-airline.
|
||||
* `iminsert` displays the current insert method
|
||||
* `paste` displays the paste indicator
|
||||
* `crypt` displays the crypted indicator
|
||||
* `exectuable` displays the executable indicator
|
||||
* `spell` displays the spell indicator
|
||||
* `filetype` displays the file type
|
||||
* `readonly` displays the read only indicator
|
||||
|
||||
@@ -48,7 +48,6 @@ function! s:init()
|
||||
endfunction
|
||||
|
||||
let s:active_winnr = -1
|
||||
|
||||
function! s:on_window_changed(event)
|
||||
" don't trigger for Vim popup windows
|
||||
if &buftype is# 'popup'
|
||||
@@ -68,20 +67,11 @@ function! s:on_window_changed(event)
|
||||
\ && &ft !~? 'gitcommit'
|
||||
" fugitive is special, it changes names and filetypes several times,
|
||||
" make sure the caching does not get into its way
|
||||
if a:event ==# 'BufUnload'
|
||||
" in the BufUnload event, make sure the cacheing does not prevent
|
||||
" removing stale entries
|
||||
call airline#highlighter#remove_separators_for_bufnr(expand('<abuf>'))
|
||||
endif
|
||||
return
|
||||
endif
|
||||
let g:airline_last_window_changed = l:key
|
||||
call s:init()
|
||||
call airline#update_statusline()
|
||||
|
||||
if a:event ==# 'BufUnload'
|
||||
call airline#highlighter#remove_separators_for_bufnr(expand('<abuf>'))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:on_focus_gained()
|
||||
|
||||
17
test/extensions_branch.vimspec
Normal file
17
test/extensions_branch.vimspec
Normal file
@@ -0,0 +1,17 @@
|
||||
Describe branch.vim
|
||||
Before
|
||||
call mkdir("branch-test")
|
||||
:lcd branch-test
|
||||
!git init
|
||||
End
|
||||
|
||||
It Match branch name main
|
||||
Assert Equals(airline#extensions#branch#get_head(), "main")
|
||||
End
|
||||
|
||||
After
|
||||
call delete("branch-test", "rf")
|
||||
:lcd ..
|
||||
End
|
||||
End
|
||||
|
||||
@@ -47,7 +47,7 @@ Describe init.vim
|
||||
|
||||
It section z should be line numbers
|
||||
Assert Match(g:airline_section_z, '%p%%')
|
||||
Assert Match(g:airline_section_z, '%2l')
|
||||
Assert Match(g:airline_section_z, '%l')
|
||||
Assert Match(g:airline_section_z, '%v')
|
||||
End
|
||||
|
||||
|
||||
Reference in New Issue
Block a user