Open w0rp opened 4 years ago
I pushed a commit to disable make -n
by default again, as someone on Reddit pointed out that make -n
is not secure, and could execute arbitrary code.
Although mentioned in the README - for others who may have missed it - if you're having issues try looking at
:ALEInfo
This command will show which executable's are invoked by ALE, their output, and what arguments were given. For me, this abundantly made clear where my configuration was malformed.
@dcousens do you mind taking a look at my :ALEInfo
error? I am on windows using mingw gcc.
Directory: C:\path\to\gstreamer-1.20.2\1.0\mingw_x86_64\include\gstreamer-1.0\gst\gst.h
My compile_commands.json
is set up with include paths that should have gst/gst.h
[
{
"directory": "C:/path/to/workspace/",
"file": "C:/path/to/entrypoint.cc",
"arguments": [
"x86_64-w64-mingw32-gcc",
"-IC:/path/to/workspace/src",
"-IC:/msys64/mingw64/include",
"-O0", "-DDEBUG", "-ggdb", "-Wall", "-fno-omit-frame-pointer", "-mms-bitfields",
"-IC:/path/to/gstreamer-1.20.2/1.0/mingw_x86_64/include/gstreamer-1.0",
...
I also put in my user config C:\path\to\AppData\Local\clangd\config.yaml
CompileFlags: # Tweak the parse settings
Add:
- "-IC:/path/to/gstreamer-1.20.2/1.0/mingw_x86_64/include/gstreamer-1.0"
Yet, no includes are not found in :ALEInfo
:
(executable check - success) clang
(finished - exit code 1) 'cmd /s/c "clang -S -x c -o nul -iquote C:\path\to\dir -std=c11 -Wall - < C:\path\to\AppData\Local\Temp\nvim.0\1jy36r\16\filename.c"'
<<<OUTPUT STARTS>>>
In file included from <stdin>:38:
C:\path\to\header.h:33:10: fatal error: 'gst/gst.h' file not found
#include <gst/gst.h>
^~~~~~~~~~~
1 error generated.
<<<OUTPUT ENDS>>>
FWIW my gd
works on gst/gst.h
. Takes me where I expect. And it looks like clangd output shows that it "build preamble".
clangtidy
works just fine for me, but trying to use clangd
is an absolute mess. If I do not put a ale_cpp_clangd_options
entry into my config approximately one billion errors pop up (starting with "Too many errors emitted, stopping now"). On the other hand, however, if I specify any ale_cpp_clangd_options
I get absolutely nothing.
In the former case, my ALEInfo
shows:
:ALEInfo
Current Filetype: cpp
Available Linters: ['cc', 'ccls', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'cspell', 'flawfinder']
Linter Aliases:
'cc' -> ['gcc', 'clang', 'g++', 'clang++']
Enabled Linters: ['clangd']
Ignored Linters: []
Suggested Fixers:
'astyle' - Fix C/C++ with astyle.
'clang-format' - Fix C, C++, C#, CUDA, Java, JavaScript, JSON, ObjectiveC and Protobuf files with clang-format.
'clangtidy' - Fix C/C++ and ObjectiveC files with clang-tidy.
'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_cpp_clangd_executable = 'clangd'
let g:ale_cpp_clangd_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 = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
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 = '%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 = ['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 = 0
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let b:ale_linters = ['clangd']
let g:ale_linters_explicit = 0
let b: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 = '●'
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_sign_highlight_linenrs = 0
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 = 'all'
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(executable check - success) clangd
(started) ['sh', '-c', '''clangd'' -compile-commands-dir=''/root/ros/overlay_ws/build/compile_commands.json''']
In the latter case it shows:
Current Filetype: cpp
Available Linters: ['cc', 'ccls', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'cspell', 'flawfinder']
Linter Aliases:
'cc' -> ['gcc', 'clang', 'g++', 'clang++']
Enabled Linters: ['clangd']
Ignored Linters: []
Suggested Fixers:
'astyle' - Fix C/C++ with astyle.
'clang-format' - Fix C, C++, C#, CUDA, Java, JavaScript, JSON, ObjectiveC and Protobuf files with clang-format.
'clangtidy' - Fix C/C++ and ObjectiveC files with clang-tidy.
'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_cpp_clangd_executable = 'clangd'
let g:ale_cpp_clangd_options = ''
let b:ale_cpp_clangd_options = '-std=c++17'
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 = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
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 = '%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 = ['clang-format']
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 = 0
let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let b:ale_linters = ['clangd']
let g:ale_linters_explicit = 0
let b:ale_linters_explicit = 1
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 = 20
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 = '●'
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 = '-'
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 = 'all'
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(executable check - success) clangd
Note that in the former, the path to the compile_commands.json
is correct (I am in a docker container, that's why it's a subdir of root). I have tried various ale_cpp_clangd_options
, prefixed with both b:
and g:
.
Again, clang-tidy
works a treat, so kudos on that. I would, however, like to figure out why clangd isn't working
There are always issues reported because detecting the correct flags to use for linting C and C++ files is nearly impossible to do well for all projects. The
g:ale_c_parse_compile_commands
option has now been enabled by default, so ALE can detect flags from the output ofcompile_commands.json
files by default. I have updated the FAQ, and you should try usingcompile_commands.json
files in your projects.People also have issues now and then with parsing weird C or C++ errors, and it's hard to fix one thing without breaking another.
This issue will collect generally any issue relating to C/C++ linting, in an attemp to make C/C++ linting better as a whole, by default.
Known Issues
.h
/.hpp
files don't usecompile_commands.json
files. Open PR here: #2919clangtidy
treats.h
as C headers. Open PR here: #2742-fstack-usage
for gcc can generate weird errors. Issue raised here: #3200compile_commands.json
parsing filters out@file
flags, such as those generated by bear. Open PR here: #3178-std
in the default options replaces the-std
fromcompile_commands.json
, which causes problems with using the wrong C++ standard. Open PR here: #3056compile_commands.json
paths aren't resolved relative to thedirectory
for each entry. #3307-include
isn't parsed. #3317make -n
doesn't always give output. #3247 #2038compile_flags.txt
if we can't parsecompile_commands.json
. #2831Ideas for Ease of Use
cc
linter to replacegcc
andclang
#3299