diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale.vim | 5 | ||||
-rw-r--r-- | autoload/ale/engine.vim | 30 | ||||
-rw-r--r-- | autoload/ale/lsp/reset.vim | 2 | ||||
-rw-r--r-- | autoload/ale/lsp_linter.vim | 4 | ||||
-rw-r--r-- | autoload/ale/other_source.vim | 21 |
5 files changed, 51 insertions, 11 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim index dddb41db..f6c23d72 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -94,6 +94,11 @@ function! s:Lint(buffer, should_lint_file, timer_id) abort \ ? ale#engine#ignore#Exclude(l:filetype, l:linters, l:ignore_config) \ : l:linters + " Tell other sources that they can start checking the buffer now. + let g:ale_want_results_buffer = a:buffer + silent doautocmd <nomodeline> User ALEWantResults + unlet! g:ale_want_results_buffer + " Don't set up buffer data and so on if there are no linters to run. if !has_key(g:ale_buffer_info, a:buffer) && empty(l:linters) return diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 05db0e49..e85e4d66 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -79,6 +79,7 @@ function! ale#engine#InitBufferInfo(buffer) abort let g:ale_buffer_info[a:buffer] = { \ 'job_list': [], \ 'active_linter_list': [], + \ 'active_other_sources_list': [], \ 'loclist': [], \ 'temporary_file_list': [], \ 'temporary_directory_list': [], @@ -97,6 +98,7 @@ function! ale#engine#IsCheckingBuffer(buffer) abort let l:info = get(g:ale_buffer_info, a:buffer, {}) return !empty(get(l:info, 'active_linter_list', [])) + \ || !empty(get(l:info, 'active_other_sources_list', [])) endfunction " Register a temporary file to be managed with the ALE engine for @@ -177,20 +179,27 @@ function! s:GatherOutput(job_id, line) abort endif endfunction -function! ale#engine#HandleLoclist(linter_name, buffer, loclist) abort +function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_source) abort let l:info = get(g:ale_buffer_info, a:buffer, {}) if empty(l:info) return endif - " Remove this linter from the list of active linters. - " This may have already been done when the job exits. - call filter(l:info.active_linter_list, 'v:val isnot# a:linter_name') + if !a:from_other_source + " Remove this linter from the list of active linters. + " This may have already been done when the job exits. + call filter(l:info.active_linter_list, 'v:val isnot# a:linter_name') + endif " Make some adjustments to the loclists to fix common problems, and also " to set default values for loclist items. - let l:linter_loclist = ale#engine#FixLocList(a:buffer, a:linter_name, a:loclist) + let l:linter_loclist = ale#engine#FixLocList( + \ a:buffer, + \ a:linter_name, + \ a:from_other_source, + \ a:loclist, + \) " Remove previous items for this linter. call filter(l:info.loclist, 'v:val.linter_name isnot# a:linter_name') @@ -263,7 +272,7 @@ function! s:HandleExit(job_id, exit_code) abort let l:loclist = [] endtry - call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist) + call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist, 0) endfunction function! ale#engine#SetResults(buffer, loclist) abort @@ -335,7 +344,7 @@ function! s:RemapItemTypes(type_map, loclist) abort endfor endfunction -function! ale#engine#FixLocList(buffer, linter_name, loclist) abort +function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist) abort let l:bufnr_map = {} let l:new_loclist = [] @@ -368,6 +377,10 @@ function! ale#engine#FixLocList(buffer, linter_name, loclist) abort \ 'linter_name': a:linter_name, \} + if a:from_other_source + let l:item.from_other_source = 1 + endif + if has_key(l:old_item, 'code') let l:item.code = l:old_item.code endif @@ -691,6 +704,7 @@ endfunction function! s:RemoveProblemsForDisabledLinters(buffer, linters) abort " Figure out which linters are still enabled, and remove " problems for linters which are no longer enabled. + " Problems from other sources will be kept. let l:name_map = {} for l:linter in a:linters @@ -699,7 +713,7 @@ function! s:RemoveProblemsForDisabledLinters(buffer, linters) abort call filter( \ get(g:ale_buffer_info[a:buffer], 'loclist', []), - \ 'get(l:name_map, get(v:val, ''linter_name''))', + \ 'get(v:val, ''from_other_source'') || get(l:name_map, get(v:val, ''linter_name''))', \) endfunction diff --git a/autoload/ale/lsp/reset.vim b/autoload/ale/lsp/reset.vim index c7c97a47..2fc7f0a2 100644 --- a/autoload/ale/lsp/reset.vim +++ b/autoload/ale/lsp/reset.vim @@ -17,7 +17,7 @@ function! ale#lsp#reset#StopAllLSPs() abort for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype')) if !empty(l:linter.lsp) - call ale#engine#HandleLoclist(l:linter.name, l:buffer, []) + call ale#engine#HandleLoclist(l:linter.name, l:buffer, [], 0) endif endfor endfor diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim index 55190483..fa4d2f86 100644 --- a/autoload/ale/lsp_linter.vim +++ b/autoload/ale/lsp_linter.vim @@ -38,7 +38,7 @@ function! s:HandleLSPDiagnostics(conn_id, response) abort let l:loclist = ale#lsp#response#ReadDiagnostics(a:response) - call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist) + call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0) endfunction function! s:HandleTSServerDiagnostics(response, error_type) abort @@ -81,7 +81,7 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort let l:loclist = get(l:info, 'semantic_loclist', []) \ + get(l:info, 'syntax_loclist', []) - call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist) + call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0) endfunction function! s:HandleLSPErrorMessage(linter_name, response) abort diff --git a/autoload/ale/other_source.vim b/autoload/ale/other_source.vim new file mode 100644 index 00000000..1a092034 --- /dev/null +++ b/autoload/ale/other_source.vim @@ -0,0 +1,21 @@ +" Tell ALE that another source has started checking a buffer. +function! ale#other_source#StartChecking(buffer, linter_name) abort + call ale#engine#InitBufferInfo(a:buffer) + let l:list = g:ale_buffer_info[a:buffer].active_other_sources_list + + call add(l:list, a:linter_name) + call uniq(sort(l:list)) +endfunction + +" Show some results, and stop checking a buffer. +" To clear results or cancel checking a buffer, an empty List can be given. +function! ale#other_source#ShowResults(buffer, linter_name, loclist) abort + call ale#engine#InitBufferInfo(a:buffer) + let l:info = g:ale_buffer_info[a:buffer] + + " Remove this linter name from the active list. + let l:list = l:info.active_other_sources_list + call filter(l:list, 'v:val isnot# a:linter_name') + + call ale#engine#HandleLoclist(a:linter_name, a:buffer, a:loclist, 1) +endfunction |