dense-analysis / ale

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

Using ALE with clangd for both linting and autocompletion #4110

Open nradclif opened 2 years ago

nradclif commented 2 years ago

Information

VIM version

VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32) Included patches: 1-2269, 3612, 3625, 3669, 3741

Operating System: Ubuntu 20.04.3 LTS on Windows 10 x86_64

What went wrong

I'm currently using ALE with clangd as a linter, but I'm running into an issue when I try to use it for autocompletion as well. The linter works fine as long as I set let g:ale_cpp_clangd_options = "-stdlib=libc++ -std=c++17" in my .vimrc file. Autocompletion also works fine as long as I don't have any changes to my .vimrc file relating to ALE with clangd (options of the form ale_cpp_clangd_options =). However, setting this ALE with clangd option (or, seemingly, any ALE with clangd option) disables autocompletion. I've read the ALE and clangd man pages but, unless I've missed something, there wasn't anything that helped with the issue I'm seeing.

Reproducing the bug

  1. Set let g:ale_cpp_clangd_options = "-stdlib=libc++ -std=c++17" in .vimrc file.
  2. Try using autocomplete in a .cpp file and see that autocomplete options no longer appear.

:ALEInfo

Current Filetype: text Available Linters: ['alex', 'cspell', 'languagetool', 'proselint', 'redpen', 'textlint', 'vale', 'writegood'] Linter Aliases: 'writegood' -> ['write-good'] Enabled Linters: [] Ignored Linters: [] Suggested Fixers: 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'textlint' - Fix text files with textlint --fix 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. Linter Variables:

Global Variables:

let g:ale_cache_executable_check_failures = v:null let g:ale_change_sign_column_color = v:null let g:ale_command_wrapper = v:null let g:ale_completion_delay = 100 let g:ale_completion_enabled = 1 let g:ale_completion_max_suggestions = 50 let g:ale_disable_lsp = 0 let g:ale_echo_cursor = 1 let g:ale_echo_msg_error_str = 'Error' let g:ale_echo_msg_format = v:null 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_history_log_output = 1 let g:ale_keep_list_window_open = v:null let g:ale_lint_delay = 200 let g:ale_lint_on_enter = 1 let g:ale_lint_on_filetype_changed = 1 let g:ale_lint_on_insert_leave = 1 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'normal' let g:ale_linter_aliases = {} let g:ale_linters = {} let g:ale_linters_explicit = 0 let g:ale_linters_ignore = {} let g:ale_list_vertical = v:null let g:ale_list_window_size = v:null let g:ale_loclist_msg_format = v:null let g:ale_max_buffer_history_size = v:null let g:ale_max_signs = v:null let g:ale_maximum_file_size = v:null let g:ale_open_list = v:null 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 = v:null let g:ale_sign_error = v:null let g:ale_sign_info = v:null let g:ale_sign_offset = v:null let g:ale_sign_style_error = v:null let g:ale_sign_style_warning = v:null let g:ale_sign_warning = v:null let g:ale_sign_highlight_linenrs = v:null let g:ale_statusline_format = v:null let g:ale_type_map = {} let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 0 let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History:

hsanson commented 2 years ago

I think the ALEInfo output is wrong as the filetype is "text" and enabled inters is empty.

Independently of the wrong ALEInfo you may want to enable log file output by adding this to your vimrc file:

call ch_logfile(expand('/tmp/chlogfile.log'), 'w')

Then check the output of /tmp/chlogfile.log after opening a CPP file to see what is going on behind the scenes. Maybe you can get a tip of what may be going wrong.

nradclif commented 2 years ago

I think the ALEInfo output is wrong as the filetype is "text" and enabled inters is empty.

I had to run ALEInfo on a blank file, since my project files are work-related and it looked like ALEInfo dumped some of the file's history.

call ch_logfile(expand('/tmp/chlogfile.log'), 'w')

I'll try adding that command to my vimrc file to see what I find.

nradclif commented 2 years ago

It looks like /tmp/chlogfile.log is empty, even after making a few changes to a cpp file.

hsanson commented 2 years ago

Difficult for me to help... I do not use clangd nor do C++ development.