2016-10-03 18:41:02 +00:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
" Description: Main entry point for the plugin: sets up prefs and autocommands
|
|
|
|
" Preferences can be set in vimrc files and so on to configure ale
|
2016-09-08 23:23:26 +00:00
|
|
|
|
2016-10-11 14:54:14 +00:00
|
|
|
" Sanity Checks
|
|
|
|
|
2017-02-14 09:18:54 +00:00
|
|
|
if exists('g:loaded_ale_dont_use_this_in_other_plugins_please')
|
2016-09-08 23:23:26 +00:00
|
|
|
finish
|
|
|
|
endif
|
2016-10-25 13:09:58 +00:00
|
|
|
|
2017-02-14 09:18:54 +00:00
|
|
|
" Set a special flag used only by this plugin for preventing doubly
|
|
|
|
" loading the script.
|
|
|
|
let g:loaded_ale_dont_use_this_in_other_plugins_please = 1
|
2016-09-08 23:23:26 +00:00
|
|
|
|
2016-10-10 12:16:32 +00:00
|
|
|
" A flag for detecting if the required features are set.
|
|
|
|
if has('nvim')
|
2016-11-04 10:17:49 +00:00
|
|
|
let s:has_features = has('timers')
|
2016-10-10 12:16:32 +00:00
|
|
|
else
|
2016-11-04 10:17:49 +00:00
|
|
|
" Check if Job and Channel functions are available, instead of the
|
|
|
|
" features. This works better on old MacVim versions.
|
|
|
|
let s:has_features = has('timers') && exists('*job_start') && exists('*ch_close_in')
|
2016-10-10 12:16:32 +00:00
|
|
|
endif
|
|
|
|
|
2016-11-04 10:17:49 +00:00
|
|
|
if !s:has_features
|
2017-02-13 23:48:36 +00:00
|
|
|
" Only output a warning if editing some special files.
|
|
|
|
if index(['', 'gitcommit'], &filetype) == -1
|
|
|
|
echoerr 'ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel'
|
|
|
|
echoerr 'Please update your editor appropriately.'
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Stop here, as it won't work.
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2017-03-06 23:15:28 +00:00
|
|
|
" Add the after directory to the runtimepath
|
|
|
|
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/after'
|
|
|
|
|
2017-02-14 09:18:54 +00:00
|
|
|
" Set this flag so that other plugins can use it, like airline.
|
|
|
|
let g:loaded_ale = 1
|
|
|
|
|
2017-02-10 09:45:42 +00:00
|
|
|
" Set the TMPDIR environment variable if it is not set automatically.
|
|
|
|
" This can automatically fix some environments.
|
|
|
|
if has('unix') && empty($TMPDIR)
|
|
|
|
let $TMPDIR = '/tmp'
|
|
|
|
endif
|
|
|
|
|
2017-03-06 23:15:28 +00:00
|
|
|
" This flag can be set to 0 to disable emitting conflict warnings.
|
|
|
|
let g:ale_emit_conflict_warnings = get(g:, 'ale_emit_conflict_warnings', 1)
|
|
|
|
|
2016-10-24 19:21:32 +00:00
|
|
|
" This global variable is used internally by ALE for tracking information for
|
|
|
|
" each buffer which linters are being run against.
|
2016-10-23 21:41:00 +00:00
|
|
|
let g:ale_buffer_info = {}
|
2016-10-11 14:54:14 +00:00
|
|
|
|
|
|
|
" User Configuration
|
|
|
|
|
2016-10-25 13:09:58 +00:00
|
|
|
" This option prevents ALE autocmd commands from being run for particular
|
|
|
|
" filetypes which can cause issues.
|
2017-02-15 22:02:59 +00:00
|
|
|
let g:ale_filetype_blacklist = ['nerdtree', 'unite', 'tags']
|
2016-10-25 13:09:58 +00:00
|
|
|
|
2016-10-11 22:11:45 +00:00
|
|
|
" This Dictionary configures which linters are enabled for which languages.
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
let g:ale_linters = get(g:, 'ale_linters', {})
|
|
|
|
|
2016-10-11 22:11:45 +00:00
|
|
|
" This Dictionary allows users to set up filetype aliases for new filetypes.
|
|
|
|
let g:ale_linter_aliases = get(g:, 'ale_linter_aliases', {})
|
|
|
|
|
2016-09-08 23:23:26 +00:00
|
|
|
" This flag can be set with a number of milliseconds for delaying the
|
|
|
|
" execution of a linter when text is changed. The timeout will be set and
|
|
|
|
" cleared each time text is changed, so repeated edits won't trigger the
|
|
|
|
" jobs for linting until enough time has passed after editing is done.
|
2016-10-05 08:27:03 +00:00
|
|
|
let g:ale_lint_delay = get(g:, 'ale_lint_delay', 200)
|
2016-09-08 23:23:26 +00:00
|
|
|
|
2017-03-30 22:21:37 +00:00
|
|
|
" This flag can be set to 'never' to disable linting when text is changed.
|
|
|
|
" This flag can also be set to 'insert' or 'normal' to lint when text is
|
|
|
|
" changed only in insert or normal mode respectively.
|
|
|
|
let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 'always')
|
|
|
|
|
|
|
|
" This flag can be set to 1 to enable linting when leaving insert mode.
|
|
|
|
let g:ale_lint_on_insert_leave = get(g:, 'ale_lint_on_insert_leave', 0)
|
2016-10-11 14:54:14 +00:00
|
|
|
|
2016-09-08 23:23:26 +00:00
|
|
|
" This flag can be set to 0 to disable linting when the buffer is entered.
|
2016-10-04 20:28:54 +00:00
|
|
|
let g:ale_lint_on_enter = get(g:, 'ale_lint_on_enter', 1)
|
2016-09-08 23:23:26 +00:00
|
|
|
|
2016-10-04 20:31:47 +00:00
|
|
|
" This flag can be set to 1 to enable linting when a buffer is written.
|
2017-03-27 19:36:35 +00:00
|
|
|
let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 1)
|
2017-02-09 18:47:14 +00:00
|
|
|
|
2017-03-27 21:40:25 +00:00
|
|
|
" This flag can be set to 1 to enable linting when the filetype is changed.
|
|
|
|
let g:ale_lint_on_filetype_changed = get(g:, 'ale_lint_on_filetype_changed', 1)
|
|
|
|
|
2017-02-09 18:47:14 +00:00
|
|
|
" This flag may be set to 0 to disable ale. After ale is loaded, :ALEToggle
|
|
|
|
" should be used instead.
|
|
|
|
let g:ale_enabled = get(g:, 'ale_enabled', 1)
|
2016-10-04 20:31:47 +00:00
|
|
|
|
2017-01-22 12:57:05 +00:00
|
|
|
" These flags dictates if ale uses the quickfix or the loclist (loclist is the
|
|
|
|
" default, quickfix overrides loclist).
|
2016-10-04 20:28:54 +00:00
|
|
|
let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1)
|
2017-01-22 12:57:05 +00:00
|
|
|
let g:ale_set_quickfix = get(g:, 'ale_set_quickfix', 0)
|
|
|
|
|
2017-01-22 14:54:57 +00:00
|
|
|
" This flag dictates if ale open the configured loclist
|
2017-01-22 12:57:05 +00:00
|
|
|
let g:ale_open_list = get(g:, 'ale_open_list', 0)
|
|
|
|
|
|
|
|
" This flag dictates if ale keeps open loclist even if there is no error in loclist
|
|
|
|
let g:ale_keep_list_window_open = get(g:, 'ale_keep_list_window_open', 0)
|
2016-09-08 23:23:26 +00:00
|
|
|
|
|
|
|
" This flag can be set to 0 to disable setting signs.
|
2016-10-04 20:28:54 +00:00
|
|
|
" This is enabled by default only if the 'signs' feature exists.
|
|
|
|
let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs'))
|
2016-09-08 23:23:26 +00:00
|
|
|
|
2017-02-13 00:18:51 +00:00
|
|
|
" This flag can be set to 0 to disable setting error highlights.
|
|
|
|
let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax'))
|
|
|
|
|
2016-10-11 14:54:14 +00:00
|
|
|
" These variables dicatate what sign is used to indicate errors and warnings.
|
|
|
|
let g:ale_sign_error = get(g:, 'ale_sign_error', '>>')
|
|
|
|
let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--')
|
2016-09-15 12:08:21 +00:00
|
|
|
|
2016-10-11 14:54:14 +00:00
|
|
|
" This variable sets an offset which can be set for sign IDs.
|
|
|
|
" This ID can be changed depending on what IDs are set for other plugins.
|
|
|
|
" The dummy sign will use the ID exactly equal to the offset.
|
|
|
|
let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000)
|
2016-09-26 15:02:21 +00:00
|
|
|
|
|
|
|
" This flag can be set to 1 to keep sign gutter always open
|
2016-10-04 20:28:54 +00:00
|
|
|
let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0)
|
2016-10-07 05:49:30 +00:00
|
|
|
|
2016-10-10 11:53:54 +00:00
|
|
|
" String format for the echoed message
|
|
|
|
" A %s is mandatory
|
|
|
|
" It can contain 2 handlers: %linter%, %severity%
|
|
|
|
let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%s')
|
|
|
|
|
|
|
|
" Strings used for severity in the echoed message
|
|
|
|
let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error')
|
|
|
|
let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
|
2016-10-11 14:54:14 +00:00
|
|
|
" This flag can be set to 0 to disable echoing when the cursor moves.
|
Implement a more efficient statusbar
The statusbar now keeps its state in a separate variable, in order to
avoid excess iterations. The engine now updates said variable on run,
and a new function is made available for external statusbars to call (to
avoid dependencies on internal implementation details of ale).
To keep things light, the status bar code is not loaded unless invoked
by the user or an external plugin. On the first load it will update
itself from the global loclist, after that, the engine will handle all
updates.
The external integration function, `ale#statusline#Count()`, will return
a tuple in the format [E, W] (where E is errors, W is warnings), unless
no data exists (ie, the plugin doesn't have a linter for a file or has
not run yet), in which case it returns 0/false.
2016-10-11 21:51:01 +00:00
|
|
|
let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1)
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
|
2016-10-11 14:54:14 +00:00
|
|
|
" String format for statusline
|
|
|
|
" Its a list where:
|
|
|
|
" * The 1st element is for errors
|
|
|
|
" * The 2nd element is for warnings
|
|
|
|
" * The 3rd element is when there are no errors
|
|
|
|
let g:ale_statusline_format = get(g:, 'ale_statusline_format',
|
|
|
|
\ ['%d error(s)', '%d warning(s)', 'OK']
|
|
|
|
\)
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
|
2016-10-11 14:54:14 +00:00
|
|
|
" This flag can be set to 0 to disable warnings for trailing whitespace
|
|
|
|
let g:ale_warn_about_trailing_whitespace =
|
|
|
|
\ get(g:, 'ale_warn_about_trailing_whitespace', 1)
|
|
|
|
|
2017-02-14 23:44:37 +00:00
|
|
|
" A flag for controlling the maximum size of the command history to store.
|
|
|
|
let g:ale_max_buffer_history_size = get(g:, 'ale_max_buffer_history_size', 20)
|
|
|
|
|
2017-02-16 21:33:44 +00:00
|
|
|
" A flag for enabling or disabling the command history.
|
|
|
|
let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1)
|
|
|
|
|
2017-02-16 23:18:57 +00:00
|
|
|
" A flag for storing the full output of commands in the history.
|
|
|
|
let g:ale_history_log_output = get(g:, 'ale_history_log_output', 0)
|
|
|
|
|
2017-03-30 22:21:37 +00:00
|
|
|
function! ALEInitAuGroups() abort
|
2017-04-03 18:04:02 +00:00
|
|
|
" This value used to be a Boolean as a Number, and is now a String.
|
|
|
|
let l:text_changed = '' . g:ale_lint_on_text_changed
|
|
|
|
|
2017-02-09 18:47:14 +00:00
|
|
|
augroup ALERunOnTextChangedGroup
|
|
|
|
autocmd!
|
2017-03-30 22:21:37 +00:00
|
|
|
if g:ale_enabled
|
2017-04-03 18:04:02 +00:00
|
|
|
if l:text_changed ==? 'always' || l:text_changed ==# '1'
|
2017-03-30 22:21:37 +00:00
|
|
|
autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay)
|
2017-04-03 18:04:02 +00:00
|
|
|
elseif l:text_changed ==? 'normal'
|
2017-03-30 22:21:37 +00:00
|
|
|
autocmd TextChanged * call ale#Queue(g:ale_lint_delay)
|
2017-04-03 18:04:02 +00:00
|
|
|
elseif l:text_changed ==? 'insert'
|
2017-03-30 22:21:37 +00:00
|
|
|
autocmd TextChangedI * call ale#Queue(g:ale_lint_delay)
|
|
|
|
endif
|
2017-02-09 18:47:14 +00:00
|
|
|
endif
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
augroup ALERunOnEnterGroup
|
|
|
|
autocmd!
|
|
|
|
if g:ale_enabled && g:ale_lint_on_enter
|
2017-03-21 13:38:27 +00:00
|
|
|
autocmd BufEnter,BufRead * call ale#Queue(300, 'lint_file')
|
2017-02-09 18:47:14 +00:00
|
|
|
endif
|
|
|
|
augroup END
|
|
|
|
|
2017-03-27 21:40:25 +00:00
|
|
|
augroup ALERunOnFiletypeChangeGroup
|
|
|
|
autocmd!
|
|
|
|
if g:ale_enabled && g:ale_lint_on_filetype_changed
|
2017-04-26 22:02:00 +00:00
|
|
|
" Set the filetype after a buffer is opened or read.
|
|
|
|
autocmd BufEnter,BufRead * let b:ale_original_filetype = &filetype
|
|
|
|
" Only start linting if the FileType actually changes after
|
|
|
|
" opening a buffer. The FileType will fire when buffers are opened.
|
|
|
|
autocmd FileType *
|
|
|
|
\ if has_key(b:, 'ale_original_filetype')
|
|
|
|
\ && b:ale_original_filetype !=# expand('<amatch>')
|
|
|
|
\| call ale#Queue(300, 'lint_file')
|
|
|
|
\| endif
|
2017-03-27 21:40:25 +00:00
|
|
|
endif
|
|
|
|
augroup END
|
|
|
|
|
2017-02-09 18:47:14 +00:00
|
|
|
augroup ALERunOnSaveGroup
|
|
|
|
autocmd!
|
|
|
|
if g:ale_enabled && g:ale_lint_on_save
|
2017-03-21 13:38:27 +00:00
|
|
|
autocmd BufWrite * call ale#Queue(0, 'lint_file')
|
2017-02-09 18:47:14 +00:00
|
|
|
endif
|
|
|
|
augroup END
|
|
|
|
|
2017-03-30 22:21:37 +00:00
|
|
|
augroup ALERunOnInsertLeave
|
|
|
|
autocmd!
|
|
|
|
if g:ale_enabled && g:ale_lint_on_insert_leave
|
|
|
|
autocmd InsertLeave * call ale#Queue(0, 'lint_file')
|
|
|
|
endif
|
|
|
|
augroup END
|
|
|
|
|
2017-02-09 18:47:14 +00:00
|
|
|
augroup ALECursorGroup
|
|
|
|
autocmd!
|
|
|
|
if g:ale_enabled && g:ale_echo_cursor
|
|
|
|
autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay()
|
2017-03-02 23:36:31 +00:00
|
|
|
" Look for a warning to echo as soon as we leave Insert mode.
|
|
|
|
" The script's position variable used when moving the cursor will
|
|
|
|
" not be changed here.
|
|
|
|
autocmd InsertLeave * call ale#cursor#EchoCursorWarning()
|
2017-02-09 18:47:14 +00:00
|
|
|
endif
|
|
|
|
augroup END
|
2017-02-15 21:36:16 +00:00
|
|
|
|
|
|
|
if !g:ale_enabled
|
|
|
|
augroup! ALERunOnTextChangedGroup
|
|
|
|
augroup! ALERunOnEnterGroup
|
|
|
|
augroup! ALERunOnSaveGroup
|
2017-03-30 22:21:37 +00:00
|
|
|
augroup! ALERunOnInsertLeave
|
2017-02-15 21:36:16 +00:00
|
|
|
augroup! ALECursorGroup
|
|
|
|
endif
|
2017-02-09 18:47:14 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! s:ALEToggle() abort
|
|
|
|
let g:ale_enabled = !get(g:, 'ale_enabled')
|
|
|
|
|
|
|
|
if g:ale_enabled
|
2017-03-21 13:38:27 +00:00
|
|
|
" Lint immediately, including running linters against the file.
|
|
|
|
call ale#Queue(0, 'lint_file')
|
2017-02-09 18:47:14 +00:00
|
|
|
else
|
2017-03-09 00:43:53 +00:00
|
|
|
" Make sure the buffer number is a number, not a string,
|
|
|
|
" otherwise things can go wrong.
|
|
|
|
for l:buffer in map(keys(g:ale_buffer_info), 'str2nr(v:val)')
|
2017-02-09 18:47:14 +00:00
|
|
|
" Stop jobs and delete stored buffer data
|
|
|
|
call ale#cleanup#Buffer(l:buffer)
|
|
|
|
" Clear signs, loclist, quicklist
|
|
|
|
call ale#engine#SetResults(l:buffer, [])
|
|
|
|
endfor
|
2017-02-13 00:18:51 +00:00
|
|
|
|
|
|
|
" Remove highlights for the current buffer now.
|
2017-02-14 19:26:19 +00:00
|
|
|
if g:ale_set_highlights
|
2017-02-13 00:18:51 +00:00
|
|
|
call ale#highlight#UpdateHighlights()
|
|
|
|
endif
|
2017-02-09 18:47:14 +00:00
|
|
|
endif
|
|
|
|
|
2017-03-30 22:21:37 +00:00
|
|
|
call ALEInitAuGroups()
|
2017-02-09 18:47:14 +00:00
|
|
|
endfunction
|
|
|
|
|
2017-03-30 22:21:37 +00:00
|
|
|
call ALEInitAuGroups()
|
2017-02-09 18:47:14 +00:00
|
|
|
|
2016-10-24 21:09:41 +00:00
|
|
|
" Define commands for moving through warnings and errors.
|
2017-03-28 17:27:07 +00:00
|
|
|
command! -bar ALEPrevious :call ale#loclist_jumping#Jump('before', 0)
|
|
|
|
command! -bar ALEPreviousWrap :call ale#loclist_jumping#Jump('before', 1)
|
|
|
|
command! -bar ALENext :call ale#loclist_jumping#Jump('after', 0)
|
|
|
|
command! -bar ALENextWrap :call ale#loclist_jumping#Jump('after', 1)
|
2016-10-24 21:09:41 +00:00
|
|
|
|
2017-03-02 07:14:30 +00:00
|
|
|
" A command for showing error details.
|
2017-03-28 17:27:07 +00:00
|
|
|
command! -bar ALEDetail :call ale#cursor#ShowCursorDetail()
|
2017-03-02 07:14:30 +00:00
|
|
|
|
2017-03-28 22:04:58 +00:00
|
|
|
" Define commands for turning ALE on or off.
|
2017-03-28 17:27:07 +00:00
|
|
|
command! -bar ALEToggle :call s:ALEToggle()
|
2017-03-28 22:04:58 +00:00
|
|
|
command! -bar ALEEnable :if !g:ale_enabled | ALEToggle | endif
|
|
|
|
command! -bar ALEDisable :if g:ale_enabled | ALEToggle | endif
|
|
|
|
|
2017-02-28 09:10:58 +00:00
|
|
|
" A command for linting manually.
|
2017-03-28 17:27:07 +00:00
|
|
|
command! -bar ALELint :call ale#Queue(0, 'lint_file')
|
2017-02-09 18:47:14 +00:00
|
|
|
|
2017-02-28 09:10:58 +00:00
|
|
|
" Define a command to get information about current filetype.
|
2017-03-28 17:27:07 +00:00
|
|
|
command! -bar ALEInfo :call ale#debugging#Info()
|
2017-02-14 23:45:22 +00:00
|
|
|
" The same, but copy output to your clipboard.
|
2017-03-28 17:27:07 +00:00
|
|
|
command! -bar ALEInfoToClipboard :call ale#debugging#InfoToClipboard()
|
2017-01-24 15:50:49 +00:00
|
|
|
|
2016-10-24 21:09:41 +00:00
|
|
|
" <Plug> mappings for commands
|
|
|
|
nnoremap <silent> <Plug>(ale_previous) :ALEPrevious<Return>
|
|
|
|
nnoremap <silent> <Plug>(ale_previous_wrap) :ALEPreviousWrap<Return>
|
|
|
|
nnoremap <silent> <Plug>(ale_next) :ALENext<Return>
|
|
|
|
nnoremap <silent> <Plug>(ale_next_wrap) :ALENextWrap<Return>
|
2017-02-09 18:47:14 +00:00
|
|
|
nnoremap <silent> <Plug>(ale_toggle) :ALEToggle<Return>
|
2017-02-28 09:10:58 +00:00
|
|
|
nnoremap <silent> <Plug>(ale_lint) :ALELint<Return>
|
2017-03-02 07:14:30 +00:00
|
|
|
nnoremap <silent> <Plug>(ale_detail) :ALEDetail<Return>
|
2016-10-24 21:09:41 +00:00
|
|
|
|
2016-10-11 14:54:14 +00:00
|
|
|
" Housekeeping
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
|
Implement a more efficient statusbar
The statusbar now keeps its state in a separate variable, in order to
avoid excess iterations. The engine now updates said variable on run,
and a new function is made available for external statusbars to call (to
avoid dependencies on internal implementation details of ale).
To keep things light, the status bar code is not loaded unless invoked
by the user or an external plugin. On the first load it will update
itself from the global loclist, after that, the engine will handle all
updates.
The external integration function, `ale#statusline#Count()`, will return
a tuple in the format [E, W] (where E is errors, W is warnings), unless
no data exists (ie, the plugin doesn't have a linter for a file or has
not run yet), in which case it returns 0/false.
2016-10-11 21:51:01 +00:00
|
|
|
augroup ALECleanupGroup
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
autocmd!
|
2016-10-11 14:54:14 +00:00
|
|
|
" Clean up buffers automatically when they are unloaded.
|
2016-10-31 14:47:08 +00:00
|
|
|
autocmd BufUnload * call ale#cleanup#Buffer(expand('<abuf>'))
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
augroup END
|
|
|
|
|
2016-10-11 14:54:14 +00:00
|
|
|
" Backwards Compatibility
|
2016-10-10 18:56:05 +00:00
|
|
|
|
2017-01-22 14:54:57 +00:00
|
|
|
function! ALELint(delay) abort
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
call ale#Queue(a:delay)
|
|
|
|
endfunction
|
2016-10-11 14:54:14 +00:00
|
|
|
|
2017-01-22 14:54:57 +00:00
|
|
|
function! ALEGetStatusLine() abort
|
2016-10-11 19:24:43 +00:00
|
|
|
return ale#statusline#Status()
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
endfunction
|