summaryrefslogtreecommitdiff
path: root/autoload/ale.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-07-07 23:47:41 +0100
committerw0rp <devw0rp@gmail.com>2017-07-07 23:47:41 +0100
commit8eb4f95766350b7a1f80eae691f390faee045e6d (patch)
tree8d3973d0226c83d129fa8c2292befb5adf601759 /autoload/ale.vim
parent46225f3bb13a242bf3b218d395f3911f013d5f14 (diff)
downloadale-8eb4f95766350b7a1f80eae691f390faee045e6d.zip
#697 - Clear all highlights every time items are set again, and refactor most things. Clear errors when linters are removed
Diffstat (limited to 'autoload/ale.vim')
-rw-r--r--autoload/ale.vim44
1 files changed, 16 insertions, 28 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim
index 7cf1def6..5efe15ab 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -53,9 +53,17 @@ function! ale#Queue(delay, ...) abort
let s:lint_timer = -1
endif
- let l:linters = ale#linter#Get(&filetype)
- if len(l:linters) == 0
- " There are no linters to lint with, so stop here.
+ let l:buffer = bufnr('')
+ let l:linters = ale#linter#Get(getbufvar(l:buffer, '&filetype'))
+
+ " Don't set up buffer data and so on if there are no linters to run.
+ if empty(l:linters)
+ " If we have some previous buffer data, then stop any jobs currently
+ " running and clear everything.
+ if has_key(g:ale_buffer_info, l:buffer)
+ call ale#engine#RunLinters(l:buffer, [], 1)
+ endif
+
return
endif
@@ -68,16 +76,16 @@ function! ale#Queue(delay, ...) abort
endfunction
function! ale#Lint(...) abort
- if ale#ShouldDoNothing()
- return
- endif
-
" Get the buffer number linting was queued for.
" or else take the current one.
let l:buffer = len(a:0) > 1 && a:1 == s:lint_timer
\ ? s:queued_buffer_number
\ : bufnr('%')
+ if ale#ShouldDoNothing()
+ return
+ endif
+
" Use the filetype from the buffer
let l:linters = ale#linter#Get(getbufvar(l:buffer, '&filetype'))
let l:should_lint_file = 0
@@ -89,27 +97,7 @@ function! ale#Lint(...) abort
let l:should_lint_file = filereadable(expand('#' . l:buffer . ':p'))
endif
- " Initialise the buffer information if needed.
- call ale#engine#InitBufferInfo(l:buffer)
-
- " Clear the new loclist again, so we will work with all new items.
- let g:ale_buffer_info[l:buffer].new_loclist = []
-
- if l:should_lint_file
- " Clear loclist items for files if we are checking files again.
- let g:ale_buffer_info[l:buffer].lint_file_loclist = []
- else
- " Otherwise, don't run any `lint_file` linters
- " We will continue running any linters which are currently checking
- " the file, and the items will be mixed together with any new items.
- call filter(l:linters, '!v:val.lint_file')
- endif
-
- call ale#engine#StopCurrentJobs(l:buffer, l:should_lint_file)
-
- for l:linter in l:linters
- call ale#engine#Invoke(l:buffer, l:linter)
- endfor
+ call ale#engine#RunLinters(l:buffer, l:linters, l:should_lint_file)
endfunction
" Reset flags indicating that files should be checked for all buffers.