Skip to content

Instantly share code, notes, and snippets.

@yutkat
Last active May 28, 2020 11:08
Show Gist options
  • Save yutkat/b724a4fa4a2148df62442bf252968a10 to your computer and use it in GitHub Desktop.
Save yutkat/b724a4fa4a2148df62442bf252968a10 to your computer and use it in GitHub Desktop.
Vim C++ local env
function! GetCurrentFunctionName() abort
if empty(get(g:vista, 'raw'))
throw 'Please execute `:Vista`'
endif
let sig = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', 'signature')
let func_name = split(substitute(substitute(sig, '(', '', 'g'), ')', '', 'g'), ',')
return func_name[0] . "." . func_name[1]
endfunction
command! TestCurrent :execute 'AsyncRun ./bin/' . expand('%:p:h:t') . '.test --gtest_filter=' . GetCurrentFunctionName()
set errorformat^=%f\|%l\ col\ %c\|\ %m
augroup local-asyncrun
au!
au User AsyncRunStop copen | wincmd p
augroup END
call altr#remove_all()
call altr#define('src/%.cpp', 'include/%.hpp', 'test/%.test.cpp', 'include/%.h', 'test/%.cxx')
{
"configurations": {
"Launch": {
"adapter": "vscode-cpptools",
"configuration": {
"name": "unit-test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/XXX-test",
"args": [],
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment