ilyachur/cmake4vim

Specify cwd when invoking `:CMakeRun`

Closed this issue · 9 comments

Is your feature request related to a problem? Please describe.
Currently, there's no (or not documented) method to change the cwd when running :CMakeRun

Describe the solution you'd like
Perhaps a use variable the user can set, like cmake_run_cwd?

Describe alternatives you've considered

Additional context
Add any other context or screenshots about the feature request here.

@sam20908

:CMakeRun command executes the binary from the current executable target.
It means if you want to change the executable file, you need to change the CMake target.

But :CMakeRun allows to specify command line arguments for the executable. You can just add these arguments to command line:
:CMakeRun arg1 arg2 arg3

What I'm asking is how to change the current working directory when I run the executable.

Yes, sorry, my mistake.
In general, at the current moment, CMakeRun doesn't change CWD.
You can try to change work directory before CMakeRun command

That's also not really an option for me, I guess for now I can just invoke the executable directly.

You could always open up a terminal in a new tab/split and just re-run the binary there every time you need to.

Or even add a mapping that does that for you.

Yes, for future, I think vimspector config could be used to specify work directory.
But currently it is not supported

It does support it, the key is cwd. It has to be modified manually, though.

It does support it, the key is cwd. It has to be modified manually, though.

Vimspector support CWD and Vimspector config contains this key, but :CMakeRun command doesn't read this key from the Vimspector config.

@sam20908 In PR #150 I added support of cwd for :CMakeRun in case of using Vimspector. Feel free to reopen the ticket if you have any issues.