From 637da0341878646fe9a6b1f6b084e74eecee80f9 Mon Sep 17 00:00:00 2001 From: Mark Vainomaa Date: Sun, 29 Jan 2017 17:12:06 +0200 Subject: [PATCH] Read clang checker flags from clang_complete file Neomake didn't provide a way to pass clang flags, so I had to implement it myself. (It is not perfect though) --- neostrophic.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/neostrophic.vim b/neostrophic.vim index cee92e5..19967fa 100644 --- a/neostrophic.vim +++ b/neostrophic.vim @@ -51,6 +51,10 @@ function! s:set_indent() endfunction +function! s:read_clangflags() + return split(join(readfile(getcwd() . "/.clang_complete"), "\n")) +endfunction + " --- Start if(!has("python3")) echo "You should install python neovim module. `pip install neovim`" @@ -325,6 +329,24 @@ let g:SuperTabDefaultCompletionType = "" " LessSpace let g:lessspace_blacklist = ['markdown'] +" Neomake +let s:default_clang_args = ['-std=c++14', '-fsyntax-only', '-Wall', '-Wextra'] +let g:neomake_cpp_clang_maker = { + \'args': s:default_clang_args + \ } +let g:neomake_cpp_enabled_makers = ['clang'] + +function! s:build_clang_args() + if filereadable(getcwd() . "/.clang_complete") + " Read flags + let newflags = s:default_clang_args + s:read_clangflags() + " Build list with no duplicates for sure + let g:neomake_cpp_clang_maker.args = filter(copy(newflags), 'index(newflags, v:val, v:key+1)==-1') + endif +endfunction +autocmd! FileType cpp nested call s:build_clang_args() + + " --- Keymaps " Commonly used commands nnoremap :u