dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.51k stars 1.43k forks source link

Omnicompletion triggers linting #4731

Closed ManuelvOK closed 4 months ago

ManuelvOK commented 7 months ago

Information

VIM version

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Feb 06 2024 15:30:35) Included patches: 1-80

Operating System: Arch Linux: Linux version 6.7.6-arch1-1

What went wrong

I am linting only when the buffer is saved. I am also using ale#completion#OmniFunc for omnicompletion. When using Omnicompletion by pressing <C-x><C-o>, linting is triggered and a syntax error is generated for the current line because I have not finished it.

Reproducing the bug

  1. Configure ale as follows:
    let g:ale_lint_on_text_changed = 0
    let g:ale_lint_on_insert_leave = 0
    let g:ale_lint_on_filetype_changed = 0
    let g:ale_lint_on_enter = 0
    set omnifunc=ale#completion#OmniFunc
    set completeopt=menu,preview
  2. Open python file foo.py and add content:
    a = {}
    a.
  3. With the cursor at the end of line 2 in insert mode, trigger omnicompletion by pressing <C-x><C-o>.
  4. A completion list appears. But after some seconds, the Line is marked with an error: # E: SyntaxError: invalid syntax (foo.py, line 2)

:ALEInfo

Expand ``` Current Filetype: python Available Linters: ['bandit', 'cspell', 'flake8', 'flakehell', 'jedils', 'mypy', 'prospector', 'pycln', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pylsp', 'pyre', 'pyright', 'refurb', 'ruff', 'unimport', 'vulture'] Linter Aliases: 'jedils' -> ['jedi_language_server'] Enabled Linters: ['jedils'] Ignored Linters: [] Suggested Fixers: 'add_blank_lines_for_python_control_statements' - Add blank lines before control statements. 'autoflake' - Fix flake issues with autoflake. 'autoimport' - Fix import issues with autoimport. 'autopep8' - Fix PEP8 issues with autopep8. 'black' - Fix PEP8 issues with black. 'isort' - Sort Python imports with isort. 'pycln' - remove unused python import statements 'pyflyby' - Tidy Python imports with pyflyby. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'reorder-python-imports' - Sort Python imports with reorder-python-imports. 'ruff' - A python linter/fixer for Python written in Rust 'ruff_format' - Fix python files with the ruff formatter. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. 'yapf' - Fix Python files with yapf. Linter Variables: let g:ale_python_auto_pipenv = 0 let g:ale_python_auto_poetry = 0 let g:ale_python_auto_virtualenv = 0 let g:ale_python_jedils_auto_pipenv = 0 let g:ale_python_jedils_executable = 'jedi-language-server' let g:ale_python_jedils_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 = 100 let g:ale_completion_enabled = 0 let g:ale_completion_max_suggestions = 50 let g:ale_disable_lsp = 'auto' 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 = 0 let g:ale_fixers = {} let g:ale_history_enabled = 1 let g:ale_info_default_mode = 'preview' let g:ale_history_log_output = 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_filetype_changed = 0 let g:ale_lint_on_insert_leave = 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 = {'typescript': ['tsserver'], 'c': ['clang', 'clangtidy'], 'lua': ['luac'], 'sh': ['shellcheck'], 'javascript': ['jshint', 'jscs'], 'cpp': ['clang', 'clangtidy'], 'python': ['jedils']} let g:ale_linters_explicit = 1 let g:ale_linters_ignore = {} let g:ale_list_vertical = 0 let g:ale_list_window_size = 10 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_root = {} 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 = 'E' let g:ale_sign_info = 'I' let g:ale_sign_offset = 1000000 let g:ale_sign_style_error = 'E' let g:ale_sign_style_warning = 'W' let g:ale_sign_warning = 'W' let g:ale_sign_highlight_linenrs = 0 let g:ale_type_map = {} let g:ale_use_neovim_diagnostics_api = 0 let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 'all' let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History: (executable check - success) jedi-language-server (started) ['/usr/bin/zsh', '-c', '''jedi-language-server'''] ```
w0rp commented 4 months ago

I'll mark this as a duplicate of https://github.com/dense-analysis/ale/issues/3600. I actually was the one who originally proposed the LSP diagnostic pull model. I just never got around to implementing it in ALE. Once that's done, diagnostics will only be sent to ALE if they are explicitly requested assuming the language server supports the pull model. The issue can't be fixed otherwise.