vim + youcompleteme + vimspector
#gcc 版本切换
sudo update-alternatives --config gcc
Your C++ compiler does NOT fully support C++17.
sudo apt install build-essential
sudo apt-get install g+±8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g+±7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g+±8
pip3 install pathtools
pip install pathtools
cd ~/.vim/plugged/YouCompleteMe
python3 install.py --clangd-completer
Plug “ycm-core/YouCompleteMe”
" ===
" === youcompleteme 对nvim支持不完整 nvim推荐coc.nvim
" ===
".ycm_extra_conf.py 是否提示加载1确认 0不需要确认
let g:ycm_confirm_extra_conf = 0
" 除/Documents/目录之外拒绝加载/目录内的.ycm_extra_conf.py文件
" 在例表前面的优先级高
let g:ycm_extra_conf_globlist = [’/Documents/*’,’!/*’]
vimspector 调式插件
nvim
Plug ‘puremourning/vimspector’,{‘do’:’./install_gadget.py --force-enable-rust -enable-python --enable-go --enable-bash --enable-c’}
vim
Plugin ‘puremourning/vimspector’,{‘do’:’./install_gadget.py --force-enable-rust -enable-python --enable-go --enable-bash --enable-c’}
放在c++工程根目录.vimspector.json
{
“configurations”: {
“cpp:launch”: {
“adapter”: “vscode-cpptools”,
“configuration”: {
“name”: “cpp:launch”,
“stopAtEntry”: true,
“type”: “ccpgdb”,
“request”: “launch”,
“program”: “
w
o
r
k
s
p
a
c
e
R
o
o
t
/
m
a
i
n
"
,
"
a
r
g
s
"
:
[
]
,
"
c
w
d
"
:
"
{workspaceRoot}/main", "args": [], "cwd": "
workspaceRoot/main","args":[],"cwd":"{workspaceRoot}”,
“environment”: [],
“externalConsole”: true,
“MIMode”: “gdb”,
“breakpointers”: {
“exception”: {
“cpp_throw”: “Y”,
“cpp_catch”: “N”
}
}
}
}
}
}
" ===
" === vimspector
" ===
let g:vimspector_enable_mappings = ‘HUMAN’
function! s:read_template_into_buffer(template)
" has to be a function to avoid the extra space fzf#run insers otherwise
execute ‘0r ~/.vim/vimspector_json/’.a:template
endfunction
command! -bang -nargs=* LoadVimSpectorJsonTemplate call fzf#run({
\ ‘source’: ‘ls -1 ~/.vim/vimspector_json’,
\ ‘down’: 20,
\ ‘sink’: function(‘read_template_into_buffer’)
\ })
" %:p:h返回当前调试源文件所在的目录
" 如果没有%:p:h时.vimspector.json会被默认存到vim/nvim启动目录
" ~$nvim test/main.cpp 没有%:p:h时则返回~/.vimspector.json 如果有 %:p:h/.vimspector.json返回~/test/.vimspector.json
noremap vs :tabe %:p:h/.vimspector.json:LoadVimSpectorJsonTemplate
sign define vimspectorBP text=🛑 texthl=Normal
sign define vimspectorBPDisabled text=🚫 texthl=Normal
sign define vimspectorPC text=👉 texthl=SpellBad