From c546f47cc0c003053fb157b0ca2cced46b5429bc Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 24 Oct 2016 20:21:32 +0100 Subject: Merge everything into the one global map. --- autoload/ale/cleanup.vim | 4 ---- autoload/ale/cursor.vim | 4 ++-- autoload/ale/engine.vim | 22 ++++++++++++++++------ autoload/ale/statusline.vim | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) (limited to 'autoload') diff --git a/autoload/ale/cleanup.vim b/autoload/ale/cleanup.vim index 40a8a359..0a1cd391 100644 --- a/autoload/ale/cleanup.vim +++ b/autoload/ale/cleanup.vim @@ -2,10 +2,6 @@ " Description: Utility functions related to cleaning state. function! ale#cleanup#Buffer(buffer) abort - if has_key(g:ale_buffer_loclist_map, a:buffer) - call remove(g:ale_buffer_loclist_map, a:buffer) - endif - if has_key(g:ale_buffer_info, a:buffer) " When buffers are removed, clear all of the jobs. for l:job in get(g:ale_buffer_info[a:buffer], 'job_list', []) diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim index a20212c1..7f490339 100644 --- a/autoload/ale/cursor.vim +++ b/autoload/ale/cursor.vim @@ -46,12 +46,12 @@ function! ale#cursor#EchoCursorWarning(...) abort let l:buffer = bufnr('%') - if !has_key(g:ale_buffer_loclist_map, l:buffer) + if !has_key(g:ale_buffer_info, l:buffer) return endif let l:pos = getcurpos() - let l:loclist = g:ale_buffer_loclist_map[l:buffer] + let l:loclist = g:ale_buffer_info[l:buffer].loclist let l:index = ale#util#BinarySearch(l:loclist, l:pos[1], l:pos[2]) if l:index >= 0 diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 5a257505..9af1f536 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -26,6 +26,7 @@ function! ale#engine#InitBufferInfo(buffer) abort \ 'job_list': [], \ 'should_reset': 1, \ 'dummy_sign_set': 0, + \ 'loclist': [], \} endif endfunction @@ -121,28 +122,28 @@ function! s:HandleExit(job) abort " Set the flag for resetting the loclist to 0 again, so we won't " empty the list later. let g:ale_buffer_info[l:buffer].should_reset = 0 - let g:ale_buffer_loclist_map[l:buffer] = [] + let g:ale_buffer_info[l:buffer].loclist = [] endif " Add the loclist items from the linter. - call extend(g:ale_buffer_loclist_map[l:buffer], l:linter_loclist) + call extend(g:ale_buffer_info[l:buffer].loclist, l:linter_loclist) " Sort the loclist again. " We need a sorted list so we can run a binary search against it " for efficient lookup of the messages in the cursor handler. - call sort(g:ale_buffer_loclist_map[l:buffer], 'ale#util#LocItemCompare') + call sort(g:ale_buffer_info[l:buffer].loclist, 'ale#util#LocItemCompare') if g:ale_set_loclist - call setloclist(0, g:ale_buffer_loclist_map[l:buffer]) + call setloclist(0, g:ale_buffer_info[l:buffer].loclist) endif if g:ale_set_signs - call ale#sign#SetSigns(l:buffer, g:ale_buffer_loclist_map[l:buffer]) + call ale#sign#SetSigns(l:buffer, g:ale_buffer_info[l:buffer].loclist) endif if exists('*ale#statusline#Update') " Don't load/run if not already loaded. - call ale#statusline#Update(l:buffer, g:ale_buffer_loclist_map[l:buffer]) + call ale#statusline#Update(l:buffer, g:ale_buffer_info[l:buffer].loclist) endif " Call user autocommands. This allows users to hook into ALE's lint cycle. @@ -281,6 +282,15 @@ function! ale#engine#Invoke(buffer, linter) abort endif endfunction +" Given a buffer number, return the warnings and errors for a given buffer. +function! ale#engine#GetLoclist(buffer) abort + if !has_key(g:ale_buffer_info, a:buffer) + return [] + endif + + return g:ale_buffer_info[a:buffer].loclist +endfunction + " This function can be called with a timeout to wait for all jobs to finish. " If the jobs to not finish in the given number of milliseconds, " an exception will be thrown. diff --git a/autoload/ale/statusline.vim b/autoload/ale/statusline.vim index 48b4d687..c01dd34d 100644 --- a/autoload/ale/statusline.vim +++ b/autoload/ale/statusline.vim @@ -27,7 +27,7 @@ function! s:SetupCount(buffer) abort " Cache is cold, so manually ask for an update. if !has_key(g:ale_buffer_info[a:buffer], 'count') - call ale#statusline#Update(a:buffer, get(g:ale_buffer_loclist_map, a:buffer, [])) + call ale#statusline#Update(a:buffer, g:ale_buffer_info[a:buffer].loclist) endif return 1 -- cgit v1.2.3