vimspector icon indicating copy to clipboard operation
vimspector copied to clipboard

[Feature Request]: Default configs

Open andrestone opened this issue 3 years ago • 11 comments

Maybe it's already there but I really couldn't find it.

How about built-in templates for the most commonly used configurations? It's a bit annoying to have to setup .vimspector.json for every new project I get my hands on.

Ideally, when starting the debugger in a project where a configuration couldn't be found, the Vimspector would ask permission to create a .vimspector.json with the most common / recommended settings for that language and open the file so the user could make small adjustments as needed. After the user saved the file, Vimspector would try starting the debug session again.

andrestone avatar Sep 30 '20 12:09 andrestone

https://trello.com/c/vWvSx2sx

This is certainly aspirational in a sense.

FYI you can configure your debug configs once centrally rather than per-project using the parameterised configs: https://puremourning.github.io/vimspector/configuration.html#debug-configurations

and the powerful replacement vars and defaults: https://puremourning.github.io/vimspector/configuration.html#replacements-and-variables

I do this a lot, but here are some examples: https://github.com/puremourning/.vim-mac/tree/master/vimspector-conf/configurations/macos

puremourning avatar Sep 30 '20 15:09 puremourning

There is some stuff in progress here https://github.com/puremourning/vimspector/tree/setup-guide but it's only very much WIP

puremourning avatar Sep 30 '20 15:09 puremourning

The main problem with this is maintenance. It's basically a job for life and I'm not sure that I can manage on my own to maintain all of these things. Will need more community involvement to produce and maintain the gadget configs I think and perhaps a way to pull them out of vimspector core and distribute them differently. not sure, but already the number of gadgets I am supporting is too much to keep up to date on my own.

puremourning avatar Sep 30 '20 16:09 puremourning

here's a demo of the WIP stuff https://asciinema.org/a/xpSMFSn0GSEFTPNYSfcf0HEIA

I have started to work on a way to separate out the gadget specs to allow the community to more easily contribute them

puremourning avatar Nov 26 '20 09:11 puremourning

This is a bit old but I think there's an existing solution to this: creating a global debug config in vimspector installation directory, under <OS>/<filetype>/. If this is working, then I think it is a good alternative for this problem; we just have to write one typical(the most common) config for each filetype and we don't really have to touch it again; only if we have an edge case project we'd have one for that project.

However, I couldn't get the global config to work. vimspector complains that it couldn't find the config and I need to tell vimspector how to launch the application.

I've created vimspector_root/configurations/linux/rust/.vimspector.json with following config:

{
  "$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json",
  "configurations": {
    "Launch": {
      "adapter": "CodeLLDB",
      "filetypes": ["rust"],
      "configuration": {
        "request": "launch",
        "program": "${workspaceRoot}/target/debug/${fileBasenameNoExtension}",
        "args": [],
        "cwd": "${workspaceRoot}",
        "externalConsole": false,
	"stopOnEntry": true,
        "MIMode": "lldb"
      }
    },
    "Attach": {
      "adapter": "CodeLLDB",
      "filetypes": ["rust"],
      "configuration": {
        "request": "attach",
        "program": "${workspaceRoot}/target/debug/${fileBasenameNoExtension}",
	"PID": "${PID}",
        "args": [],
        "MIMode": "lldb"
      }
    }
  }
}

stucash avatar Jan 29 '24 09:01 stucash

I've created vimspector_root/configurations/linux/rust/.vimspector.json

rename to ‘rust.json’. Or some other non-hidden file name in that directory

puremourning avatar Jan 29 '24 09:01 puremourning

Thanks! for rust vimspector seems to think that the ${workspaceRoot} or ${workspaceFolder} to be root_folder/src for rust, whereas a local config got it correctly as root_folder/.

Typically rust's bin folder is root_folder/target/debug/; the global config thought it was root_folder/src/target/debug; is there a way I work around this?

stucash avatar Jan 29 '24 11:01 stucash

I don't understand the question (and it seems not relevant to this issue), but the behaviour of determining the workspace root is documented in the reference guide https://puremourning.github.io/vimspector/configuration.html#project-and-global-configurations

one alternative is to not use ${workspaceRoot} and use, say ${MY_PROJECT_ROOT} (or anything else, which you can then set in vim with :let $MY_PROJECT_ROOT=getcwd() or something. I often have an env var which is the root of my actual project if I'm using centralised configs.

puremourning avatar Jan 29 '24 11:01 puremourning

thanks; I'll have a read and I've updated my comment above; hope it clarify the issue I have a little bit.

stucash avatar Jan 29 '24 11:01 stucash

I don't understand the question (and it seems not relevant to this issue), but the behaviour of determining the workspace root is documented in the reference guide https://puremourning.github.io/vimspector/configuration.html#project-and-global-configurations

one alternative is to not use ${workspaceRoot} and use, say ${MY_PROJECT_ROOT} (or anything else, which you can then set in vim with :let $MY_PROJECT_ROOT=getcwd() or something. I often have an env var which is the root of my actual project if I'm using centralised configs.

Ah that's a good one; I just tried and it worked well.

stucash avatar Jan 29 '24 12:01 stucash

What about something like: https://github.com/sharksforarms/vimspector-gen

luisdavim avatar Feb 07 '24 23:02 luisdavim