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 14:51:29 -04:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
|
|
|
" Description: Linter registration and lazy-loading
|
|
|
|
" Retrieves linters as requested by the engine, loading them if needed.
|
|
|
|
|
|
|
|
let s:linters = {}
|
|
|
|
|
2016-10-11 18:11:45 -04:00
|
|
|
" Default filetype aliaes.
|
|
|
|
" The user defined aliases will be merged with this Dictionary.
|
|
|
|
let s:default_ale_linter_aliases = {
|
2017-02-02 17:26:46 -05:00
|
|
|
\ 'Dockerfile': 'dockerfile',
|
2016-10-11 18:11:45 -04:00
|
|
|
\ 'csh': 'sh',
|
2016-12-04 18:13:57 -05:00
|
|
|
\ 'plaintex': 'tex',
|
|
|
|
\ 'systemverilog': 'verilog',
|
2017-02-02 17:26:46 -05:00
|
|
|
\ 'zsh': 'sh',
|
2016-10-11 18:11:45 -04:00
|
|
|
\}
|
|
|
|
|
|
|
|
" Default linters to run for particular filetypes.
|
|
|
|
" The user defined linter selections will be merged with this Dictionary.
|
2016-12-22 06:32:20 -05:00
|
|
|
"
|
|
|
|
" No linters are used for plaintext files by default.
|
2017-02-15 17:59:26 -05:00
|
|
|
"
|
|
|
|
" Only cargo is enabled for Rust by default.
|
2017-04-20 11:55:20 -04:00
|
|
|
" rpmlint is disabled by default because it can result in code execution.
|
2016-10-11 18:11:45 -04:00
|
|
|
let s:default_ale_linters = {
|
|
|
|
\ 'csh': ['shell'],
|
2017-04-15 16:04:43 -04:00
|
|
|
\ 'go': ['go build', 'gofmt', 'golint', 'gosimple', 'go vet', 'staticcheck'],
|
2017-03-01 19:06:09 -05:00
|
|
|
\ 'help': [],
|
2017-02-15 17:59:26 -05:00
|
|
|
\ 'rust': ['cargo'],
|
2017-04-20 11:55:20 -04:00
|
|
|
\ 'spec': [],
|
2016-12-22 06:32:20 -05:00
|
|
|
\ 'text': [],
|
2017-02-15 17:59:26 -05:00
|
|
|
\ 'zsh': ['shell'],
|
2016-10-11 18:11:45 -04:00
|
|
|
\}
|
|
|
|
|
2016-10-21 22:02:20 -04:00
|
|
|
" Testing/debugging helper to unload all linters.
|
|
|
|
function! ale#linter#Reset() abort
|
|
|
|
let s:linters = {}
|
|
|
|
endfunction
|
|
|
|
|
2016-10-25 15:25:23 -04:00
|
|
|
function! s:IsCallback(value) abort
|
|
|
|
return type(a:value) == type('') || type(a:value) == type(function('type'))
|
|
|
|
endfunction
|
|
|
|
|
2017-02-09 18:32:57 -05:00
|
|
|
function! s:IsBoolean(value) abort
|
|
|
|
return type(a:value) == type(0) && (a:value == 0 || a:value == 1)
|
|
|
|
endfunction
|
|
|
|
|
2016-10-25 15:25:23 -04:00
|
|
|
function! ale#linter#PreProcess(linter) abort
|
|
|
|
if type(a:linter) != type({})
|
|
|
|
throw 'The linter object must be a Dictionary'
|
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 14:51:29 -04:00
|
|
|
endif
|
|
|
|
|
2016-10-25 15:25:23 -04:00
|
|
|
let l:obj = {
|
|
|
|
\ 'name': get(a:linter, 'name'),
|
|
|
|
\ 'callback': get(a:linter, 'callback'),
|
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 14:51:29 -04:00
|
|
|
\}
|
|
|
|
|
2016-10-25 15:25:23 -04:00
|
|
|
if type(l:obj.name) != type('')
|
|
|
|
throw '`name` must be defined to name the linter'
|
|
|
|
endif
|
|
|
|
|
|
|
|
if !s:IsCallback(l:obj.callback)
|
|
|
|
throw '`callback` must be defined with a callback to accept output'
|
|
|
|
endif
|
|
|
|
|
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 14:51:29 -04:00
|
|
|
if has_key(a:linter, 'executable_callback')
|
2016-10-25 15:25:23 -04:00
|
|
|
let l:obj.executable_callback = a:linter.executable_callback
|
|
|
|
|
|
|
|
if !s:IsCallback(l:obj.executable_callback)
|
|
|
|
throw '`executable_callback` must be a callback if defined'
|
|
|
|
endif
|
|
|
|
elseif has_key(a:linter, 'executable')
|
|
|
|
let l:obj.executable = a:linter.executable
|
|
|
|
|
|
|
|
if type(l:obj.executable) != type('')
|
|
|
|
throw '`executable` must be a string if defined'
|
|
|
|
endif
|
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 14:51:29 -04:00
|
|
|
else
|
2016-10-25 15:25:23 -04:00
|
|
|
throw 'Either `executable` or `executable_callback` must be defined'
|
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 14:51:29 -04:00
|
|
|
endif
|
|
|
|
|
2017-02-04 13:30:30 -05:00
|
|
|
if has_key(a:linter, 'command_chain')
|
|
|
|
let l:obj.command_chain = a:linter.command_chain
|
|
|
|
|
|
|
|
if type(l:obj.command_chain) != type([])
|
|
|
|
throw '`command_chain` must be a List'
|
|
|
|
endif
|
|
|
|
|
|
|
|
if empty(l:obj.command_chain)
|
|
|
|
throw '`command_chain` must contain at least one item'
|
|
|
|
endif
|
|
|
|
|
|
|
|
let l:link_index = 0
|
|
|
|
|
|
|
|
for l:link in l:obj.command_chain
|
|
|
|
let l:err_prefix = 'The `command_chain` item ' . l:link_index . ' '
|
|
|
|
|
|
|
|
if !s:IsCallback(get(l:link, 'callback'))
|
|
|
|
throw l:err_prefix . 'must define a `callback` function'
|
|
|
|
endif
|
|
|
|
|
|
|
|
if has_key(l:link, 'output_stream')
|
|
|
|
if type(l:link.output_stream) != type('')
|
|
|
|
\|| index(['stdout', 'stderr', 'both'], l:link.output_stream) < 0
|
|
|
|
throw l:err_prefix . '`output_stream` flag must be '
|
|
|
|
\ . "'stdout', 'stderr', or 'both'"
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2017-02-09 18:32:57 -05:00
|
|
|
if has_key(l:link, 'read_buffer') && !s:IsBoolean(l:link.read_buffer)
|
|
|
|
throw l:err_prefix . 'value for `read_buffer` must be `0` or `1`'
|
|
|
|
endif
|
|
|
|
|
2017-02-04 13:30:30 -05:00
|
|
|
let l:link_index += 1
|
|
|
|
endfor
|
|
|
|
elseif has_key(a:linter, 'command_callback')
|
2016-10-25 15:25:23 -04:00
|
|
|
let l:obj.command_callback = a:linter.command_callback
|
|
|
|
|
|
|
|
if !s:IsCallback(l:obj.command_callback)
|
|
|
|
throw '`command_callback` must be a callback if defined'
|
|
|
|
endif
|
|
|
|
elseif has_key(a:linter, 'command')
|
|
|
|
let l:obj.command = a:linter.command
|
|
|
|
|
|
|
|
if type(l:obj.command) != type('')
|
|
|
|
throw '`command` must be a string if defined'
|
|
|
|
endif
|
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 14:51:29 -04:00
|
|
|
else
|
2016-10-25 15:25:23 -04:00
|
|
|
throw 'Either `command`, `executable_callback`, `command_chain` '
|
|
|
|
\ . 'must be defined'
|
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 14:51:29 -04:00
|
|
|
endif
|
|
|
|
|
2017-02-09 15:44:13 -05:00
|
|
|
if (
|
|
|
|
\ has_key(a:linter, 'command')
|
|
|
|
\ + has_key(a:linter, 'command_chain')
|
|
|
|
\ + has_key(a:linter, 'command_callback')
|
|
|
|
\) > 1
|
|
|
|
throw 'Only one of `command`, `command_callback`, or `command_chain` '
|
|
|
|
\ . 'should be set'
|
|
|
|
endif
|
|
|
|
|
2016-10-25 15:25:23 -04:00
|
|
|
let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout')
|
|
|
|
|
|
|
|
if type(l:obj.output_stream) != type('')
|
|
|
|
\|| index(['stdout', 'stderr', 'both'], l:obj.output_stream) < 0
|
|
|
|
throw "`output_stream` must be 'stdout', 'stderr', or 'both'"
|
|
|
|
endif
|
|
|
|
|
2017-03-07 19:23:14 -05:00
|
|
|
" An option indicating that this linter should only be run against the
|
|
|
|
" file on disk.
|
|
|
|
let l:obj.lint_file = get(a:linter, 'lint_file', 0)
|
|
|
|
|
|
|
|
if !s:IsBoolean(l:obj.lint_file)
|
|
|
|
throw '`lint_file` must be `0` or `1`'
|
|
|
|
endif
|
|
|
|
|
2017-02-09 18:32:57 -05:00
|
|
|
" An option indicating that the buffer should be read.
|
2017-03-07 19:23:14 -05:00
|
|
|
let l:obj.read_buffer = get(a:linter, 'read_buffer', !l:obj.lint_file)
|
2017-02-09 18:32:57 -05:00
|
|
|
|
|
|
|
if !s:IsBoolean(l:obj.read_buffer)
|
|
|
|
throw '`read_buffer` must be `0` or `1`'
|
|
|
|
endif
|
|
|
|
|
2017-03-07 19:23:14 -05:00
|
|
|
if l:obj.lint_file && l:obj.read_buffer
|
|
|
|
throw 'Only one of `lint_file` or `read_buffer` can be `1`'
|
|
|
|
endif
|
|
|
|
|
2016-10-25 15:25:23 -04:00
|
|
|
return l:obj
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale#linter#Define(filetype, linter) abort
|
|
|
|
if !has_key(s:linters, a:filetype)
|
|
|
|
let s:linters[a:filetype] = []
|
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 14:51:29 -04:00
|
|
|
endif
|
|
|
|
|
2016-10-25 15:25:23 -04:00
|
|
|
let l:new_linter = ale#linter#PreProcess(a:linter)
|
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 14:51:29 -04:00
|
|
|
|
2016-10-10 19:00:09 -04:00
|
|
|
call add(s:linters[a:filetype], l:new_linter)
|
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 14:51:29 -04:00
|
|
|
endfunction
|
|
|
|
|
2017-04-11 16:10:08 -04:00
|
|
|
function! ale#linter#GetAll(filetypes) abort
|
|
|
|
let l:combined_linters = []
|
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 14:51:29 -04:00
|
|
|
|
2017-04-11 16:10:08 -04:00
|
|
|
for l:filetype in a:filetypes
|
2017-04-15 07:13:31 -04:00
|
|
|
" Load linter defintions from files if we haven't loaded them yet.
|
2017-04-11 16:10:08 -04:00
|
|
|
if !has_key(s:linters, l:filetype)
|
|
|
|
execute 'silent! runtime! ale_linters/' . l:filetype . '/*.vim'
|
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 14:51:29 -04:00
|
|
|
|
2017-04-15 07:13:31 -04:00
|
|
|
" Always set an empty List for the loaded linters if we don't find
|
|
|
|
" any. This will prevent us from executing the runtime command
|
|
|
|
" many times, redundantly.
|
2017-04-11 16:10:08 -04:00
|
|
|
if !has_key(s:linters, l:filetype)
|
|
|
|
let s:linters[l:filetype] = []
|
|
|
|
endif
|
|
|
|
endif
|
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 14:51:29 -04:00
|
|
|
|
2017-04-11 16:10:08 -04:00
|
|
|
call extend(l:combined_linters, get(s:linters, l:filetype, []))
|
|
|
|
endfor
|
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 14:51:29 -04:00
|
|
|
|
2017-04-11 16:10:08 -04:00
|
|
|
return l:combined_linters
|
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 14:51:29 -04:00
|
|
|
endfunction
|
2016-10-11 18:11:45 -04:00
|
|
|
|
2017-02-13 17:11:35 -05:00
|
|
|
function! ale#linter#ResolveFiletype(original_filetype) abort
|
2017-01-24 10:50:49 -05:00
|
|
|
" Try and get an aliased file type either from the user's Dictionary, or
|
|
|
|
" our default Dictionary, otherwise use the filetype as-is.
|
|
|
|
let l:filetype = get(
|
|
|
|
\ g:ale_linter_aliases,
|
|
|
|
\ a:original_filetype,
|
|
|
|
\ get(
|
|
|
|
\ s:default_ale_linter_aliases,
|
|
|
|
\ a:original_filetype,
|
|
|
|
\ a:original_filetype
|
|
|
|
\ )
|
|
|
|
\)
|
|
|
|
|
2017-04-11 16:10:08 -04:00
|
|
|
if type(l:filetype) != type([])
|
|
|
|
return [l:filetype]
|
|
|
|
endif
|
|
|
|
|
2017-01-24 10:50:49 -05:00
|
|
|
return l:filetype
|
|
|
|
endfunction
|
|
|
|
|
2016-10-21 22:02:20 -04:00
|
|
|
function! ale#linter#Get(original_filetypes) abort
|
2016-10-11 18:11:45 -04:00
|
|
|
let l:combined_linters = []
|
|
|
|
|
2016-10-21 22:02:20 -04:00
|
|
|
" Handle dot-seperated filetypes.
|
|
|
|
for l:original_filetype in split(a:original_filetypes, '\.')
|
2017-02-13 17:11:35 -05:00
|
|
|
let l:filetype = ale#linter#ResolveFiletype(l:original_filetype)
|
2016-10-21 22:02:20 -04:00
|
|
|
|
|
|
|
" Try and get a list of linters to run, using the original file type,
|
|
|
|
" not the aliased filetype. We have some linters to limit by default,
|
|
|
|
" and users may define their own list of linters to run.
|
|
|
|
let l:linter_names = get(
|
|
|
|
\ g:ale_linters,
|
|
|
|
\ l:original_filetype,
|
|
|
|
\ get(
|
|
|
|
\ s:default_ale_linters,
|
|
|
|
\ l:original_filetype,
|
|
|
|
\ 'all'
|
|
|
|
\ )
|
|
|
|
\)
|
|
|
|
|
2017-01-24 10:50:49 -05:00
|
|
|
let l:all_linters = ale#linter#GetAll(l:filetype)
|
2016-10-21 22:02:20 -04:00
|
|
|
let l:filetype_linters = []
|
|
|
|
|
|
|
|
if type(l:linter_names) == type('') && l:linter_names ==# 'all'
|
|
|
|
let l:filetype_linters = l:all_linters
|
|
|
|
elseif type(l:linter_names) == type([])
|
|
|
|
" Select only the linters we or the user has specified.
|
|
|
|
for l:linter in l:all_linters
|
|
|
|
if index(l:linter_names, l:linter.name) >= 0
|
|
|
|
call add(l:filetype_linters, l:linter)
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endif
|
|
|
|
|
|
|
|
call extend(l:combined_linters, l:filetype_linters)
|
|
|
|
endfor
|
2016-10-11 18:11:45 -04:00
|
|
|
|
|
|
|
return l:combined_linters
|
|
|
|
endfunction
|