ale icon indicating copy to clipboard operation
ale copied to clipboard

Lint on enter

Open monkoose opened this issue 9 years ago • 9 comments

Even with option let g:ale_lint_on_enter = 0 it keeps linting on enter?

neovim 0.1.7 archlinux

Current Filetype: python
Available Linters: ['flake8', 'mypy', 'pylint']
  Enabled Linters: ['flake8']
 Linter Variables:

let g:ale_python_flake8_args = '--ignore=E501'
let g:ale_python_flake8_executable = 'flake8'
let g:ale_python_flake8_options = '--ignore=E501'
 Global Variables:

let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '[%linter%] %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 = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 0
let g:ale_linter_aliases = {}
let g:ale_linters = {'html': ['HTMLHint'], 'javascript': ['jshint'], 'css': ['csslint'], 'python': ['flake8']}
let g:ale_open_list = 0
let g:ale_set_highlights = 0
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 = 'E'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = 'W'
let g:ale_statusline_format = ['E:%d', 'W:%d', '']
let g:ale_warn_about_trailing_whitespace = 1

monkoose avatar Apr 26 '17 10:04 monkoose

Checked augroups

    augroup ALERunOnTextChangedGroup
        autocmd!
        if g:ale_enabled
            if l:text_changed ==? 'always' || l:text_changed ==# '1'
                autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay)
            elseif l:text_changed ==? 'normal'
                autocmd TextChanged * call ale#Queue(g:ale_lint_delay)
            elseif l:text_changed ==? 'insert'
                autocmd TextChangedI * call ale#Queue(g:ale_lint_delay)
            endif
        endif
    augroup END

    augroup ALERunOnEnterGroup
        autocmd!
        if g:ale_enabled && g:ale_lint_on_enter
            autocmd BufEnter,BufRead * call ale#Queue(300, 'lint_file')
        endif
    augroup END

Logically seems correct. But on text change and on enter implemented differently, so changing on text change variable works for me and on enter doen't. Only me with this problem?

monkoose avatar Apr 26 '17 10:04 monkoose

:echo g:ale_enagled && g:ale_lint_on_enter returns 0 But why it isn't working?

monkoose avatar Apr 26 '17 10:04 monkoose

I have fixed this now. The problem was caused by the other event for FileType being fired when you first open buffers. I fixed this by saving a b: variable when a buffer is entered or read, and by checking the filetype being set in FileType against that variable.

w0rp avatar Apr 26 '17 22:04 w0rp

Thank you. It works now.

monkoose avatar Apr 27 '17 13:04 monkoose

This only partially solved the problem for me. It still lints on enter for the first file i open after starting vim and opening a file via fzf.

mark-westerhof avatar Apr 27 '17 16:04 mark-westerhof

It still lints on enter for the first file

Works for me just fine as expected.

I don't use fzf so can't say about the second part.

monkoose avatar Apr 27 '17 17:04 monkoose

@mark-westerhof Can you create a reproducible series of steps? I'm not familiar with fzf myself.

w0rp avatar Apr 28 '17 14:04 w0rp

Hi @w0rp, Just installed ALE (instead of Neomake), I disabled lint_on_enter (because it feels slow to me) and when I open any file, it lines.

any reason?


 Current Filetype: ruby
Available Linters: ['brakeman', 'rails_best_practices', 'reek', 'rubocop', 'ruby']
  Enabled Linters: ['brakeman', 'rails_best_practices', 'reek', 'rubocop', 'ruby']
 Linter Variables:

let g:ale_ruby_brakeman_options = ''
let g:ale_ruby_reek_show_context = 0
let g:ale_ruby_reek_show_wiki_link = 0
let g:ale_ruby_rubocop_executable = 'rubocop'
let g:ale_ruby_rubocop_options = ''
 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_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
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:

yosiat avatar Sep 02 '17 14:09 yosiat

@yosiat I have fixed this now.

The problem was that the code used for the g:ale_lint_on_filetype_changed option was linting files when the filetype was initially set. Now have made it so if you turn the option for linting when a buffer is opened off, that ALE will not lint files when the filetype is initially set. I added a paragraph for this in the documentation for g:ale_lint_on_filetype_changed. Now users should either leave the option for linting on enter on to get that behaviour, or they should just run :ALELint themselves.

w0rp avatar Sep 02 '17 15:09 w0rp