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
This commit is contained in:
Bjorn Neergaard
2016-10-10 13:51:29 -05:00
committed by w0rp
parent 0680f875fe
commit 7f0ce89d2b
44 changed files with 337 additions and 336 deletions

View File

@@ -12,7 +12,7 @@ if !exists('g:ale_c_gcc_options')
let g:ale_c_gcc_options = '-Wall'
endif
call ALEAddLinter('c', {
call ale#linter#Define('c', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable': 'gcc',

View File

@@ -7,7 +7,7 @@ endif
let g:loaded_ale_linters_coffee_coffee = 1
call ALEAddLinter('coffee', {
call ale#linter#Define('coffee', {
\ 'name': 'coffee',
\ 'executable': 'coffee',
\ 'command': 'coffee -cp -s',

View File

@@ -44,7 +44,7 @@ function! ale_linters#coffee#coffeelint#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('coffee', {
call ale#linter#Define('coffee', {
\ 'name': 'coffeelint',
\ 'executable': 'coffeelint',
\ 'command': 'coffeelint --stdin --reporter csv',

View File

@@ -12,7 +12,7 @@ if !exists('g:ale_cpp_gcc_options')
let g:ale_cpp_gcc_options = '-Wall'
endif
call ALEAddLinter('cpp', {
call ale#linter#Define('cpp', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable': 'gcc',

View File

@@ -7,7 +7,7 @@ endif
let g:loaded_ale_linters_css_csslint = 1
call ALEAddLinter('css', {
call ale#linter#Define('css', {
\ 'name': 'csslint',
\ 'executable': 'csslint',
\ 'command': g:ale#util#stdin_wrapper . ' .css csslint --format=compact',

View File

@@ -61,7 +61,7 @@ function! ale_linters#d#dmd#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('d', {
call ale#linter#Define('d', {
\ 'name': 'dmd',
\ 'output_stream': 'stderr',
\ 'executable': 'dmd',

View File

@@ -60,7 +60,7 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('fortran', {
call ale#linter#Define('fortran', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable': 'gcc',

View File

@@ -58,7 +58,7 @@ function! ale_linters#haskell#ghc#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('haskell', {
call ale#linter#Define('haskell', {
\ 'name': 'ghc',
\ 'output_stream': 'stderr',
\ 'executable': 'ghc',
@@ -66,7 +66,7 @@ call ALEAddLinter('haskell', {
\ 'callback': 'ale_linters#haskell#ghc#Handle',
\})
call ALEAddLinter('haskell', {
call ale#linter#Define('haskell', {
\ 'name': 'stack-ghc',
\ 'output_stream': 'stderr',
\ 'executable': 'stack',

View File

@@ -40,7 +40,7 @@ function! ale_linters#html#htmlhint#Handle(buffer, lines) abort
return output
endfunction
call ALEAddLinter('html', {
call ale#linter#Define('html', {
\ 'name': 'htmlhint',
\ 'executable': 'htmlhint',
\ 'command': 'htmlhint --format=unix stdin',

View File

@@ -71,7 +71,7 @@ function! ale_linters#html#tidy#Handle(buffer, lines) abort
return output
endfunction
call ALEAddLinter('html', {
call ale#linter#Define('html', {
\ 'name': 'tidy',
\ 'executable': g:ale_html_tidy_executable,
\ 'output_stream': 'stderr',

View File

@@ -49,14 +49,14 @@ function! ale_linters#javascript#eslint#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('javascript', {
call ale#linter#Define('javascript', {
\ 'name': 'eslint',
\ 'executable': g:ale_javascript_eslint_executable,
\ 'command': g:ale_javascript_eslint_executable . ' -f unix --stdin --stdin-filename %s',
\ 'callback': 'ale_linters#javascript#eslint#Handle',
\})
call ALEAddLinter('javascript.jsx', {
call ale#linter#Define('javascript.jsx', {
\ 'name': 'eslint',
\ 'executable': g:ale_javascript_eslint_executable,
\ 'command': g:ale_javascript_eslint_executable . ' -f unix --stdin --stdin-filename %s',

View File

@@ -43,14 +43,14 @@ function! ale_linters#javascript#jscs#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('javascript', {
call ale#linter#Define('javascript', {
\ 'name': 'jscs',
\ 'executable': 'jscs',
\ 'command': 'jscs -r unix -n -',
\ 'callback': 'ale_linters#javascript#jscs#Handle',
\})
call ALEAddLinter('javascript.jsx', {
call ale#linter#Define('javascript.jsx', {
\ 'name': 'jscs',
\ 'executable': 'jscs',
\ 'command': 'jscs -r unix -n -',

View File

@@ -70,14 +70,14 @@ function! ale_linters#javascript#jshint#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('javascript', {
call ale#linter#Define('javascript', {
\ 'name': 'jshint',
\ 'executable': g:ale_javascript_jshint_executable,
\ 'command_callback': 'ale_linters#javascript#jshint#GetCommand',
\ 'callback': 'ale_linters#javascript#jshint#Handle',
\})
call ALEAddLinter('javascript.jsx', {
call ale#linter#Define('javascript.jsx', {
\ 'name': 'jshint',
\ 'executable': g:ale_javascript_jshint_executable,
\ 'command_callback': 'ale_linters#javascript#jshint#GetCommand',

View File

@@ -35,7 +35,7 @@ function! ale_linters#json#jsonlint#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('json', {
call ale#linter#Define('json', {
\ 'name': 'jsonlint',
\ 'executable': 'jsonlint',
\ 'output_stream': 'stderr',

View File

@@ -37,7 +37,7 @@ function! ale_linters#perl#perl#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('perl', {
call ale#linter#Define('perl', {
\ 'name': 'perl',
\ 'executable': 'perl',
\ 'output_stream': 'both',

View File

@@ -37,7 +37,7 @@ function! ale_linters#perl#perlcritic#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('perl', {
call ale#linter#Define('perl', {
\ 'name': 'perlcritic',
\ 'executable': 'perlcritic',
\ 'output_stream': 'sdtout',

View File

@@ -36,7 +36,7 @@ function! ale_linters#php#php#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('php', {
call ale#linter#Define('php', {
\ 'name': 'php',
\ 'executable': 'php',
\ 'output_stream': 'both',

View File

@@ -50,7 +50,7 @@ function! ale_linters#php#phpcs#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('php', {
call ale#linter#Define('php', {
\ 'name': 'phpcs',
\ 'executable': 'phpcs',
\ 'command_callback': 'ale_linters#php#phpcs#GetCommand',

View File

@@ -35,7 +35,7 @@ function! ale_linters#pug#puglint#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('pug', {
call ale#linter#Define('pug', {
\ 'name': 'puglint',
\ 'executable': 'pug-lint',
\ 'output_stream': 'stderr',

View File

@@ -34,7 +34,7 @@ function! ale_linters#pyrex#cython#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('pyrex', {
call ale#linter#Define('pyrex', {
\ 'name': 'cython',
\ 'output_stream': 'stderr',
\ 'executable': 'cython',

View File

@@ -47,7 +47,7 @@ function! ale_linters#python#flake8#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('python', {
call ale#linter#Define('python', {
\ 'name': 'flake8',
\ 'executable': 'flake8',
\ 'command': 'flake8 -',

View File

@@ -40,7 +40,7 @@ function! ale_linters#ruby#rubocop#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('ruby', {
call ale#linter#Define('ruby', {
\ 'name': 'rubocop',
\ 'executable': 'rubocop',
\ 'command': 'rubocop --format emacs --stdin _',

View File

@@ -6,7 +6,7 @@ endif
let g:loaded_ale_linters_sass_sasslint = 1
call ALEAddLinter('sass', {
call ale#linter#Define('sass', {
\ 'name': 'sasslint',
\ 'executable': 'sass-lint',
\ 'command': g:ale#util#stdin_wrapper . ' .sass sass-lint -v -q -f compact',

View File

@@ -49,7 +49,7 @@ function! ale_linters#scala#scalac#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('scala', {
call ale#linter#Define('scala', {
\ 'name': 'scalac',
\ 'executable': 'scalac',
\ 'output_stream': 'stderr',

View File

@@ -6,7 +6,7 @@ endif
let g:loaded_ale_linters_scss_sasslint = 1
call ALEAddLinter('scss', {
call ale#linter#Define('scss', {
\ 'name': 'sasslint',
\ 'executable': 'sass-lint',
\ 'command': g:ale#util#stdin_wrapper . ' .scss sass-lint -v -q -f compact',

View File

@@ -41,7 +41,7 @@ function! ale_linters#scss#scsslint#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('scss', {
call ale#linter#Define('scss', {
\ 'name': 'scsslint',
\ 'executable': 'scss-lint',
\ 'command': 'scss-lint --stdin-file-path=%s',

View File

@@ -74,7 +74,7 @@ function! ale_linters#sh#shell#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('sh', {
call ale#linter#Define('sh', {
\ 'name': 'shell',
\ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#sh#shell#GetExecutable',

View File

@@ -22,7 +22,7 @@ else
let s:exclude_option = ''
endif
call ALEAddLinter('sh', {
call ale#linter#Define('sh', {
\ 'name': 'shellcheck',
\ 'executable': 'shellcheck',
\ 'command': 'shellcheck ' . s:exclude_option . ' -f gcc -',

View File

@@ -43,7 +43,7 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('typescript', {
call ale#linter#Define('typescript', {
\ 'name': 'tslint',
\ 'executable': 'tslint',
\ 'command': g:ale#util#stdin_wrapper . ' .ts tslint',

View File

@@ -42,7 +42,7 @@ function! ale_linters#verilog#iverilog#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('verilog', {
call ale#linter#Define('verilog', {
\ 'name': 'iverilog',
\ 'output_stream': 'stderr',
\ 'executable': 'iverilog',

View File

@@ -44,7 +44,7 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('verilog', {
call ale#linter#Define('verilog', {
\ 'name': 'verilator',
\ 'output_stream': 'stderr',
\ 'executable': 'verilator',

View File

@@ -9,7 +9,7 @@ let g:loaded_ale_linters_vim_vint = 1
let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})'
call ALEAddLinter('vim', {
call ale#linter#Define('vim', {
\ 'name': 'vint',
\ 'executable': 'vint',
\ 'command': g:ale#util#stdin_wrapper . ' .vim vint -w --no-color ' . s:format,

View File

@@ -40,7 +40,7 @@ function! ale_linters#yaml#yamllint#Handle(buffer, lines)
return output
endfunction
call ALEAddLinter('yaml', {
call ale#linter#Define('yaml', {
\ 'name': 'yamllint',
\ 'executable': 'yamllint',
\ 'command': g:ale#util#stdin_wrapper . ' .yml yamllint -f parsable',