amix / vimrc

The ultimate Vim configuration (vimrc)
MIT License
30.78k stars 7.3k forks source link

Issue: Vim Displays "two_right_angle_brackets_need_space" Error #759

Closed georgios-vassos1 closed 5 months ago

georgios-vassos1 commented 5 months ago

Issue: Error message "two_right_angle_brackets_need_space" when using C++ with vim

Description

When using C++ with vim, users encounter the error message "two_right_angle_brackets_need_space: In included file: a space is required between consecutive right angle brackets (use '> >')". This issue appears to be related to the compiler flags used by vim for generating checks, specifically the -std flag.

Expected Behavior

Since the code actually compiles without errors when using g++ -std=c++11 -o xx example.cpp, vim should not prompt error messages.

Actual Behavior

The error message "two_right_angle_brackets_need_space: In included file: a space is required between consecutive right angle brackets (use '> >')" is displayed.

Tried Solutions

  1. Added the following lines to .vim_runtime/my_configs.vim:

    
    let g:clang_complete_copen=1
    let g:clang_library_path='/usr/local/opt/llvm/lib'
    let g:clang_user_options='-std=c++11'
  2. Modified the line exec "!g++ % -o %<" in .vim_runtime/vimrcs/extended.vim to exec "!g++ % -std=c++11 -o %<".

Code Example (example.cpp)


// Example code
#include<iostream>

int main() {
    std::vector<std::vector<int>> matrix; // Example of consecutive right angle brackets without spaces
    // Additional code
    return 0;
}
georgios-vassos1 commented 5 months ago

Sorted the issue by changing call ale#Set('cpp_clangcheck_options', '') in .vim_runtime/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim and call ale#Set('cpp_clangd_options', '') in .vim_runtime/sources_non_forked/ale/ale_linters/cpp/clangd.vim to call ale#Set('cpp_clangcheck_options', '-std=c++14 -Wall') and call ale#Set('cpp_clangd_options', '-std=c++14 -Wall'), respectively.