All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 function! s:EnablePreamble() abort
2 " Set pattern options again, if enabled.
3 if get(g:, 'ale_pattern_options_enabled', 0)
4 call ale#pattern_options#SetOptions(bufnr(''))
7 " Lint immediately, including running linters against the file.
8 call ale#Queue(0, 'lint_file')
11 function! s:DisablePostamble() abort
12 " Remove highlights for the current buffer now.
13 if g:ale_set_highlights
14 call ale#highlight#UpdateHighlights()
17 if g:ale_virtualtext_cursor isnot# 'disabled' && g:ale_virtualtext_cursor != 0
18 call ale#virtualtext#Clear(bufnr(''))
22 function! ale#toggle#Toggle() abort
23 let g:ale_enabled = !get(g:, 'ale_enabled')
26 call s:EnablePreamble()
29 call ale#balloon#Enable()
32 call ale#engine#CleanupEveryBuffer()
33 call s:DisablePostamble()
35 if exists('*ale#balloon#Disable')
36 call ale#balloon#Disable()
40 call ale#events#Init()
43 function! ale#toggle#Enable() abort
45 call ale#toggle#Toggle()
49 function! ale#toggle#Disable() abort
51 call ale#toggle#Toggle()
55 function! ale#toggle#Reset() abort
56 call ale#engine#CleanupEveryBuffer()
57 call ale#highlight#UpdateHighlights()
60 function! ale#toggle#ToggleBuffer(buffer) abort
61 " Get the new value for the toggle.
62 let l:enabled = !getbufvar(a:buffer, 'ale_enabled', 1)
64 " Disabling ALE globally removes autocmd events, so we cannot enable
65 " linting locally when linting is disabled globally
66 if l:enabled && !g:ale_enabled
68 echom 'ALE cannot be enabled locally when disabled globally'
73 call setbufvar(a:buffer, 'ale_enabled', l:enabled)
76 call s:EnablePreamble()
78 " Stop all jobs and clear the results for everything, and delete
79 " all of the data we stored for the buffer.
80 call ale#engine#Cleanup(a:buffer)
81 call s:DisablePostamble()
85 function! ale#toggle#EnableBuffer(buffer) abort
86 " ALE is enabled by default for all buffers.
87 if !getbufvar(a:buffer, 'ale_enabled', 1)
88 call ale#toggle#ToggleBuffer(a:buffer)
92 function! ale#toggle#DisableBuffer(buffer) abort
93 if getbufvar(a:buffer, 'ale_enabled', 1)
94 call ale#toggle#ToggleBuffer(a:buffer)
98 function! ale#toggle#ResetBuffer(buffer) abort
99 call ale#engine#Cleanup(a:buffer)
100 call ale#highlight#UpdateHighlights()