workaround with index(term_list(), bufnr('')) > -1 not needed anymore,
since vim 8.0.936 will correctly return 't' for the mode() function in
the terminal.
This enables the highlighting caching only when the variable
g:airline_highlighting_cache is set to 1
Should make airline faster and more performant, because we can save a
lot of expensive C core calls. However, when redefining highlighting
groups, it might not correctly reset the cache.
do not access get() function twice. We can assign the result to a
variable and use it a second time. Should speed up the highligther part
of the code by a bit.
Since I was already touching s:Get(), also get rid of the default
parameter, as it always has been the empty string.
Currently this is a hack, to get terminal mode from Vim.
However there is no better solution yet, since the API is not stable
here. Until then, just use the hack with
index(term_list(), bufnr('')) > -1
When using vim-gitgutter and fugitive:
The hunks extension and the branch extension work as expected when the
file is first loaded; both parts are added to the statusline.
Once the cursor is moved and stopped for &updatetime ms:
1. The branch extension clears b:airline_head on CursorHold
2. Somehow (?) airline#statusline gets called on CursorHold
3. The hunks extension returns '' when b:airline_head is empty, causing
the hunks to be removed from the statusline.
It doesn't make sense to clear airline_head just because the cursor
moved, and the commit message adding the line doesn't say why:
13297cee03
Commit 174b7e1962 relies on airline_head
being set.
Debug detail:
Executing CursorHold Auto commands for "*"
autocommand unlet! b:airline_head
[...]
continuing in CursorHold Auto commands for "*"
calling function airline#statusline(1)
[...]
line 1: return exists('*airline#extensions#branch#head') && empty(get(b:, 'airline_head', ''))
function airline#extensions#hunks#get_hunks[13]..<SNR>32_get_hunks[14]..<SNR>32_get_hunks_gitgutter[1]..<SNR>32_is_branch_empty returning #1
function airline#extensions#hunks#get_hunks[13]..<SNR>32_get_hunks[14]..<SNR>32_get_hunks_gitgutter returning ''
function airline#extensions#hunks#get_hunks[13]..<SNR>32_get_hunks returning ''
function airline#extensions#hunks#get_hunks returning ''
:au CursorHold
--- Auto-Commands ---
gitgutter CursorHold
* call gitgutter#process_buffer(bufnr(''), 1)
CursorHold
* unlet! b:airline_head
airline_whitespace CursorHold
* call <sid>ws_refresh()
------------------------
Sample vimrc:
set nocompatible
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | q | doautocmd WinEnter
endif
autocmd VimEnter *
\ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | q
\| endif
call plug#begin('~/.vim/bundle/')
Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
call plug#end()
set laststatus=2
set updatetime=250
let g:airline_theme = 'dark'
Commmit a10d321809 introduced a small typo
spelling a previously set variable `trailing_fmt` as `trailing_fm`. This
causes Vim to report `trailing_fm` as an undefined variable. In this
change, the variable is properly referenced as `trailing_fmt`.
calling settabvar() while evaluating the 'tabline' setting apparently
causes flicker on Windows. Fall back to using `:let t:var` to store the
content in the current tabpage.
This is not as good as using `settabvar()` since we cannot store the
title for other tabs, but at least it should prevent the flicker and at
the same time at least cache the title for the current tabpage.
do not call airline#extensions#branch#head() but instead use the cached
variable b:airline_head.
Note: it looks like GitGutterGetHunkSummary() could need some cacheing
The comparison in airline#highlighter#exec() was there to prevent to
call out to too many :hi calls by making sure that the newly to be
defined highlighting group will be actually different from the current
existing one.
However, that did not work, as the returned old highlight
group did never match the newly to be created one, since it
intentionally left the cterm attributes out for the gui and the gui
attributes for the terminal.
Therefore, fix the comparasion and make it compare the actual values
that we have.
This should make vim-airline a bit faster (hopefully!)
Currently, vim-airline will check untracked status for files e.g. living
in .git. So when editing .git/config it will show as being untracked.
While technically, this is correct I prefer not to see this for those
files. So skip the check for those files.
if airline is initialized too early and some :hi commands are run,
this will force a redraw in Vim which will result in the intro screen
being cleared.
Currently, this does not work for gvim, not sure why.
closes#1476 (well only partly, until i have discovered, why for gvim it
doesn't work).
previously we only checked, that the group exists, however
if loading a new color scheme, this might lead to the group becoming
cleared. That means it still exists, but the highlighting group would
not show anything. Therefore, also check that the group is not cleared.
closes#1483
Currently the syntastic results are simply dumped into the error
section, however syntastic does internally distinguish between error and
warning sections.
Therefore change the syntastic extension to dump errors into the error
section and warnings into the warning section.
closes#1480
If a file is edited inside a git repository, which lies within a git
repository, the branch extensions shows 'gitmaster | hgdefault'
To make it more obvious, that we are looking into both repositories
here, use 'git:master | hg:default'
closes#1482
vim-airline does use a different section (path/file) depending on
whether 'acd' is set. Later in the bufferline extesion however, it
unconditionally overwrites the 'file' section, regardless of whether
this section is actually used.
Therefore the bufferline section needs to check this option as well.
fixes#1487
This should not happen, however being a bit more error tolerant
shouldn't hurt, so let's just fall back to 'normal' for the
g:netrw_sort_direction in case it is not defined (which should be the
default anyhow).
fixes#1492
Indicates:
- whether the file is considered to be main or local
- whether the viewer is opened
- whether the compilation is running
- whether the compilation is continuous
Added:
* `vimtex` existence check
* variables documentation
TODO: readme and a screenshot
Update readme.md
Update doc
Update screenshot url
The denite extension functions return the content of some buffer-local
variables. Those variables are not defined, the first time the they are
accessed and therefore, the statusline is not updated later when
g:airline_skip_empty_sections is set.
So disable this variable in this window, by setting the
w:airline_skip_empty_section=0 variable in the denite window.
closes#1454
Basically what the title says. First check if the user has Powerline,
fall back to Unicode symbols if he doesn't and fall back to ASCII
symbols if he doesn't have that either.
Vim-airline is not a looker without a Powerline font. This fixes that!
* Ugly separator symbols are hidden
* New branch (ᚠ), line (㏑), maxline (☰) and whitespace (☲) symbols
* Replace old whitespace (✹) symbol in Powerline with the new (☲) more logical one
previously, it could have been skipped, if the old highlighting
attribute was the same as the current one. However, if the group does
not exist, it should still be defined
closes#1404
If a color value of ['', '', 'NONE', 'NONE', ''] is given as value to
the highlighting group, the resulting group definition would look like
this:
hi Normal ctermfg=NONE ctermbg=NONE
which would result in the highlighting group being cleared (or even no
set at all), therefore check that at least one other value exists and if
not fall back to the highlighting definition of the Normal group.
Line numbers are now displayed before the error, instead of after, preventing truncation (and thus making the whitespace/indent section essentially useless in smaller terminals)
This was used as a workaround to fix a highlighting bug, which was fixed
in Vim 7.4.1511 and therefore, we need to correctly detect that the
patch was applied and in that case skip adding those extra groups.
As a bonus, when not using those empty %( %) groups, the
skip_empty_section test will correctly handle this and therefore this
closes#1351
This is no explicit problem in Vim, however Neovim diverged in this
behaviour from Vim and requires the dict attribute to be present before
accessing the self attribute.
See neovim/neovim#5763
Adding an option to prevent windows from being closed when a buffer in
the tabline is middle clicked and the clicked buffer is currently open
in a window.
When this option is enabled, instead of closing the window a new buffer
will be opened in all of the windows editing the clicked buffer instead.
This is my first pull request AND my first experience with vimscript, so
my apologies if this is a bit sloppy 😄
This seems to be an omission/regression from #afb75adc, where inactive
highlight updating was accidentally removed when fixing another bug.
Solution: Add back the deleted statement. closes#1339
Repro steps:
1. Install some theme that depends on the background color
(Soares/base16.nvim has a bunch)
2. `set background=dark` in your vimrc, and `colorscheme` one of the
aforementioned schemes.
3. Open a split window. Note the colors on the inactive window's airline.
4. `set background=light` manually. note the colors on the inactive
window's airline. Note how they have not updated. (In particular,
airline_c_inactive has updated, but all the other inactive groups
have not.)
5. Enter the inactive window. Exit the inactive window. Observe that the
colors are now correct (showing that it is in fact a problem with the
airline load_theme code, and not with the theme).
It seems strange that the code as written only expects
airline_c_inactive to have styling; perhaps there is some norm that
themes are supposed to handle inactive windows in a particular way? For
the record, my theme dis omething like this:
```
let s:IA1 = s:airlist('similar1', 'similar2')
let s:IA2 = s:airlist('similar1', 'similar2')
let s:IA3 = s:airlist('similar1', 'similar2')
let g:airline#themes#{s:palette}#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3)
let g:airline#themes#{s:palette}#palette.inactive.airline_warning = s:airlist('base', 'contrast3')
let g:airline#themes#{s:palette}#palette.inactive.airline_error = s:airlist('base', 'antibase')
```
airline#extensions#tabline#excludes and
airline#extensions#tabline#exclude_preview previously had no impact if
changed after vim load. This fixes that.
Currently vim-airline assumes, that the git_dir is part of the path for
the file being edited. This has changed, since git supports worktrees.
So take care of b:git_dir (which is set by fugitive) being a path
differently from the absolute path of the file being edited (however, it
should include the substring worktree in that case).
A typical status line for a 'po' (Portable Object) translation file is:
1152 translated messages, 91 fuzzy translations, 42 untranslated messages.
Adding a substitute(), tidies this to:
1152 translated, 91 fuzzy, 42 untranslated
which is still informative, but less verbose.
airline#system#util for nvim used to fall back to 'system' implementation on
command error. This behavior caused conflict with other plugins if 'util' was
executed with a failing command as part of a ShellCmdPost event.
This commit makes 'util' interpret command error as persistent and not call
'system' in such a case.
This commit fixes#1317.
Since Vim8 we have win_getid() and getwininfo() functions to get
information about the current window. So we can use those functions to
find out, whether the current window is a quickfix or location list
window.
This avoids using a redir() over the :ls command and trying to
manually match the string quickfix and should be faster and also be more
robust, as the redir may fail if done recursively.
fixes#1319
This commit makes branch.vim use neovim's async jobs instead of a system()
function. This way we avoid the v:shell_error overwrite bug and allow live
updates of the untracked status.
* The head string is now calculated iff it has changed.
* The not exists symbol for current file appears as soon as its status is known.
* Fixes various problems with asynchronous status checking, such as:
* The not exists symbol keeps appearing and disapearing. This happened when
file was marked as not existing, the untracked cache was invalidated, and
the cache update is started, but in the meantime, the head string
calculation used the current (empty) value of the cache.
* The not exists symbol never appears, because cache keeps getting invalidated
before b:airline_head is emptied and updated.
closes#1306
* Introduce a config variable that holds the vcs-dependent parts of code.
* Removes `get_*_untracked` duplication by merging their logic together.
* Removes custom checks for 'git' or 'hg'. Functions now rely on provided config
argument.
* Use loops instead of manually specifying each handled VCS.
closes#1303
This commit fixes a bug, where untracked files in Git repos did not get the not
exists symbol displayed. The fix works by replacing the previous check for
whether currently edited file is a directory or not with a check based on
`findfile`. More detailed explanation follows.
VCS extension to vim-airline checks whether currently edited file is untracked.
The previous `s:get_git_untracked` implementation, which was used for the
aforementioned purpose for Git repos, was buggy, because it did not return the
untracked symbol in most situations, i.e. the edited file is untracked, but it
was treated as if it wasn't.
The root cause was the second clause in boolean expression checking the output
of `git status`:
if output[0:1] is# '??' && output[3:-2] is? a:file
It was added to make sure we are not checking a directory, but at this point in
the program `a:file` is an absolute path, while output of `git status` is a
relative path from the root of git repo. So the `is?` expression failed in most
situations.
These are forks/alternate versions of Solarized, without many of the
dynamic elements or the extensive terminal support.
[flattened](https://github.com/romainl/flattened) is a basic, totally
static version of Solarized with only ansi and GUI support.
[NeoSolarized](https://github.com/iCyMind/NeoSolarized) is a version
focusing on true/24-bit color support and NeoVim support, with limited
dynamic options.
[solarized8](https://github.com/lifepillar/vim-solarized8) is a version
focusing on vim/neovim true color support and limited dynamics. It is
already supported (`match()` matches it), but it is at least worth
noting.
Many users, including myself, use these themes over the original
Solarized for performance or technical reasons. Many users believe they
are incompatible with airline because automatic theming no longer
functions. While they can manually override the theme, most people seem
to miss this option in the documentation and give up.
It would be a nice quality of live improvement if airline detected these
themes and enabled its own Solarized theme automatically to match.
This makes it so if the whitespace symbol (g:airline#extensions#whitespace#symbol) is an empty string, we don't end up wth two characters at the beginning of the message.
commit #3d667c32d3ac04 fixed a bug, that a section was not considered
empty for the statusline, also g:airline_skip_empty was set.
However unfortunately, this lead to a regression, makeing the tabline
ugly, because sections, that contained a single highlighting group would
be considered empty and would therefore be skipped. Since this is not
what is expected, make s:section_is_empty() return zero, when it notices
we are looking at a tabline.
fixes#1273
airline_c (which contains the filename) usually is used together with
the buffer number, so that several windows showing the a different
buffer do not share the same highlighting group.
This was fixed in 73aea86a, but unfortunately it was forgotten to not
only add this to the current group, but also modify the previous group
accordingly. This is what this patch does.
fixes#1268
consider a window with these splits:
,----
| file1
| ---
| file2
| ---
| file1
`----
If the top buffer is the active one and you start modifying this buffer,
this will also reset the highlighting for the inactive buffer2, since
the highlighting group 'airline_c_inactive' is used for both windows
(one having the unmodified buffer 'file2' and one having the modified
'file1').
This lead to the incorrect highlighting of the buffer name of file2.
Airline basically already created different airline_c<bufnr>_inactive
highlighting groups, but unfortunately did not use them.
Therefore, make the builder aware of this and always append the buffer
number to the group 'airline_c' if it is in an inactive window.
2) we need to make sure, the highlighting won't get overwritten, so
make the highlighter aware of this situation as well, by appending the
buffer number to the group name, if it creates the 'inactive' mode
groups and a buffer number has been given.
this fixes#1233
Using let g:airline_section_y = airline#section#create_right(['ffenc','%{strftime("%H:%M")}'])
will result in an output string of `utf-8[unix] < < 00:00`
This happens, because the function util#prepend() will eventually add an
extra separator, if the width is zero. Therefore, when building the
string, remember, if the last section added an extra separator and only
add one, if there hasn't been added one before.
fixes#1220
If active buffer is modified, `:AirlineRefresh` apply `normal` highlight
instead of `normal_modified` highlight.
No particular config is requiered to reproduce this bug.
I see this bug with option `g:airline_skip_empty_sections` set.
Add any modification at the active buffer return to normal mode,
**do not save** and wait a few seconds, you can see highlight change to
normal but file is modified.
Without option `g:airline_skip_empty_sections`, add any modification at
the active buffer return to normal mode and type `:AirlineRefresh` you
can see change to bad highlight .
Cache the hunk values. In case of short windows, shorten the hunk string
a little bit and make the branch extension take the hunk value into
account when deciding how much to shorten it.
Sometimes, if a buffer triggers many whitespace check warnings,
and the Vim window size is too small, other parts of the statusline
might become unreadable.
Therefore, if the window size is smaller than say 120 characters
and the whitespace warning > 9 chars, limit it to 10 characters
and inidicate, that there is more to come
fixes#1187 by making sure, we only call functions, that actually exist.
Should make vim-airline work with lady loaded YCM, e.g. using vim-plug:
```viml
" Code to execute when the plugin is loaded on demand
Plug 'Valloric/YouCompleteMe', { 'for': 'cpp' }
autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif
```
Make sure, b:airline_head variable is set, also it is initially set in
this function earlier. But see #1171 for an error.
Therefore, before checking if the variable is empty, make sure it
exists.
fixes#1171
This is a little bit a hack, because by the time the separators are
added, it is not clear, if the following section is empty, therefore
we need to parse the content of the following section and eval the
expressions to find out, if this is empty
Remarks:
- catch all exceptions when eval'ing statusline
- make sure, that the seperators are highlighted
even when skipping empty regions (highlight group
names need to be adjusted)
- if a section is defined as empty, it will be removed completly from
the statusline. This means, it won't be called on the next update
and may not refresh properly (e.g. when the whitespace check
triggers, therefore, the whitesapce extension has to call an
explicit redraw whenever it is supposed to be refreshed)
"system()" called by "get_git_untracked" and "get_hg_untracked" fails
sometimes. It reports error "Can't open file /tmp/***".
The root cause is that the file path for system() contains some unordinary
character and lacks quotes.
airline#extensions#load() tries to load all extensions,
the user has specified in g:airline_extensions.
However, if e.g. bufferline is requested to be loaded, but
is not installed, it will throw an error
E117: Unknown function: airline#extensions#bufferline#init
Therefore, catch E117 and show a warning.
closes#1127
Similar to #1065 and #1081, adds link scripts to be excluded.
Adds a list containing C-like languages to ignore, which implement
multiline comments as:
/*
*
...
*/
Comment below filetype check reflects all exclusions (c-like)
This patch prevents check_mix_indent_file() form notifying a "mix-ident-file"
when working where C/CPP using space and comment like:
/**
* Some comment on the 1st column that shall not trigger check_indent_file()
*/
This kind of file can be found in linux kernel for example.
tabline
Solution: Add a new option which inverses the position of buffer and
tabs
If switch_buffer_and_tabs is 0 (default) buffer are on the left and tabs
on the right else if is 1 the order is reversed.
theme usually use '_' instead of '-', so replace that first before
trying to match.
Second, make the patterns easier to match.
Third, make sure, match for Tomorrow happens with matching case
fixes#1056