#1524 - Define global variables where they are needed

This commit is contained in:
w0rp 2018-05-28 19:19:20 +01:00
parent cae194d1bd
commit f2837b5802
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
15 changed files with 90 additions and 102 deletions

View File

@ -2,6 +2,11 @@
" Description: Primary code path for the plugin " Description: Primary code path for the plugin
" Manages execution of linters when requested by autocommands " Manages execution of linters when requested by autocommands
" 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_info_str = get(g:, 'ale_echo_msg_info_str', 'Info')
let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
let s:lint_timer = -1 let s:lint_timer = -1
let s:queued_buffer_number = -1 let s:queued_buffer_number = -1
let s:should_lint_file_for_buffer = {} let s:should_lint_file_for_buffer = {}
@ -32,12 +37,8 @@ function! ale#CallWithCooldown(timestamp_key, func, arglist) abort
endfunction endfunction
" Return 1 if a file is too large for ALE to handle. " Return 1 if a file is too large for ALE to handle.
function! ale#FileTooLarge() abort function! ale#FileTooLarge(buffer) abort
if !exists('g:ale_maximum_file_size') let l:max = getbufvar(a:buffer, 'ale_maximum_file_size', get(g:, 'ale_maximum_file_size', 0))
return 0
endif
let l:max = ale#Var(bufnr(''), 'maximum_file_size')
return l:max > 0 ? (line2byte(line('$') + 1) > l:max) : 0 return l:max > 0 ? (line2byte(line('$') + 1) > l:max) : 0
endfunction endfunction
@ -90,7 +91,7 @@ function! ale#ShouldDoNothing(buffer) abort
endif endif
" Do nothing if the file is too large. " Do nothing if the file is too large.
if ale#FileTooLarge() if ale#FileTooLarge(a:buffer)
return 1 return 1
endif endif

View File

@ -1,7 +1,9 @@
" Author: w0rp <devw0rp@gmail.com> " Author: w0rp <devw0rp@gmail.com>
" Description: Completion support for LSP linters " Description: Completion support for LSP linters
call ale#Set('completion_excluded_words', []) let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100)
let g:ale_completion_excluded_words = get(g:, 'ale_completion_excluded_words', [])
let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50)
let s:timer_id = -1 let s:timer_id = -1
let s:last_done_pos = [] let s:last_done_pos = []

View File

@ -1,6 +1,11 @@
" Author: w0rp <devw0rp@gmail.com> " Author: w0rp <devw0rp@gmail.com>
" Description: Echoes lint message for the current line, if any " Description: Echoes lint message for the current line, if any
" Controls the milliseconds delay before echoing a message.
let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10)
" A string format for the echoed message.
let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s')
let s:cursor_timer = -1 let s:cursor_timer = -1
let s:last_pos = [0, 0, 0] let s:last_pos = [0, 0, 0]

View File

@ -2,6 +2,9 @@
" Description: Backend execution and job management " Description: Backend execution and job management
" Executes linters in the background, using NeoVim or Vim 8 jobs " Executes linters in the background, using NeoVim or Vim 8 jobs
" Remapping of linter problems.
let g:ale_type_map = get(g:, 'ale_type_map', {})
" Stores information for each job including: " Stores information for each job including:
" "
" linter: The linter dictionary for the job. " linter: The linter dictionary for the job.
@ -44,7 +47,7 @@ function! ale#engine#IsExecutable(buffer, executable) abort
" Cache the executable check if we found it, or if the option to cache " Cache the executable check if we found it, or if the option to cache
" failing checks is on. " failing checks is on.
if l:result || g:ale_cache_executable_check_failures if l:result || get(g:, 'ale_cache_executable_check_failures', 0)
let s:executable_cache_map[a:executable] = l:result let s:executable_cache_map[a:executable] = l:result
endif endif

View File

@ -1,6 +1,9 @@
" Author: w0rp <devw0rp@gmail.com> " Author: w0rp <devw0rp@gmail.com>
" Description: Tools for managing command history " Description: Tools for managing command history
" 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)
" Return a shallow copy of the command history for a given buffer number. " Return a shallow copy of the command history for a given buffer number.
function! ale#history#Get(buffer) abort function! ale#history#Get(buffer) abort
return copy(getbufvar(a:buffer, 'ale_history', [])) return copy(getbufvar(a:buffer, 'ale_history', []))

View File

@ -8,6 +8,9 @@
" ale#job#IsRunning(job_id) -> 1 if running, 0 otherwise. " ale#job#IsRunning(job_id) -> 1 if running, 0 otherwise.
" ale#job#Stop(job_id) " ale#job#Stop(job_id)
" A setting for wrapping commands.
let g:ale_command_wrapper = get(g:, 'ale_command_wrapper', '')
if !has_key(s:, 'job_map') if !has_key(s:, 'job_map')
let s:job_map = {} let s:job_map = {}
endif endif

View File

@ -1,6 +1,19 @@
" Author: Bjorn Neergaard <bjorn@neersighted.com>, modified by Yann fery <yann@fery.me> " Author: Bjorn Neergaard <bjorn@neersighted.com>, modified by Yann fery <yann@fery.me>
" Description: Manages the loclist and quickfix lists " Description: Manages the loclist and quickfix lists
" This flag dictates if ale open the configured loclist
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)
" This flag dictates that quickfix windows should be opened vertically
let g:ale_list_vertical = get(g:, 'ale_list_vertical', 0)
" The window size to set for the quickfix and loclist windows
let g:ale_list_window_size = get(g:, 'ale_list_window_size', 10)
" A string format for the loclist messages.
let g:ale_loclist_msg_format = get(g:, 'ale_loclist_msg_format',
\ get(g:, 'ale_echo_msg_format', '%code: %%s')
\)
if !exists('s:timer_args') if !exists('s:timer_args')
let s:timer_args = {} let s:timer_args = {}
endif endif

View File

@ -1,6 +1,11 @@
" Author: w0rp <devw0rp@gmail.com> " Author: w0rp <devw0rp@gmail.com>
" Description: Set options in files based on regex patterns. " Description: Set options in files based on regex patterns.
" A dictionary mapping regular expression patterns to arbitrary buffer
" variables to be set. Useful for configuring ALE based on filename patterns.
let g:ale_pattern_options = get(g:, 'ale_pattern_options', {})
let g:ale_pattern_options_enabled = get(g:, 'ale_pattern_options_enabled', !empty(g:ale_pattern_options))
" These variables are used to cache the sorting of patterns below. " These variables are used to cache the sorting of patterns below.
let s:last_pattern_options = {} let s:last_pattern_options = {}
let s:sorted_items = [] let s:sorted_items = []

View File

@ -2,6 +2,25 @@ scriptencoding utf8
" Author: w0rp <devw0rp@gmail.com> " Author: w0rp <devw0rp@gmail.com>
" Description: Draws error and warning signs into signcolumn " Description: Draws error and warning signs into signcolumn
" This flag can be set to some integer to control the maximum number of signs
" that ALE will set.
let g:ale_max_signs = get(g:, 'ale_max_signs', -1)
" This flag can be set to 1 to enable changing the sign column colors when
" there are errors.
let g:ale_change_sign_column_color = get(g:, 'ale_change_sign_column_color', 0)
" These variables dictate what signs are used to indicate errors and warnings.
let g:ale_sign_error = get(g:, 'ale_sign_error', '>>')
let g:ale_sign_style_error = get(g:, 'ale_sign_style_error', g:ale_sign_error)
let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--')
let g:ale_sign_style_warning = get(g:, 'ale_sign_style_warning', g:ale_sign_warning)
let g:ale_sign_info = get(g:, 'ale_sign_info', g:ale_sign_warning)
" 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)
" 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)
if !hlexists('ALEErrorSign') if !hlexists('ALEErrorSign')
highlight link ALEErrorSign error highlight link ALEErrorSign error
endif endif

View File

@ -1,6 +1,12 @@
" Author: KabbAmine <amine.kabb@gmail.com> " Author: KabbAmine <amine.kabb@gmail.com>
" Description: Statusline related function(s) " Description: Statusline related function(s)
" A deprecated setting for ale#statusline#Status()
" See :help ale#statusline#Count() for getting status reports.
let g:ale_statusline_format = get(g:, 'ale_statusline_format',
\ ['%d error(s)', '%d warning(s)', 'OK']
\)
function! s:CreateCountDict() abort function! s:CreateCountDict() abort
" Keys 0 and 1 are for backwards compatibility. " Keys 0 and 1 are for backwards compatibility.
" The count object used to be a List of [error_count, warning_count]. " The count object used to be a List of [error_count, warning_count].

View File

@ -1,6 +1,6 @@
function! s:EnablePreamble() abort function! s:EnablePreamble() abort
" Set pattern options again, if enabled. " Set pattern options again, if enabled.
if g:ale_pattern_options_enabled if get(g:, 'ale_pattern_options_enabled', 0)
call ale#pattern_options#SetOptions(bufnr('')) call ale#pattern_options#SetOptions(bufnr(''))
endif endif
@ -53,11 +53,6 @@ endfunction
function! ale#toggle#Enable() abort function! ale#toggle#Enable() abort
if !g:ale_enabled if !g:ale_enabled
" Set pattern options again, if enabled.
if g:ale_pattern_options_enabled
call ale#pattern_options#SetOptions(bufnr(''))
endif
call ale#toggle#Toggle() call ale#toggle#Toggle()
endif endif
endfunction endfunction

View File

@ -686,7 +686,7 @@ g:airline#extensions#ale#enabled *g:airline#extensions#ale#enabled*
g:ale_cache_executable_check_failures *g:ale_cache_executable_check_failures* g:ale_cache_executable_check_failures *g:ale_cache_executable_check_failures*
Type: |Number| Type: |Number|
Default: `0` Default: undefined
When set to `1`, ALE will cache failing executable checks for linters. By When set to `1`, ALE will cache failing executable checks for linters. By
default, only executable checks which succeed will be cached. default, only executable checks which succeed will be cached.
@ -1259,7 +1259,7 @@ g:ale_max_signs *g:ale_max_signs*
g:ale_maximum_file_size *g:ale_maximum_file_size* g:ale_maximum_file_size *g:ale_maximum_file_size*
*b:ale_maximum_file_size* *b:ale_maximum_file_size*
Type: |Number| Type: |Number|
Default: `0` Default: undefined
A maximum file size in bytes for ALE to check. If set to any positive A maximum file size in bytes for ALE to check. If set to any positive
number, ALE will skip checking files larger than the given size. number, ALE will skip checking files larger than the given size.

View File

@ -96,6 +96,7 @@ let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 1)
" This flag can be set to 1 to enable linting when the filetype is changed. " 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) let g:ale_lint_on_filetype_changed = get(g:, 'ale_lint_on_filetype_changed', 1)
" This flag can be set to 1 to enable automatically fixing files on save.
let g:ale_fix_on_save = get(g:, 'ale_fix_on_save', 0) let g:ale_fix_on_save = get(g:, 'ale_fix_on_save', 0)
" This flag may be set to 0 to disable ale. After ale is loaded, :ALEToggle " This flag may be set to 0 to disable ale. After ale is loaded, :ALEToggle
@ -107,72 +108,20 @@ let g:ale_enabled = get(g:, 'ale_enabled', 1)
let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1) let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1)
let g:ale_set_quickfix = get(g:, 'ale_set_quickfix', 0) let g:ale_set_quickfix = get(g:, 'ale_set_quickfix', 0)
" This flag dictates if ale open the configured loclist
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)
" This flag dictates that quickfix windows should be opened vertically
let g:ale_list_vertical = get(g:, 'ale_list_vertical', 0)
" The window size to set for the quickfix and loclist windows
let g:ale_list_window_size = get(g:, 'ale_list_window_size', 10)
" This flag can be set to 0 to disable setting signs. " This flag can be set to 0 to disable setting signs.
" 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 some integer to control the maximum number of signs
" that ALE will set.
let g:ale_max_signs = get(g:, 'ale_max_signs', -1)
" This flag can be set to 1 to enable changing the sign column colors when
" there are errors.
let g:ale_change_sign_column_color = get(g:, 'ale_change_sign_column_color', 0)
" This flag can be set to 0 to disable setting error highlights. " This flag can be set to 0 to disable setting error highlights.
let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax')) let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax'))
" These variables dictate what sign is used to indicate errors and warnings.
let g:ale_sign_error = get(g:, 'ale_sign_error', '>>')
let g:ale_sign_style_error = get(g:, 'ale_sign_style_error', g:ale_sign_error)
let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--')
let g:ale_sign_style_warning = get(g:, 'ale_sign_style_warning', g:ale_sign_warning)
let g:ale_sign_info = get(g:, 'ale_sign_info', g:ale_sign_warning)
" 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)
" 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)
" A string format for the echoed message
let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s')
" The same for the loclist.
let g:ale_loclist_msg_format = get(g:, 'ale_loclist_msg_format', g:ale_echo_msg_format)
" 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_info_str = get(g:, 'ale_echo_msg_info_str', 'Info')
let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
" This flag can be set to 0 to disable echoing when the cursor moves. " This flag can be set to 0 to disable echoing when the cursor moves.
let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1) let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1)
" Controls the milliseconds delay before echoing a message.
let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10)
" This flag can be set to 0 to disable balloon support. " This flag can be set to 0 to disable balloon support.
let g:ale_set_balloons = get(g:, 'ale_set_balloons', let g:ale_set_balloons = get(g:, 'ale_set_balloons',
\ has('balloon_eval') && has('gui_running') || \ (has('balloon_eval') && has('gui_running'))
\ has('balloon_eval_term') && !has('gui_running') \ || (has('balloon_eval_term') && !has('gui_running'))
\)
" A deprecated setting for ale#statusline#Status()
" See :help ale#statusline#Count() for getting status reports.
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 " This flag can be set to 0 to disable warnings for trailing whitespace
@ -180,38 +129,14 @@ let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whit
" This flag can be set to 0 to disable warnings for trailing blank lines " This flag can be set to 0 to disable warnings for trailing blank lines
let g:ale_warn_about_trailing_blank_lines = get(g:, 'ale_warn_about_trailing_blank_lines', 1) let g:ale_warn_about_trailing_blank_lines = get(g:, 'ale_warn_about_trailing_blank_lines', 1)
" 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)
" A flag for enabling or disabling the command history. " A flag for enabling or disabling the command history.
let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1) let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1)
" A flag for storing the full output of commands in the history. " A flag for storing the full output of commands in the history.
let g:ale_history_log_output = get(g:, 'ale_history_log_output', 1) let g:ale_history_log_output = get(g:, 'ale_history_log_output', 1)
" A flag for caching failed executable checks.
" This is off by default, because it will cause problems.
let g:ale_cache_executable_check_failures = get(g:, 'ale_cache_executable_check_failures', 0)
" A dictionary mapping regular expression patterns to arbitrary buffer
" variables to be set. Useful for configuration ALE based on filename
" patterns.
let g:ale_pattern_options = get(g:, 'ale_pattern_options', {})
let g:ale_pattern_options_enabled = get(g:, 'ale_pattern_options_enabled', !empty(g:ale_pattern_options))
" A maximum file size for checking for errors.
let g:ale_maximum_file_size = get(g:, 'ale_maximum_file_size', 0)
" Remapping of linter problems.
let g:ale_type_map = get(g:, 'ale_type_map', {})
" Enable automatic completion with LSP servers and tsserver " Enable automatic completion with LSP servers and tsserver
let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0) let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0)
let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100)
let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50)
" A setting for wrapping commands.
let g:ale_command_wrapper = get(g:, 'ale_command_wrapper', '')
if g:ale_set_balloons if g:ale_set_balloons
call ale#balloon#Enable() call ale#balloon#Enable()

View File

@ -1,43 +1,51 @@
Before: Before:
Save g:ale_buffer_info Save g:ale_buffer_info
Save g:ale_cache_executable_check_failures Save g:ale_cache_executable_check_failures
Save g:ale_completion_delay
Save g:ale_completion_enabled Save g:ale_completion_enabled
Save g:ale_completion_max_suggestions
Save g:ale_fixers Save g:ale_fixers
Save g:ale_history_log_output Save g:ale_history_log_output
Save g:ale_lint_on_insert_leave Save g:ale_lint_on_insert_leave
Save g:ale_lint_on_text_changed Save g:ale_lint_on_text_changed
Save g:ale_linters Save g:ale_linters
Save g:ale_lsp_error_messages
Save g:ale_maximum_file_size Save g:ale_maximum_file_size
Save g:ale_pattern_options Save g:ale_pattern_options
Save g:ale_pattern_options_enabled Save g:ale_pattern_options_enabled
Save g:ale_set_balloons Save g:ale_set_balloons
Save g:ale_warn_about_trailing_whitespace
Save g:ale_sign_error Save g:ale_sign_error
Save g:ale_sign_warning
Save g:ale_sign_info Save g:ale_sign_info
Save g:ale_sign_style_error Save g:ale_sign_style_error
Save g:ale_sign_style_warning Save g:ale_sign_style_warning
Save g:ale_lsp_error_messages Save g:ale_sign_warning
Save g:ale_statusline_format
Save g:ale_type_map
Save g:ale_warn_about_trailing_whitespace
unlet! b:ale_history unlet! b:ale_history
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
let g:ale_cache_executable_check_failures = 0 let g:ale_cache_executable_check_failures = 0
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 0 let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = 50
let g:ale_history_log_output = 1 let g:ale_history_log_output = 1
let g:ale_lint_on_insert_leave = 0 let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_text_changed = 'always' let g:ale_lint_on_text_changed = 'always'
let g:ale_lsp_error_messages = {}
let g:ale_maximum_file_size = 0 let g:ale_maximum_file_size = 0
let g:ale_pattern_options = {} let g:ale_pattern_options = {}
let g:ale_pattern_options_enabled = 0 let g:ale_pattern_options_enabled = 0
let g:ale_set_balloons = 0 let g:ale_set_balloons = 0
let g:ale_warn_about_trailing_whitespace = 1
let g:ale_sign_error = '>>' let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let g:ale_sign_info = '--' let g:ale_sign_info = '--'
let g:ale_sign_style_error = '>>' let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--' let g:ale_sign_style_warning = '--'
let g:ale_lsp_error_messages = {} let g:ale_sign_warning = '--'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_type_map = {}
let g:ale_warn_about_trailing_whitespace = 1
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'} let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'}
let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout'} let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout'}

View File

@ -2,7 +2,7 @@ Before:
runtime autoload/ale.vim runtime autoload/ale.vim
" Replace one of the key ALE functions and make it throw. " Replace one of the key ALE functions and make it throw.
function! ale#FileTooLarge() abort function! ale#FileTooLarge(buffer) abort
throw 'broken' throw 'broken'
endfunction endfunction