Implement Lua ALE setup & overhaul documentation

1. Add ale.setup and ale.setup.buffer for pure Lua configuration.
2. Update many global settings to use Booleans instead of numbers to
   make types easiert to work with in Lua.
3. Radically reformat documentation and fix errors to make
   documentation more usable for Neovim users.
This commit is contained in:
w0rp
2025-03-20 21:33:12 +00:00
parent 2280d41b30
commit 400857d758
146 changed files with 5469 additions and 2642 deletions

View File

@@ -16,7 +16,7 @@ onoremap <silent> <Plug>(ale_show_completion_menu) <Nop>
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 g:ale_completion_autoimport = get(g:, 'ale_completion_autoimport', 1)
let g:ale_completion_autoimport = get(g:, 'ale_completion_autoimport', v:true)
let g:ale_completion_tsserver_remove_warnings = get(g:, 'ale_completion_tsserver_remove_warnings', 0)
let s:timer_id = -1
@@ -394,6 +394,7 @@ function! ale#completion#Show(result) abort
if g:ale_enabled
\&& (
\ l:text_changed is# '1'
\ || g:ale_lint_on_text_changed is v:true
\ || l:text_changed is# 'always'
\ || l:text_changed is# 'normal'
\ || l:text_changed is# 'insert'
@@ -510,7 +511,7 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
\ 'icase': 1,
\ 'menu': join(l:displayParts, ''),
\ 'dup': get(l:info, 'additional_edits_only', 0)
\ || g:ale_completion_autoimport,
\ || (g:ale_completion_autoimport + 0),
\ 'info': join(l:documentationParts, ''),
\}
" This flag is used to tell if this completion came from ALE or not.
@@ -625,7 +626,7 @@ function! ale#completion#ParseLSPCompletions(response) abort
\ 'icase': 1,
\ 'menu': l:detail,
\ 'dup': get(l:info, 'additional_edits_only', 0)
\ || g:ale_completion_autoimport,
\ || (g:ale_completion_autoimport + 0),
\ 'info': (type(l:doc) is v:t_string ? l:doc : ''),
\}
" This flag is used to tell if this completion came from ALE or not.
@@ -779,18 +780,15 @@ function! s:OnReady(linter, lsp_details) abort
call ale#lsp#RegisterCallback(l:id, l:Callback)
if a:linter.lsp is# 'tsserver'
if get(g:, 'ale_completion_tsserver_autoimport') is 1
" no-custom-checks
echom '`g:ale_completion_tsserver_autoimport` is deprecated. Use `g:ale_completion_autoimport` instead.'
endif
let l:message = ale#lsp#tsserver_message#Completions(
\ l:buffer,
\ b:ale_completion_info.line,
\ b:ale_completion_info.column,
\ b:ale_completion_info.prefix,
\ get(b:ale_completion_info, 'additional_edits_only', 0)
\ || g:ale_completion_autoimport,
\ (
\ get(b:ale_completion_info, 'additional_edits_only', 0)
\ || g:ale_completion_autoimport
\ ) ? v:true : v:false,
\)
else
" Send a message saying the buffer has changed first, otherwise

View File

@@ -4,7 +4,7 @@
let s:go_to_definition_map = {}
" Enable automatic updates of the tagstack
let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1)
let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', v:true)
let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer')
" Used to get the definition map in tests.

View File

@@ -68,7 +68,7 @@ function! ale#engine#IsExecutable(buffer, executable) abort
" Cache the executable check if we found it, or if the option to cache
" failing checks is on.
if l:result || get(g:, 'ale_cache_executable_check_failures', 0)
if l:result || get(g:, 'ale_cache_executable_check_failures')
let s:executable_cache_map[a:executable] = l:result
endif

View File

@@ -173,7 +173,9 @@ function! ale#events#Init() abort
autocmd BufWritePost * call ale#events#SaveEvent(str2nr(expand('<abuf>')))
if g:ale_enabled
if l:text_changed is? 'always' || l:text_changed is# '1'
if l:text_changed is? 'always'
\|| l:text_changed is# '1'
\|| g:ale_lint_on_text_changed is v:true
autocmd TextChanged,TextChangedI * call ale#Queue(ale#Var(str2nr(expand('<abuf>')), 'lint_delay'))
elseif l:text_changed is? 'normal'
autocmd TextChanged * call ale#Queue(ale#Var(str2nr(expand('<abuf>')), 'lint_delay'))

View File

@@ -2,11 +2,11 @@
" 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)
let g:ale_open_list = get(g:, 'ale_open_list', v:false)
" 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)
let g:ale_list_vertical = get(g:, 'ale_list_vertical', v:false)
" 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.

View File

@@ -219,7 +219,7 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
call s:HandleTSServerDiagnostics(a:response, 'syntax')
elseif get(a:response, 'type', '') is# 'event'
\&& get(a:response, 'event', '') is# 'suggestionDiag'
\&& get(g:, 'ale_lsp_suggestions', '1') == 1
\&& get(g:, 'ale_lsp_suggestions')
call s:HandleTSServerDiagnostics(a:response, 'suggestion')
endif
endfunction

View File

@@ -17,8 +17,8 @@ function! ale#rename#ClearLSPData() abort
let s:rename_map = {}
endfunction
let g:ale_rename_tsserver_find_in_comments = get(g:, 'ale_rename_tsserver_find_in_comments')
let g:ale_rename_tsserver_find_in_strings = get(g:, 'ale_rename_tsserver_find_in_strings')
let g:ale_rename_tsserver_find_in_comments = get(g:, 'ale_rename_tsserver_find_in_comments', v:false)
let g:ale_rename_tsserver_find_in_strings = get(g:, 'ale_rename_tsserver_find_in_strings', v:false)
function! s:message(message) abort
call ale#util#Execute('echom ' . string(a:message))

View File

@@ -7,7 +7,7 @@ scriptencoding utf8
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)
let g:ale_change_sign_column_color = get(g:, 'ale_change_sign_column_color', v:false)
" These variables dictate what signs are used to indicate errors and warnings.
let g:ale_sign_error = get(g:, 'ale_sign_error', 'E')
let g:ale_sign_style_error = get(g:, 'ale_sign_style_error', g:ale_sign_error)
@@ -20,8 +20,8 @@ let g:ale_sign_priority = get(g:, 'ale_sign_priority', 30)
" 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)
let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0)
let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', v:false)
let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', v:false)
let s:supports_sign_groups = has('nvim-0.4.2') || has('patch-8.1.614')

View File

@@ -32,7 +32,7 @@ let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10)
let g:ale_virtualtext_column = get(g:, 'ale_virtualtext_column', 0)
let g:ale_virtualtext_maxcolumn = get(g:, 'ale_virtualtext_maxcolumn', 0)
" If 1, only show the first problem with virtualtext.
let g:ale_virtualtext_single = get(g:, 'ale_virtualtext_single', 1)
let g:ale_virtualtext_single = get(g:, 'ale_virtualtext_single', v:true)
let s:cursor_timer = get(s:, 'cursor_timer', -1)
let s:last_pos = get(s:, 'last_pos', [0, 0, 0])