Ale: Undefined variable: g:ale_fixers

Created on 1 Jun 2017  路  6Comments  路  Source: dense-analysis/ale

Hi guys, Im trying to figure out how to set up the .vimrc file to be able yo autofix using eslint both on save and by running ALEFix. But I alway get the same result when launching vim:

Undefined variable: g:ale_fixers

The specific.vimrc config for ale is:

let g:ale_linters = {
\   'javascript': ['eslint']
\}

let g:ale_fixers.javascript = [
  \ 'DoSomething',
  \ 'eslint',
  \ {buffer, lines -> filter(lines, 'v:val !=~ ''^\s*//''')},
\]

 let g:ale_fix_on_save = 1

Also by runnig :ALEFix gets:

Error detected while processing function ale#fix#Fix

The :ALEInfoToClipboard result is:

 Current Filetype: javascript.jsx
Available Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
  Enabled Linters: ['eslint']
 Linter Variables:

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

let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%s'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'javascript': ['eslint']}
let g:ale_open_list = 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_offset = 1000000
let g:ale_sign_warning = '--'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(finished - exit code 1) ['/bin/zsh', '-c', '''/Users/CharlieMac/influencity/advertiser-front/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-filename ''/Users/CharlieMac/influencity/advertiser-front/src/routes/Network/validations/validations.js'' < ''/var/folders/0b/889kssj53bqdcv2tcm5tvd8w0000gn/T/vV3LfEo/0/validations.js''']

Is something broken or Am I doing something wrong?
Linting is working perfect, just having ISSUES when Im trying to fix it

Thank you for the work!馃嵒

bug

Most helpful comment

You need to initiate the g:ale_fixers variable with an empty object first:

let g:ale_fixers = {}
let g:ale_fixers.javascript = [
\   ...
\]

Or do it in one go:

let g:ale_fixers = {
\   'javascript': [
\       ...
\   ]
\}

All 6 comments

Could you copy and paste the full error messages? The errors you see might have nothing to do with the actual error. Vim has a habit of continuing to attempt to execute lines of code after a previous line which threw an exception.

Yes sure! :)
When run :ALEFix I got:

Error detected while processing function ale#fix#Fix:
line   15:
No fixers have been defined. Try :ALEFixSuggest
Press ENTER or type command to continue

then I run :ALEFixSuggest and get:

Try the following fixers appropriate for the filetype:
'eslint' - Apply eslint --fix to a file.
'prettier' - Apply prettier to a file.
'prettier_eslint' - Apply prettier-eslint to a file.
Try the following generic fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
See :help ale-fix-configuration

Then when I read the help docs I understand that I need to add something like the following to mi .vimrc:

  let g:ale_fixers.javascript = [
  \ 'DoSomething',
  \ 'eslint',
  \ {buffer, lines -> filter(lines, 'v:val !=~ ''^\s*//''')},
  \]

But when I do that if I run vim I get:

Error detected while processing /Users/CharlieMac/.vimrc:
line   61:
E121: Undefined variable: g:ale_fixers
Press ENTER or type command to continue

Hope it helps! If need anything else let me know 馃槂

You need to initiate the g:ale_fixers variable with an empty object first:

let g:ale_fixers = {}
let g:ale_fixers.javascript = [
\   ...
\]

Or do it in one go:

let g:ale_fixers = {
\   'javascript': [
\       ...
\   ]
\}

Yeah. In your vimrc file, g:ale_fixers hasn't yet been defined, so you need to create a new Dictionary.

I just changed the documentation so the example constructs a Dictionary in one go.

Yeah it works! Thanks so much guys 馃槃
Sorry If I bother you! Vim newbie here xD
Cheers!馃嵒

Was this page helpful?
0 / 5 - 0 ratings

Related issues

catbaron0 picture catbaron0  路  3Comments

aressler38 picture aressler38  路  3Comments

lervag picture lervag  路  3Comments

ilyakopy picture ilyakopy  路  4Comments

amerov picture amerov  路  4Comments