From e8bbce1878fe3e2973a5dd4a24151cdc8bf79b44 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Sun, 31 Jul 2022 01:24:17 +0200 Subject: [PATCH] vim: fix cdg usage from build_commands generation --- .vim/plugin/cdg.py | 4 ++-- .vim/plugin/cscope_plus.vim | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.vim/plugin/cdg.py b/.vim/plugin/cdg.py index 84ff973..9efa317 100755 --- a/.vim/plugin/cdg.py +++ b/.vim/plugin/cdg.py @@ -4,7 +4,7 @@ import json import sys import re - +import os '''A simple compilation database generator, or cdg in short. @@ -63,7 +63,7 @@ Per https://clang.llvm.org/docs/JSONCompilationDatabase.html # To workaround that there is no "entering directory..." if not pwd: - pwd = "/path/to/your/project/" + pwd = os.getcwd() path_stack.append(pwd) # Special handling for projects like Redis, diff --git a/.vim/plugin/cscope_plus.vim b/.vim/plugin/cscope_plus.vim index 2e7773d..d06af90 100644 --- a/.vim/plugin/cscope_plus.vim +++ b/.vim/plugin/cscope_plus.vim @@ -89,7 +89,11 @@ endif " signatures (S) information. " --extra=+q : Adds context to the tag name. Note: Without this " option, the script cannot get class members. -let g:build_cmd="make" +if !exists("g:build_cmd") + let g:build_cmd="make" +endif + +" More tools can be found here: https://github.com/Sarcasm/notes/blob/master/dev/compilation-database.rst func! MenuCB(id, result) if a:result == 1 silent exec "!echo '==Building ctags database==' && ctags --fields=+iaS --extra=+q --totals -R --c++-kinds=+p --exclude=.ccls-cache" @@ -117,7 +121,7 @@ func! MenuCB(id, result) elseif a:result == 8 "https://github.com/rizsotto/scan-build execute "!analyze-build" elseif a:result == 9 - execute "!make clean > /dev/null && make -nw | python ~/.vim/plugin/cdg.py " + execute "!make clean > /dev/null && LANG=C make -nw | python ~/.vim/plugin/cdg.py " elseif a:result == 10 echo "Add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to cmake. On modify build option with ccmake" endif