├── LICENSE
├── README.md
├── autoload
└── lightline
│ └── ale.vim
├── plugin
└── lightline
│ └── ale.vim
└── screenshot.png
/LICENSE:
--------------------------------------------------------------------------------
1 | ISC License
2 |
3 | Copyright (c) 2017-2021, Maxim Baz
4 |
5 | Permission to use, copy, modify, and/or distribute this software for any
6 | purpose with or without fee is hereby granted, provided that the above
7 | copyright notice and this permission notice appear in all copies.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # lightline-ale
2 |
3 | This plugin provides [ALE](https://github.com/w0rp/ale) indicator for the [lightline](https://github.com/itchyny/lightline.vim) vim plugin.
4 |
5 | 
6 |
7 | ## Table Of Contents
8 |
9 | - [Installation](#installation)
10 | - [Integration](#integration)
11 | - [Configuration](#configuration)
12 | - [License](#license)
13 |
14 | ## Installation
15 |
16 | Install using a plugin manager of your choice, for example:
17 |
18 | ```viml
19 | call dein#add('dense-analysis/ale') " Dependency: linter
20 | call dein#add('itchyny/lightline.vim') " Dependency: status line
21 | call dein#add('maximbaz/lightline-ale')
22 | ```
23 |
24 | ## Integration
25 |
26 | 1. Register the components:
27 |
28 | ```viml
29 | let g:lightline = {}
30 |
31 | let g:lightline.component_expand = {
32 | \ 'linter_checking': 'lightline#ale#checking',
33 | \ 'linter_infos': 'lightline#ale#infos',
34 | \ 'linter_warnings': 'lightline#ale#warnings',
35 | \ 'linter_errors': 'lightline#ale#errors',
36 | \ 'linter_ok': 'lightline#ale#ok',
37 | \ }
38 | ```
39 |
40 | 2. Set color to the components:
41 |
42 | ```viml
43 | let g:lightline.component_type = {
44 | \ 'linter_checking': 'right',
45 | \ 'linter_infos': 'right',
46 | \ 'linter_warnings': 'warning',
47 | \ 'linter_errors': 'error',
48 | \ 'linter_ok': 'right',
49 | \ }
50 | ```
51 |
52 | 3. Add the components to the lightline, for example to the right side:
53 |
54 | ```viml
55 | let g:lightline.active = { 'right': [[ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ]] }
56 | ```
57 |
58 | 3.1. Lineinfo, fileformat, etc. have to be added additionaly. Final example:
59 |
60 | ```viml
61 | let g:lightline.active = {
62 | \ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ],
63 | \ [ 'lineinfo' ],
64 | \ [ 'percent' ],
65 | \ [ 'fileformat', 'fileencoding', 'filetype'] ] }
66 |
67 | ```
68 |
69 | ## Configuration
70 |
71 | ##### `g:lightline#ale#indicator_checking`
72 |
73 | The indicator to use when ALE is in progress. Default is `Linting...`.
74 |
75 | ##### `g:lightline#ale#indicator_infos`
76 |
77 | The indicator to use when there are infos. Default is `I:`.
78 |
79 | ##### `g:lightline#ale#indicator_warnings`
80 |
81 | The indicator to use when there are warnings. Default is `W:`.
82 |
83 | ##### `g:lightline#ale#indicator_errors`
84 |
85 | The indicator to use when there are errors. Default is `E:`.
86 |
87 | ##### `g:lightline#ale#indicator_ok`
88 |
89 | The indicator to use when there are no warnings or errors. Default is `OK`.
90 |
91 | ### Using icons as indicators
92 |
93 | If you would like to replace the default indicators with symbols like on the screenshot, then you'll need to ensure you have some "iconic fonts" installed, such as [Font Awesome](https://fontawesome.com). A common alternative is to replace your primary font with one of the [Patched Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), which saves you from having to install multiple fonts.
94 |
95 | The following icons from the Font Awesome font are used in the screenshot:
96 |
97 | - Checking: [f110](https://fontawesome.com/icons/spinner)
98 | - Infos: [f129](https://fontawesome.com/icons/info)
99 | - Warnings: [f071](https://fontawesome.com/icons/exclamation-triangle)
100 | - Errors: [f05e](https://fontawesome.com/icons/ban)
101 | - OK: [f00c](https://fontawesome.com/icons/check) (although I prefer to disable this component)
102 |
103 | To specify icons in the configuration, use their unicode codes as `"\uXXXX"` (make sure to wrap them in double quotes). Alternatively copy the icons from a font website, or type \u\<4-digit-unicode\> or \U\<8-digit-unicode\> to insert the literal characters.
104 |
105 | See the code points here:
106 |
107 | - Font Awesome: https://fontawesome.com/icons
108 | - Nerd Fonts: https://github.com/ryanoasis/nerd-fonts#glyph-sets
109 |
110 | Here's the configuration snippet used in the screenshot:
111 |
112 | ```viml
113 | let g:lightline#ale#indicator_checking = "\uf110"
114 | let g:lightline#ale#indicator_infos = "\uf129"
115 | let g:lightline#ale#indicator_warnings = "\uf071"
116 | let g:lightline#ale#indicator_errors = "\uf05e"
117 | let g:lightline#ale#indicator_ok = "\uf00c"
118 | ```
119 |
120 | ## License
121 |
122 | Released under the [ISC License](LICENSE)
123 |
--------------------------------------------------------------------------------
/autoload/lightline/ale.vim:
--------------------------------------------------------------------------------
1 | let s:indicator_infos = get(g:, 'lightline#ale#indicator_infos', 'I: ')
2 | let s:indicator_warnings = get(g:, 'lightline#ale#indicator_warnings', 'W: ')
3 | let s:indicator_errors = get(g:, 'lightline#ale#indicator_errors', 'E: ')
4 | let s:indicator_ok = get(g:, 'lightline#ale#indicator_ok', 'OK')
5 | let s:indicator_checking = get(g:, 'lightline#ale#indicator_checking', 'Linting...')
6 |
7 |
8 | """"""""""""""""""""""
9 | " Lightline components
10 |
11 | function! lightline#ale#infos() abort
12 | if !lightline#ale#linted()
13 | return ''
14 | endif
15 | let l:counts = ale#statusline#Count(bufnr(''))
16 | return l:counts.info == 0 ? '' : printf(s:indicator_infos . '%d', l:counts.info)
17 | endfunction
18 |
19 | function! lightline#ale#warnings() abort
20 | if !lightline#ale#linted()
21 | return ''
22 | endif
23 | let l:counts = ale#statusline#Count(bufnr(''))
24 | let l:all_warnings = l:counts.warning + l:counts.style_warning
25 | return l:all_warnings == 0 ? '' : printf(s:indicator_warnings . '%d', all_warnings)
26 | endfunction
27 |
28 | function! lightline#ale#errors() abort
29 | if !lightline#ale#linted()
30 | return ''
31 | endif
32 | let l:counts = ale#statusline#Count(bufnr(''))
33 | let l:all_errors = l:counts.error + l:counts.style_error
34 | return l:all_errors == 0 ? '' : printf(s:indicator_errors . '%d', all_errors)
35 | endfunction
36 |
37 | function! lightline#ale#ok() abort
38 | if !lightline#ale#linted()
39 | return ''
40 | endif
41 | let l:counts = ale#statusline#Count(bufnr(''))
42 | return l:counts.total == 0 ? s:indicator_ok : ''
43 | endfunction
44 |
45 | function! lightline#ale#checking() abort
46 | return ale#engine#IsCheckingBuffer(bufnr('')) ? s:indicator_checking : ''
47 | endfunction
48 |
49 |
50 | """"""""""""""""""
51 | " Helper functions
52 |
53 | function! lightline#ale#linted() abort
54 | return get(g:, 'ale_enabled', 0) == 1
55 | \ && getbufvar(bufnr(''), 'ale_enabled', 1)
56 | \ && getbufvar(bufnr(''), 'ale_linted', 0) > 0
57 | \ && ale#engine#IsCheckingBuffer(bufnr('')) == 0
58 | endfunction
59 |
--------------------------------------------------------------------------------
/plugin/lightline/ale.vim:
--------------------------------------------------------------------------------
1 | augroup lightline#ale
2 | autocmd!
3 | autocmd User ALEJobStarted call lightline#update()
4 | autocmd User ALELintPost call lightline#update()
5 | autocmd User ALEFixPost call lightline#update()
6 | augroup END
7 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximbaz/lightline-ale/a861f691ac7e40b1b359bc7a147078fa1e0570ce/screenshot.png
--------------------------------------------------------------------------------