Skip to content

running ALEFix on save #591

@dxu

Description

@dxu

Hello! I am a new user of ale, I noticed the work done on #571, and have started trying to use it. I'm running into issues when trying to run it on save (which is being tackled by #570), but figured I might as well ask in case it is due to user error.

Here are my configs:

let g:ale_fixers = {}
let g:ale_fixers.javascript = [
\ 'prettier',
\ 'eslint',
\]
let g:ale_javascript_prettier_options = ' --stdin\ --parser\ flow\ --single-quote\ --trailing-comma\ all\ --no-bracket-spacing'

autocmd BufWrite *.js ALEFix

I'm noticing a few things:

  1. I'm trying to set up a autocommand to run ALEFix on save, but for some reason when I save, the file will write, the checker will run, and then the buffer will update with the changes. As a result:
    a. vim complains that the buffer has not yet been saved when trying to quit
    b. if i very quickly quit before the buffer updates with the change, the fix won't actually occur (e.g, via :wq.

Is this due to some async feature of ale? I previously used neoformat to do something similar, for which this doesn't occur.

  1. when specifying ale_fixers for javascript, if I change the order of eslint and prettier so that eslint comes before prettier, the javascript_prettier_options don't get applied.

  2. If I don't specify ale_javascript_prettier_options, ALEFix runs into an error

Error detected while processing function ale#fix#Fix[21]..<SNR>213_RunFixer[6]..ale#handlers#prettier#Fix[1]..ale#Var:
line    3:
E716: Key not present in Dictionary: ale_javascript_prettier_options
E116: Invalid arguments for function getbufvar(str2nr(a:buffer), l:full_name, g:[l:full_name])
E15: Invalid expression: getbufvar(str2nr(a:buffer), l:full_name, g:[l:full_name])

Thank you for doing such amazing work!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions