Open m0xai opened 3 years ago
On my setup exiting from d (linter dls), zig (linter zls), elm (linter elm_ls) and elixir (linters ['credo', 'dialyxir', 'dogma']) produce errors with wq. No error when exiting with q.
Error detected while processing function
Error detected while processing function
Error detected while processing function
Error detected while processing function
config:
set omnifunc=ale#completion#OmniFunc
let g:airline#extensions#branch#enabled = 1
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
let g:airline_section_c_only_filename = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#nerdtree_statusline = 1
set completeopt=menu,menuone,preview,noselect,noinsert
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_linters = {
\ 'cpp': ['clangd', 'g++'],
\ 'd': ['dls'],
\ 'javascript': ['eslint'],
\ 'python': ['pylint', 'flake8'] ,}
if filereadable(findfile("Cargo.toml", ".;"))
let ale_linters['rust'] = ['analyzer', 'cargo']
else
let ale_linters['rust'] = ['analyzer', 'rustc']
endif
let g:ale_rust_analyzer_executable = '/home/calimero/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rust-analyzer'
let g:ale_d_dls_executable='/home/calimero/.dub/packages/.bin/dls-latest/dls'
let g:ale_fixers = { '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'rust': ['rustfmt'],
\ 'go': ['gofmt'],
\ 'c': ['clang-format'],
\ 'd': ['dfmt'],
\ 'cpp': ['clang-format'],
\ 'zig': ['zigfmt'],
\ 'elm': ['elm-format'],
\ 'javascript': ['eslint'],
\ 'elixir': ['mix_format'],
\ }
let g:ale_sign_column_always = 1
let g:ale_d_dfmt_options='--brace_style=otbs'
let g:ale_c_clangformat_style_option = '{BasedOnStyle: LLVM,
\ IndentWidth: 4,
\ ColumnLimit: 110,
\ AllowShortFunctionsOnASingleLine: Empty }'
let g:ale_c_cc_executable = 'clang'
let g:ale_cpp_cc_executable = 'g++'
let g:ale_c_cc_options = '-std=gnu17 -Wall'
let g:ale_cpp_cc_options = '-std=c++17 -Wall'
let g:ale_python_flake8_options="--ignore=E127, E501"
let g:ruby_host_prog = 'rvm system do neovim-ruby-host'
let g:completion_enable_auto_popup = 1
let g:ale_rust_cargo_use_clippy = executable('cargo-clippy')
let g:ale_java_checkstyle_options = ' -c /home/calimero/.vim/plugged/ale/ale_linters/ '
let g:elm_format_autosave = 1
Setting ale_fix_on_save
to zero solves the problem but requires a manual ALEFix.
A (not wonderful) workaround in nvim
vim.api.nvim_create_autocmd({ "BufWrite" }, {
pattern = { "*." .. extension },
callback = function()
vim.api.nvim_exec(":ALEFix", false)
vim.api.nvim_exec("sleep 50m", false)
end
})
(where "extension" is a language I have a formatter for)
@enckse I'm afraid that doesn't solve the problem. I changed the word extension to "zig" and now I got the error message both with ale_fix_on_save to 1 and 0.
Same with patterns "." and "*".
The error only happens with "wq". No problems with "w" and then "q".
Given the issue as laid out, my running into this, a few other issues here, and browsing the code - my guess is that neovim is exiting before ALEFix
finishes. Given my amateur sleuthing - if ale_fix_on_save = 1
with neovim, you are likely to encounter this bug (unless your formatter runs faster than any I use - this will be important later) when you do a wq
(w
alone is not triggering neovim to exit and q
alone isn’t necessarily a save)
If you take my snippet above, you should have turned off ale_fix_on_save
(=0) because my “fix” is calling ALEFix
manually on buffer write (basically save). Why would you want to run ALEFix
twice on write? I can’t (and wouldn’t try) to tune the sleep statement for all formatters in existence (I only care that the workaround I have in my config works for me). I would suggest looking at the neovim documentation for sleep (if you apply my workaround) and maybe increasing the sleep duration to fix wq
issues (I optimized the sleep duration for the source code formatters I use)
My fix is basically re-implementing ale_fix_on_save
locally in my neovim config to fix what looks like a race condition. Applying it elsewhere likely requires tweaking.
Thank you for your contribute. But I have changed my computer, basically threw up :) that's why I can't reproduce. I hope your fix can help others and we can close this issue.
There is still a bug here in ale so we shouldn’t necessarily close this issue in case someone can work out an actual fix in ale itself (though this workaround likely helps alleviate this already minor issue more)
Information
VIM version
NVIM v0.5.1 Build type: Release
Operating System: macOS Catalina (10.15.7)
What went wrong
Exiting java file from nvim produces error. It has no effect on file but it produces same error every time.
Reproducing the bug
I did this.
:wq
Then this happened.
:ALEInfo