Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ale_cpp_{gcc,clang}_options should be ignored when ale_c_parse_compile_commands = 1 #2950

Closed
Ram-Z opened this issue Dec 31, 2019 · 2 comments

Comments

@Ram-Z
Copy link

Ram-Z commented Dec 31, 2019

When the compile flags are being read from a compilation database, ALE should'n override them by appending ale_cpp_options to the end.

Obviously one could simply let g:ale_cpp_options = '', but that prevents setting sane defaults when a compilation database cannot be found.

There should still be the ability to add additional options even if a compilation database is found.

I propose to split the variables into two ale_cpp_options and ale_cpp_extra_options and have something like this in ale_linters/cpp/{gcc,clang}.vim.

diff --git a/ale_linters/cpp/gcc.vim b/ale_linters/cpp/gcc.vim
index 108d6d7..6da499c 100644
--- a/ale_linters/cpp/gcc.vim
+++ b/ale_linters/cpp/gcc.vim
@@ -16,7 +16,7 @@ function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
     \   . ' -o ' . g:ale#util#nul_file
     \   . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
     \   . ale#Pad(l:cflags)
-    \   . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -'
+    \   . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_extra_options')) . ' -'
 endfunction
 
 call ale#linter#Define('cpp', {
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index 9b42870..c3d9b47 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -347,7 +347,8 @@ function! ale#c#GetCFlags(buffer, output) abort
     endif
 
     if l:cflags is v:null
-        let l:cflags = ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))
+        let l:cflags = ale#Var(a:buffer, 'cpp_gcc_options')
+        \            . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)))
     endif
 
     return l:cflags isnot v:null ? l:cflags : ''
@Ram-Z Ram-Z changed the title ale_cpp_options should be ignored when ale_c_parse_compile_commands = 1 ale_cpp_{gcc,clang}_options should be ignored when ale_c_parse_compile_commands = 1 Dec 31, 2019
@Ram-Z
Copy link
Author

Ram-Z commented Feb 11, 2020

@w0rp Hopefully this is a quick one to ease you back in. Patch attached.

Thank you for all your work on this project.


Actually I'm not sure anymore why I didn't open a MR, happy to do it if the general idea is acceptable.

@w0rp w0rp mentioned this issue Aug 9, 2020
12 tasks
@w0rp
Copy link
Member

w0rp commented Aug 9, 2020

Almost all C/C++ issues with flags should now be discussed in #3276, so a comprehensive solution can be found for most people, for automatically detecting flags.

@w0rp w0rp closed this as completed Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants