dense-analysis / dense-analysis/ale

Clangd stops working after saving C file with error

Open
#2,156 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

## Information

**VIM version**

NVIM v0.3.1-1-g489d32f2b
Build type: RelWithDebInfo
Features: +acl +iconv +jemalloc +tui
SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64 GNU/Linux

**Clangd version**
clangd version 8.0.0 (trunk 348706) (llvm/trunk 348705)

**Clang-tidy/LLVM version **
LLVM version 8.0.0svn

## What went wrong
Hello,
I've configured clangd in my c project alongside clang-tidy to use linter and go to definition ALE functionalities. At first it worked like a charm, go to definition, references etc. However when I've tried it in development process it turned out that after some file editing linter and clangd features just stopped working without returning any error. ALEReset/ResetBuffer neither reopening buffer, changing file does not help at all. The only way around to make everything work again is to restart nvim. Then with the same c file all the lints and clangd features works perfectly.

I examined the issue happens after making the mistake in c file. After some error is made, file is saved, and then mistake is fixed. Clangd stops working and never wakes up again until nvim restart.
It is possible to make restart after every issue is being corrected but when working with a lot of buffers and splits it is getting terribly annoying.

For now removing clangd from linter list and leaving only clang-tidy is my solution but with it I've lost ALEGoToDefinition and ALEFindReferences which i find very useful.

I don't know how to verify if the issue is connected with clangd, ALE or nvim. Could you verify my reproducing scenario?

## Reproducing the bug

1. Create a project with simple c source, Makefile and correct compile_commands.json file generation
2. Configure project specific .nvimrc file to use clangd:
let g:ale_pattern_options = {
\ '.c$': {
\ 'ale_linters': ['clangtidy', 'clangd'],
\ 'ale_fixers': ['clang-format'],
\ },
\}
nmap (ale_go_to_definition)
3. Open simple c file and check if go to definition is working (clangd should work)
4. Make mistake on purpose, save file, try ALE to go to definition (clangd sometimes works)
5. Correct the mistake, save file (clangd will not work)
6. Restart nvim try ALE to go to definition (clangd will work again)

### :ALEInfo

Current Filetype: c
Available Linters: ['ccls', 'clang', 'clangd', 'clangtidy', 'cppcheck', 'cquery', 'flawfinder', 'gcc']
Enabled Linters: ['clangd', 'clangtidy']
Suggested Fixers:
'clang-format' - Fix C/C++ files with clang-format.
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
'uncrustify' - Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.
Linter Variables:
let g:ale_c_clangd_executable = 'clangd'
let g:ale_c_clangd_options = ''
let g:ale_c_clangtidy_checks = []
let g:ale_c_clangtidy_executable = 'clang-tidy'
let g:ale_c_clangtidy_options = ''
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 = 1
let g:ale_completion_max_suggestions = 50
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 b:ale_fixers = ['clang-format']
let g:ale_history_enabled = 1
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 = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let b:ale_linters = ['clangtidy', 'clangd']
let g:ale_linters_explicit = 0
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 = {'.c$': {'ale_linters': ['clangtidy', 'clangd'], 'ale_fixers': ['clang-format']}, '.py$': {'ale_linters': ['pylint']}}
let g:ale_pattern_options_enabled = v:null
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 = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
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:
(started) ['/bin/bash', '-c', '''clangd''']
(executable check - success) clang-tidy
(finished - exit code 0) ['/bin/bash', '-c', '''clang-tidy'' ''/home/mypath/src/main.c'' -p ''/home/mypath/''']
<<>>

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.