Default values for .vimspector.json
Midren opened this issue · 10 comments
Is your feature request related to a problem? Please describe.
I'm really a big fan of vimspector integration, and I am so happy, that I needn't write a path to binary each time, and it also regenerates automatically, if cmake has changed. However, it is a bit frustrating, that for each project I need to specify "type", "adapter"
and rules for exceptions. It would be really great if you could specify default values for those ones.
Describe the solution you'd like
It would be great to have some variable like that:
let g:cmake_default_vimspector_config = {
\ "adapter": "CodeLLDB",
\ "breakpoints": {
\ "exception": {
\ "cpp_catch": "N",
\ "cpp_throw": "Y",
\ }
\ },
\ "configuration": {
\ "type": "lldb",
\ "stopAtEntry": "True",
\ }
\ }
Try out this patch and let us know if that works for you.
diff --git a/autoload/utils/config/vimspector.vim b/autoload/utils/config/vimspector.vim
index fa7b758..d57bf95 100644
--- a/autoload/utils/config/vimspector.vim
+++ b/autoload/utils/config/vimspector.vim
@@ -41,6 +41,10 @@ function! s:generateEmptyVimspectorConfig() abort
endfunction
function! s:createNewTarget() abort
+ if exists('g:cmake_default_vimspector_config')
+ return g:cmake_default_vimspector_config
+ endif
+
let l:configuration = {}
let l:configuration['type'] = ''
let l:configuration['request'] = 'launch'
It works like a charm, thank you !
I'm not sure, if it's better to open another issue, but another thing, that I am constantly encountering is creating vimspector configuration entries for targets, that are not runnable (i.e all
). I think some checking can be run before adding to .vimspector.json
I'm not sure, if it's better to open another issue, but another thing, that I am constantly encountering is creating vimspector configuration entries for targets, that are not runnable (i.e
all
). I think some checking can be run before adding to .vimspector.json
Hah, that's actually something on my TODO
list I've had for a while.
I couldn't think of a simple solution because we cannot know if a target is runnable unless we try and run it. And by then, it's already "too late" since it's already in the .vimspector.json
.
We can get this info using cmake file api. Example here: https://github.com/ilyachur/cmake4vim/blob/master/autoload/utils/cmake.vim#L340
Found even easier solution, will make the PR