Merge pull request #93 from neersighted/pruning

Clean and reorganize flags/preferences
This commit is contained in:
w0rp 2016-10-11 17:18:17 +01:00 committed by GitHub
commit f88db6c336
2 changed files with 67 additions and 62 deletions

View File

@ -20,14 +20,6 @@ if !hlexists('ALEWarning')
highlight link ALEWarning SpellCap highlight link ALEWarning SpellCap
endif endif
" Global variables for signs
let g:ale_sign_error = get(g:, 'ale_sign_error', '>>')
let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--')
" 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)
" Signs show up on the left for error markers. " Signs show up on the left for error markers.
execute 'sign define ALEErrorSign text=' . g:ale_sign_error execute 'sign define ALEErrorSign text=' . g:ale_sign_error
\ . ' texthl=ALEErrorSign' \ . ' texthl=ALEErrorSign'

View File

@ -2,6 +2,8 @@
" Description: Main entry point for the plugin: sets up prefs and autocommands " 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 " Preferences can be set in vimrc files and so on to configure ale
" Sanity Checks
if exists('g:loaded_ale') if exists('g:loaded_ale')
finish finish
endif endif
@ -9,34 +11,60 @@ let g:loaded_ale = 1
" A flag for detecting if the required features are set. " A flag for detecting if the required features are set.
if has('nvim') if has('nvim')
let g:ale_has_required_features = has('timers') let s:ale_has_required_features = has('timers')
else else
let g:ale_has_required_features = has('timers') && has('job') && has('channel') let s:ale_has_required_features = has('timers') && has('job') && has('channel')
endif endif
if !g:ale_has_required_features if !s:ale_has_required_features
echoerr 'ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel' echoerr 'ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel'
echoerr 'Please update your editor appropriately.' echoerr 'Please update your editor appropriately.'
finish finish
endif endif
" Globals
let g:ale_buffer_loclist_map = {}
let g:ale_buffer_should_reset_map = {}
let g:ale_buffer_sign_dummy_map = {}
" User Configuration
" This list configures which linters are enabled for which languages. " This list configures which linters are enabled for which languages.
let g:ale_linters = get(g:, 'ale_linters', {}) let g:ale_linters = get(g:, 'ale_linters', {})
" This flag can be set to 0 to disable linting when text is changed.
let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 1)
" This flag can be set with a number of milliseconds for delaying the " 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 " 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 " 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. " jobs for linting until enough time has passed after editing is done.
let g:ale_lint_delay = get(g:, 'ale_lint_delay', 200) let g:ale_lint_delay = get(g:, 'ale_lint_delay', 200)
" This flag can be set to 0 to disable linting when text is changed.
let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 1)
if g:ale_lint_on_text_changed
augroup ALERunOnTextChangedGroup
autocmd!
autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay)
augroup END
endif
" This flag can be set to 0 to disable linting when the buffer is entered. " This flag can be set to 0 to disable linting when the buffer is entered.
let g:ale_lint_on_enter = get(g:, 'ale_lint_on_enter', 1) let g:ale_lint_on_enter = get(g:, 'ale_lint_on_enter', 1)
if g:ale_lint_on_enter
augroup ALERunOnEnterGroup
autocmd!
autocmd BufEnter,BufRead * call ale#Queue(100)
augroup END
endif
" This flag can be set to 1 to enable linting when a buffer is written. " This flag can be set to 1 to enable linting when a buffer is written.
let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 0) let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 0)
if g:ale_lint_on_save
augroup ALERunOnSaveGroup
autocmd!
autocmd BufWrite * call ale#Queue(0)
augroup END
endif
" This flag can be set to 0 to disable setting the loclist. " This flag can be set to 0 to disable setting the loclist.
let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1) let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1)
@ -45,25 +73,18 @@ let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1)
" This is enabled by default only if the 'signs' feature exists. " This is enabled by default only if the 'signs' feature exists.
let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs')) let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs'))
" This flag can be set to 0 to disable echoing when the cursor moves. " These variables dicatate what sign is used to indicate errors and warnings.
let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1) let g:ale_sign_error = get(g:, 'ale_sign_error', '>>')
let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--')
" This flag can be set to 0 to disable warnings for trailing whitespace " This variable sets an offset which can be set for sign IDs.
let g:ale_warn_about_trailing_whitespace = " This ID can be changed depending on what IDs are set for other plugins.
\ get(g:, 'ale_warn_about_trailing_whitespace', 1) " The dummy sign will use the ID exactly equal to the offset.
let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000)
" This flag can be set to 1 to keep sign gutter always open " This flag can be set to 1 to keep sign gutter always open
let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0)
" 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']
\)
" String format for the echoed message " String format for the echoed message
" A %s is mandatory " A %s is mandatory
" It can contain 2 handlers: %linter%, %severity% " It can contain 2 handlers: %linter%, %severity%
@ -73,49 +94,41 @@ let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%s')
let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error') 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') let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
if g:ale_lint_on_text_changed " This flag can be set to 0 to disable echoing when the cursor moves.
augroup ALERunOnTextChangedGroup if get(g:, 'ale_echo_cursor', 1)
autocmd!
autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay)
augroup END
endif
if g:ale_lint_on_enter
augroup ALERunOnEnterGroup
autocmd!
autocmd BufEnter,BufRead * call ale#Queue(100)
augroup END
endif
if g:ale_lint_on_save
augroup ALERunOnSaveGroup
autocmd!
autocmd BufWrite * call ale#Queue(0)
augroup END
endif
" Clean up buffers automatically when they are unloaded.
augroup ALEBufferCleanup
autocmd!
autocmd BufUnload * call ale#cleanup#Buffer('<abuf>')
augroup END
" Globals which each part of the plugin should use.
let g:ale_buffer_loclist_map = {}
let g:ale_buffer_should_reset_map = {}
let g:ale_buffer_sign_dummy_map = {}
if g:ale_echo_cursor
augroup ALECursorGroup augroup ALECursorGroup
autocmd! autocmd!
autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay() autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay()
augroup END augroup END
endif endif
" Backwards compatibility " 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']
\)
" 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)
" Housekeeping
augroup ALECleanup
autocmd!
" Clean up buffers automatically when they are unloaded.
autocmd BufUnload * call ale#cleanup#Buffer('<abuf>')
augroup END
" Backwards Compatibility
function! ALELint(delay) function! ALELint(delay)
call ale#Queue(a:delay) call ale#Queue(a:delay)
endfunction endfunction
function! ALEGetStatusLine() function! ALEGetStatusLine()
call ale#statusline#Status() call ale#statusline#Status()
endfunction endfunction