Reputation: 59367
I'm using VIM to work on Visual Studio solutions, and I have written a function that searches the filesystem upwards from the current file and locates the first *.sln file.
What I want to do is something like this:
function! BuildSLN()
" FindSLN is my function that locates the sln "
let slnfile = FindSLN()
if slnfile != ""
execute "!devenv " . slnfile . " /Build Debug"
endif
endfunction
CompilerSet makeprg=:call BuildSLN()
This way, I could use my currently set keybindings for :make
to build the solution file.
Is this possible?
Upvotes: 3
Views: 1940
Reputation: 32926
You can define a mapping/function/command/whatver that:
Personally, I'd rather have makeprg set when I edit a file from a directory (that I associate to a project). And a few mappings to toggle the compilation mode aspects (debug/release, background/or not, target (cross-compilation/or not), multithreaded compilation/or not, etc). Each time one of the aspects is changed, I update makeprg.
Upvotes: 0
Reputation: 59367
I have found a solution, although not technically an answer to my own question :)
Since I am loading the compiler settings whenever I enter a C# or VB.net buffer, I am just going to do:
let &l:makeprg='"devenv.com "' . FindSLN() . '" /Build Debug"'
in the compiler settings file. This gives me the effect that I want, however it technically does not set the makeprg to a function that will be evaluated when :make
is called, like originally requested.
Upvotes: 3