mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-15 23:56:52 +08:00
The statusbar now keeps its state in a separate variable, in order to avoid excess iterations. The engine now updates said variable on run, and a new function is made available for external statusbars to call (to avoid dependencies on internal implementation details of ale). To keep things light, the status bar code is not loaded unless invoked by the user or an external plugin. On the first load it will update itself from the global loclist, after that, the engine will handle all updates. The external integration function, `ale#statusline#Count()`, will return a tuple in the format [E, W] (where E is errors, W is warnings), unless no data exists (ie, the plugin doesn't have a linter for a file or has not run yet), in which case it returns 0/false.
46 lines
1.2 KiB
VimL
46 lines
1.2 KiB
VimL
" Author: w0rp <devw0rp@gmail.com>
|
|
" Description: Contains miscellaneous functions
|
|
|
|
function! s:FindWrapperScript() abort
|
|
for l:parent in split(&runtimepath, ',')
|
|
" Expand the path to deal with ~ issues.
|
|
let l:path = expand(l:parent . '/' . 'stdin-wrapper')
|
|
|
|
if filereadable(l:path)
|
|
if has('win32')
|
|
return l:path . '.exe'
|
|
endif
|
|
|
|
return l:path
|
|
endif
|
|
endfor
|
|
endfunction
|
|
|
|
let g:ale#util#stdin_wrapper = s:FindWrapperScript()
|
|
|
|
" A null file for sending output to nothing.
|
|
let g:ale#util#nul_file = '/dev/null'
|
|
|
|
if has('win32')
|
|
let g:ale#util#nul_file = 'nul'
|
|
endif
|
|
|
|
" Return the number of lines for a given buffer.
|
|
function! ale#util#GetLineCount(buffer) abort
|
|
return len(getbufline(a:buffer, 1, '$'))
|
|
endfunction
|
|
|
|
" Given a buffer and a filename, find the nearest file by searching upwards
|
|
" through the paths relative to the given buffer.
|
|
function! ale#util#FindNearestFile(buffer, filename) abort
|
|
return findfile(a:filename, fnamemodify(bufname(a:buffer), ':p') . ';')
|
|
endfunction
|
|
|
|
function! ale#util#GetFunction(string_or_ref) abort
|
|
if type(a:string_or_ref) == type('')
|
|
return function(a:string_or_ref)
|
|
endif
|
|
|
|
return a:string_or_ref
|
|
endfunction
|