Ale: Linting errors / fix results take 2-3 seconds to show

Created on 27 Sep 2018  路  10Comments  路  Source: dense-analysis/ale

Information

Vim Version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 30 2018 07:42:53)
macOS version
Included patches: 1-1650
Compiled by Homebrew

Operating System: macOS Sierra (10.12.6)

:ALEInfo

 Current Filetype: javascript.jsx
Available Linters: ['eslint', 'flow', 'flow-language-server', 'jscs', 'jshint', 'standard', 'tsserver', 'xo']
  Enabled Linters: ['eslint']
 Suggested Fixers: 
  'eslint' - Apply eslint --fix to a file.
  'importjs' - automatic imports for javascript
  'prettier' - Apply prettier to a file.
  'prettier_eslint', 'prettier-eslint' - Apply prettier-eslint to a file.
  'prettier_standard', 'prettier-standard' - Apply prettier-standard to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'standard' - Fix JavaScript files using standard --fix
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
  'xo' - Fix JavaScript files using xo --fix.
 Linter Variables:

let g:ale_javascript_eslint_executable = 'eslint'
let g:ale_javascript_eslint_options = ''
let g:ale_javascript_eslint_suppress_eslintignore = 0
let g:ale_javascript_eslint_suppress_missing_config = 0
let g:ale_javascript_eslint_use_global = 0
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {'json': ['prettier'], 'javascript': ['prettier', 'eslint']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 0
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_lint_on_insert_leave = 0
let g:ale_linter_aliases = {}
let g:ale_linters = {'javascript': ['eslint']}
let g:ale_linters_explicit = 0
let g:ale_list_window_size = 10
let g:ale_list_vertical = 0
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) /Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js
(finished - exit code 0) ['sh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/4/Search.js''']

<<<NO OUTPUT RETURNED>>>

(started) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/5/Search.js''']
(started) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/6/Search.js''']
(started) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/7/Search.js''']
(started) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/8/Search.js''']
(started) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/9/Search.js''']
(started) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/10/Search.js''']
(finished - exit code 1) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/11/Search.js''']

<<<OUTPUT STARTS>>>
/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js:6:1: More than 1 blank line not allowed. [Error/no-multiple-empty-lines]
/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js:9:12: Multiple spaces found before 'onClick'. [Error/no-multi-spaces]

2 problems
<<<OUTPUT ENDS>>>

(finished - exit code 0) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/.bin/prettier'' --version']
(finished - exit code 0) ['/bin/zsh', '-c', 'cd ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons'' && ''/Users/sgunnells/dev/lochinvar/client/node_modules/.bin/prettier'' --stdin-filepath ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' --stdin < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/12/Search.js''']
(finished - exit code 0) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' --version']
(finished - exit code 0) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' --stdin --fix-dry-run --format=json < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/13/Search.js''']
(finished - exit code 0) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/14/Search.js''']

<<<NO OUTPUT RETURNED>>>

(finished - exit code 0) ['/bin/zsh', '-c', '''/Users/sgunnells/dev/lochinvar/client/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/sgunnells/dev/lochinvar/client/src/components/global/icons/Search.js'' < ''/var/folders/_r/flm7f2j1733_yzr51bzpyx_80000gp/T/veQicZe/15/Search.js''']

<<<NO OUTPUT RETURNED>>>

What went wrong

This isn't truly a bug. The linter and fixes are all working fine it seems. I am simply trying to figure out why the UI isn't updating as fast as it seems like it should. (I've also tried this in Mac Vim with similar results so it doesn't seem to be the rendering process itself.) I've profiled my vim and everything seems to be happening very quickly. ALEs functions themselves seem to be completing in less than a second. I've also tried running the commands that ALE runs to do the linting and they seem to be very fast as well.

I just hope that I'm not asking too much of vim for it to be as responsive as, say, Atom or VSCode. In my tests using them, the UI updates within a second without fail. Any help that could be offered in helping me get a faster response time would be much appreciated. Or just tell me off if I'm expecting too much.

Reproducing the bug

I have the following in my .vimrc and am working in a React component file with JSX.

let g:ale_lint_delay = 0
let g:ale_linters = {'javascript': ['eslint']}
let g:ale_fix_on_save = 1
let g:ale_fixers = {}
let g:ale_fixers['javascript'] = ['prettier', 'eslint']
let g:ale_fixers['json'] = ['prettier']

Most helpful comment

Maybe ESLint just takes 2 seconds to run in the background. You could try using eslint_d to speed it up.

All 10 comments

Sounds like some kind of Vim issue. I can't offer much help with this. Try using different versions of Vim, or changing your settings.

I know this may still not be the place to find answers, but I am having very little luck in my searches elsewhere. I have discovered that, after making changes that should cause linting errors to show, if I call :redraw, the appropriate errors show up immediately. I have had little luck discovering why Vim doesn't immediately redraw or otherwise draw the errors when they occur, but that is finally some information that I didn't have before.

I will close this if you would prefer I didn't bog down your issues with something that's not truly a problem with ALE. This is a great tool and I really appreciate the work that has clearly gone into it.

Check your lazyredraw setting. You might have to turn that off. You could also try leaving the setting on and running :redraw from one of the autocmd events. See :help ALELintPost-autocmd.

It seems I may have fooled myself. I think the redrawing is a red herring. I've noted that adding a redraw autocmd doesn't give any noticeable benefit and lazyredraw is off by default. I'm down to using a very minimal .vimrc and am still seeing these issues.

I added an augroup, as the help text states one might, that changes the status line color while linting is in progress. It seems that there is a couple of seconds between ALELintPre and ALELintPost so perhaps it is something to do with ALE. However, when I profile vim, though ale#Lint() is the longest entry, it is only taking 0.013 seconds. It's very puzzling.

Does setting let g:ale_set_balloons = 1 in your vimrc help?

Doesn't seem to. I'm going to close this since I've pretty much thrown in the towel at this point.

What's the output of echo has('balloon_eval')?

Try also putting the following in your vimrc:

func g:Foo(...)
" do nothing
endfunc
call timer_start(50,function('g:Foo'),{'repeat':-1})

Maybe ESLint just takes 2 seconds to run in the background. You could try using eslint_d to speed it up.

@markonm I get 0 when I check has('balloon_eval')

@w0rp Switching to eslint_d did it! I suspected that ESLint (or Prettier) might have been the culprit but I couldn't figure how to confirm it since it seemed plenty fast when I ran it from the command line. Regardless, the linting and fixing is now faster than any other editor I've ever used. Thanks so much for helping me!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garand picture garand  路  4Comments

sublee picture sublee  路  3Comments

sodiumjoe picture sodiumjoe  路  4Comments

catbaron0 picture catbaron0  路  3Comments

alexlafroscia picture alexlafroscia  路  4Comments