From 7f0ce89d2b574fd5bdd0c050eaad92deeb63086d Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Mon, 10 Oct 2016 13:51:29 -0500 Subject: 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 --- ale_linters/c/gcc.vim | 2 +- ale_linters/coffee/coffee.vim | 2 +- ale_linters/coffee/coffeelint.vim | 2 +- ale_linters/cpp/gcc.vim | 2 +- ale_linters/css/csslint.vim | 2 +- ale_linters/d/dmd.vim | 2 +- ale_linters/fortran/gcc.vim | 2 +- ale_linters/haskell/ghc.vim | 4 ++-- ale_linters/html/htmlhint.vim | 2 +- ale_linters/html/tidy.vim | 2 +- ale_linters/javascript/eslint.vim | 4 ++-- ale_linters/javascript/jscs.vim | 4 ++-- ale_linters/javascript/jshint.vim | 4 ++-- ale_linters/json/jsonlint.vim | 2 +- ale_linters/perl/perl.vim | 2 +- ale_linters/perl/perlcritic.vim | 2 +- ale_linters/php/php.vim | 2 +- ale_linters/php/phpcs.vim | 2 +- ale_linters/pug/puglint.vim | 2 +- ale_linters/pyrex/cython.vim | 2 +- ale_linters/python/flake8.vim | 2 +- ale_linters/ruby/rubocop.vim | 2 +- ale_linters/sass/sasslint.vim | 2 +- ale_linters/scala/scalac.vim | 2 +- ale_linters/scss/sasslint.vim | 2 +- ale_linters/scss/scsslint.vim | 2 +- ale_linters/sh/shell.vim | 2 +- ale_linters/sh/shellcheck.vim | 2 +- ale_linters/typescript/tslint.vim | 2 +- ale_linters/verilog/iverilog.vim | 2 +- ale_linters/verilog/verilator.vim | 2 +- ale_linters/vim/vint.vim | 2 +- ale_linters/yaml/yamllint.vim | 2 +- 33 files changed, 37 insertions(+), 37 deletions(-) (limited to 'ale_linters') diff --git a/ale_linters/c/gcc.vim b/ale_linters/c/gcc.vim index 500542d7..c22b5e88 100644 --- a/ale_linters/c/gcc.vim +++ b/ale_linters/c/gcc.vim @@ -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', diff --git a/ale_linters/coffee/coffee.vim b/ale_linters/coffee/coffee.vim index a19017c6..b2ad32b1 100644 --- a/ale_linters/coffee/coffee.vim +++ b/ale_linters/coffee/coffee.vim @@ -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', diff --git a/ale_linters/coffee/coffeelint.vim b/ale_linters/coffee/coffeelint.vim index 972fa25d..61f3dc81 100644 --- a/ale_linters/coffee/coffeelint.vim +++ b/ale_linters/coffee/coffeelint.vim @@ -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', diff --git a/ale_linters/cpp/gcc.vim b/ale_linters/cpp/gcc.vim index 31c3c245..0936a82e 100644 --- a/ale_linters/cpp/gcc.vim +++ b/ale_linters/cpp/gcc.vim @@ -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', diff --git a/ale_linters/css/csslint.vim b/ale_linters/css/csslint.vim index e212aecc..dbaed15b 100644 --- a/ale_linters/css/csslint.vim +++ b/ale_linters/css/csslint.vim @@ -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', diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim index 4c109e08..0fdf0bac 100644 --- a/ale_linters/d/dmd.vim +++ b/ale_linters/d/dmd.vim @@ -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', diff --git a/ale_linters/fortran/gcc.vim b/ale_linters/fortran/gcc.vim index 3e97fea9..fecaf39a 100644 --- a/ale_linters/fortran/gcc.vim +++ b/ale_linters/fortran/gcc.vim @@ -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', diff --git a/ale_linters/haskell/ghc.vim b/ale_linters/haskell/ghc.vim index 5af4bb3d..5c5dba10 100644 --- a/ale_linters/haskell/ghc.vim +++ b/ale_linters/haskell/ghc.vim @@ -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', diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim index 8cfe1f28..57eff0ec 100644 --- a/ale_linters/html/htmlhint.vim +++ b/ale_linters/html/htmlhint.vim @@ -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', diff --git a/ale_linters/html/tidy.vim b/ale_linters/html/tidy.vim index b5621f91..c1aab8f3 100644 --- a/ale_linters/html/tidy.vim +++ b/ale_linters/html/tidy.vim @@ -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', diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim index 94d14e6b..d140a957 100644 --- a/ale_linters/javascript/eslint.vim +++ b/ale_linters/javascript/eslint.vim @@ -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', diff --git a/ale_linters/javascript/jscs.vim b/ale_linters/javascript/jscs.vim index 263ea88d..9252eef3 100644 --- a/ale_linters/javascript/jscs.vim +++ b/ale_linters/javascript/jscs.vim @@ -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 -', diff --git a/ale_linters/javascript/jshint.vim b/ale_linters/javascript/jshint.vim index a020ca0c..11c60409 100644 --- a/ale_linters/javascript/jshint.vim +++ b/ale_linters/javascript/jshint.vim @@ -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', diff --git a/ale_linters/json/jsonlint.vim b/ale_linters/json/jsonlint.vim index 77145bcd..aaf56b6e 100644 --- a/ale_linters/json/jsonlint.vim +++ b/ale_linters/json/jsonlint.vim @@ -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', diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index ad33b6dc..c5300ac8 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -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', diff --git a/ale_linters/perl/perlcritic.vim b/ale_linters/perl/perlcritic.vim index 98ac83a8..64e1e3e4 100644 --- a/ale_linters/perl/perlcritic.vim +++ b/ale_linters/perl/perlcritic.vim @@ -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', diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim index 808a5ce6..57519a24 100644 --- a/ale_linters/php/php.vim +++ b/ale_linters/php/php.vim @@ -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', diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim index db7598fa..ed74b443 100644 --- a/ale_linters/php/phpcs.vim +++ b/ale_linters/php/phpcs.vim @@ -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', diff --git a/ale_linters/pug/puglint.vim b/ale_linters/pug/puglint.vim index d59c7f06..754c6bb4 100644 --- a/ale_linters/pug/puglint.vim +++ b/ale_linters/pug/puglint.vim @@ -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', diff --git a/ale_linters/pyrex/cython.vim b/ale_linters/pyrex/cython.vim index a0175ab4..0c393f95 100644 --- a/ale_linters/pyrex/cython.vim +++ b/ale_linters/pyrex/cython.vim @@ -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', diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim index 95ab2a28..aa114df6 100644 --- a/ale_linters/python/flake8.vim +++ b/ale_linters/python/flake8.vim @@ -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 -', diff --git a/ale_linters/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim index 1acb2636..17326a7e 100644 --- a/ale_linters/ruby/rubocop.vim +++ b/ale_linters/ruby/rubocop.vim @@ -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 _', diff --git a/ale_linters/sass/sasslint.vim b/ale_linters/sass/sasslint.vim index 3d7fbfc4..eb14ba9c 100644 --- a/ale_linters/sass/sasslint.vim +++ b/ale_linters/sass/sasslint.vim @@ -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', diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim index 7d7d14ab..06508107 100644 --- a/ale_linters/scala/scalac.vim +++ b/ale_linters/scala/scalac.vim @@ -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', diff --git a/ale_linters/scss/sasslint.vim b/ale_linters/scss/sasslint.vim index baf860b6..c0dd09c8 100644 --- a/ale_linters/scss/sasslint.vim +++ b/ale_linters/scss/sasslint.vim @@ -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', diff --git a/ale_linters/scss/scsslint.vim b/ale_linters/scss/scsslint.vim index 7f4c67ea..ac1c3796 100644 --- a/ale_linters/scss/scsslint.vim +++ b/ale_linters/scss/scsslint.vim @@ -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', diff --git a/ale_linters/sh/shell.vim b/ale_linters/sh/shell.vim index 07c5650c..b17f331a 100644 --- a/ale_linters/sh/shell.vim +++ b/ale_linters/sh/shell.vim @@ -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', diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim index 3bc9abe4..82ca5947 100644 --- a/ale_linters/sh/shellcheck.vim +++ b/ale_linters/sh/shellcheck.vim @@ -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 -', diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim index 16a6f352..ef147832 100644 --- a/ale_linters/typescript/tslint.vim +++ b/ale_linters/typescript/tslint.vim @@ -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', diff --git a/ale_linters/verilog/iverilog.vim b/ale_linters/verilog/iverilog.vim index d1eb51e3..02df6f84 100644 --- a/ale_linters/verilog/iverilog.vim +++ b/ale_linters/verilog/iverilog.vim @@ -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', diff --git a/ale_linters/verilog/verilator.vim b/ale_linters/verilog/verilator.vim index cc29f890..4878ad3e 100644 --- a/ale_linters/verilog/verilator.vim +++ b/ale_linters/verilog/verilator.vim @@ -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', diff --git a/ale_linters/vim/vint.vim b/ale_linters/vim/vint.vim index 5d4b10eb..32e64041 100644 --- a/ale_linters/vim/vint.vim +++ b/ale_linters/vim/vint.vim @@ -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, diff --git a/ale_linters/yaml/yamllint.vim b/ale_linters/yaml/yamllint.vim index 92a4313d..db01ccc4 100644 --- a/ale_linters/yaml/yamllint.vim +++ b/ale_linters/yaml/yamllint.vim @@ -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', -- cgit v1.2.3