2016-10-03 18:41:02 +00:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
|
|
|
" Description: Echoes lint message for the current line, if any
|
|
|
|
|
2016-10-10 11:53:54 +00:00
|
|
|
" Return a formatted message according to g:ale_echo_msg_format variable
|
|
|
|
function! s:GetMessage(linter, type, text) abort
|
2016-10-10 23:00:09 +00:00
|
|
|
let l:msg = g:ale_echo_msg_format
|
|
|
|
let l:type = a:type ==# 'E'
|
2016-10-10 11:53:54 +00:00
|
|
|
\ ? g:ale_echo_msg_error_str
|
|
|
|
\ : g:ale_echo_msg_warning_str
|
|
|
|
" Capitalize the 1st character
|
2016-10-10 23:00:09 +00:00
|
|
|
let l:text = toupper(a:text[0]) . a:text[1:-1]
|
2016-10-10 11:53:54 +00:00
|
|
|
|
|
|
|
" Replace handlers if they exist
|
2016-10-10 23:00:09 +00:00
|
|
|
for [l:k, l:v] in items({'linter': a:linter, 'severity': l:type})
|
|
|
|
let l:msg = substitute(l:msg, '\V%' . l:k . '%', l:v, '')
|
2016-10-10 11:53:54 +00:00
|
|
|
endfor
|
|
|
|
|
2016-10-10 23:00:09 +00:00
|
|
|
return printf(l:msg, l:text)
|
2016-10-10 11:53:54 +00:00
|
|
|
endfunction
|
|
|
|
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
function! ale#cursor#TruncatedEcho(message) abort
|
2016-10-10 23:00:09 +00:00
|
|
|
let l:message = a:message
|
2016-09-08 23:23:26 +00:00
|
|
|
" Change tabs to spaces.
|
2016-10-10 23:00:09 +00:00
|
|
|
let l:message = substitute(l:message, "\t", ' ', 'g')
|
2016-09-08 23:23:26 +00:00
|
|
|
" Remove any newlines in the message.
|
2016-10-10 23:00:09 +00:00
|
|
|
let l:message = substitute(l:message, "\n", '', 'g')
|
2016-09-08 23:23:26 +00:00
|
|
|
|
2016-10-08 17:04:34 +00:00
|
|
|
" We need to turn T for truncated messages on for shortmess,
|
|
|
|
" and then then we need to reset the option back to what it was.
|
2016-10-10 23:00:09 +00:00
|
|
|
let l:shortmess_options = getbufvar('%', '&shortmess')
|
2016-10-08 17:04:34 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
" Echo the message truncated to fit without creating a prompt.
|
2016-10-10 13:02:39 +00:00
|
|
|
setlocal shortmess+=T
|
2016-10-16 15:09:01 +00:00
|
|
|
exec "norm! :echomsg message\n"
|
2016-10-08 17:04:34 +00:00
|
|
|
finally
|
2016-10-10 23:00:09 +00:00
|
|
|
call setbufvar('%', '&shortmess', l:shortmess_options)
|
2016-10-08 17:04:34 +00:00
|
|
|
endtry
|
2016-09-08 23:23:26 +00:00
|
|
|
endfunction
|
|
|
|
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
function! ale#cursor#EchoCursorWarning(...) abort
|
2016-10-09 11:50:45 +00:00
|
|
|
" Only echo the warnings in normal mode, otherwise we will get problems.
|
|
|
|
if mode() !=# 'n'
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
2016-10-10 23:00:09 +00:00
|
|
|
let l:buffer = bufnr('%')
|
2016-09-14 10:47:52 +00:00
|
|
|
|
2016-10-24 19:21:32 +00:00
|
|
|
if !has_key(g:ale_buffer_info, l:buffer)
|
2016-09-09 21:48:40 +00:00
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
2016-10-10 23:00:09 +00:00
|
|
|
let l:pos = getcurpos()
|
2016-10-24 19:21:32 +00:00
|
|
|
let l:loclist = g:ale_buffer_info[l:buffer].loclist
|
2016-10-13 20:24:47 +00:00
|
|
|
let l:index = ale#util#BinarySearch(l:loclist, l:pos[1], l:pos[2])
|
2016-09-14 10:47:52 +00:00
|
|
|
|
2016-10-10 23:00:09 +00:00
|
|
|
if l:index >= 0
|
|
|
|
let l:loc = l:loclist[l:index]
|
|
|
|
let l:msg = s:GetMessage(l:loc.linter_name, l:loc.type, l:loc.text)
|
|
|
|
call ale#cursor#TruncatedEcho(l:msg)
|
2016-10-24 19:55:20 +00:00
|
|
|
let g:ale_buffer_info[l:buffer].echoed = 1
|
2016-09-08 23:23:26 +00:00
|
|
|
else
|
2016-10-24 19:55:20 +00:00
|
|
|
" We'll only clear the echoed message when moving off errors once,
|
|
|
|
" so we don't continually clear the echo line.
|
|
|
|
if get(g:ale_buffer_info[l:buffer], 'echoed')
|
|
|
|
echo
|
|
|
|
let g:ale_buffer_info[l:buffer].echoed = 0
|
|
|
|
endif
|
2016-09-08 23:23:26 +00:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2016-09-15 09:57:11 +00:00
|
|
|
let s:cursor_timer = -1
|
2016-10-25 15:07:20 +00:00
|
|
|
let s:last_pos = [0, 0, 0]
|
2016-09-15 09:57:11 +00:00
|
|
|
|
First pass at optimizing ale to autoload (#80)
* First pass at optimizing ale to autoload
First off, the structure/function names should be revised a bit,
but I will wait for @w0rp's input before unifying the naming style.
Second off, the docs probably need some more work, I just did some
simple find-and-replace work.
With that said, this pull brings major performance gains for ale. On my
slowest system, fully loading ale and all its code takes around 150ms.
I have moved all of ale's autoload-able code to autoload/, and in
addition, implemented lazy-loading of linters. This brings load time on
that same system down to 5ms.
The only downside of lazy loading is that `g:ale_linters` cannot be
changed at runtime; however, it also speeds up performance at runtime by
simplfying the logic greatly.
Please let me know what you think!
Closes #59
* Address Travis/Vint errors
For some reason, ale isn't running vint for me...
* Incorporate feedback, make fixes
Lazy-loading logic is much improved.
* Add header comments; remove incorrect workaround
* Remove unneeded plugin guards
* Fix lazy-loading linter logic
Set the wrong variable....
* Fix capitialization
2016-10-10 18:51:29 +00:00
|
|
|
function! ale#cursor#EchoCursorWarningWithDelay() abort
|
2017-02-14 21:02:49 +00:00
|
|
|
if ale#ShouldDoNothing()
|
2016-10-31 14:47:08 +00:00
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
2016-09-15 09:57:11 +00:00
|
|
|
if s:cursor_timer != -1
|
|
|
|
call timer_stop(s:cursor_timer)
|
|
|
|
let s:cursor_timer = -1
|
|
|
|
endif
|
|
|
|
|
2016-10-25 15:07:20 +00:00
|
|
|
let l:pos = getcurpos()[0:2]
|
|
|
|
|
|
|
|
" Check the current buffer, line, and column number against the last
|
|
|
|
" recorded position. If the position has actually changed, *then*
|
|
|
|
" we should echo something. Otherwise we can end up doing processing
|
|
|
|
" the echo message far too frequently.
|
|
|
|
if l:pos != s:last_pos
|
|
|
|
let s:last_pos = l:pos
|
|
|
|
let s:cursor_timer = timer_start(10, function('ale#cursor#EchoCursorWarning'))
|
|
|
|
endif
|
2016-09-15 09:57:11 +00:00
|
|
|
endfunction
|