make/makeprg integration #8

Closed
mMontu opened this Issue Aug 14, 2012 · 7 comments

Comments

Projects
None yet
2 participants
Contributor

mMontu commented Aug 14, 2012

Hi Peter,

Thanks for your work with Vim plugins!!
I 'm still starting using them (just moving from open.vim to shell.vim), but I'm impressed with the great ideas of easytags and session.

I've started using shell.vim due to the DLL in order to avoid the command prompt windows.
The Fullscreen command is also very nice. I didn't intended to use it, but I've changed my mind after I tried it for some time. Unfortunately it is conflicting with some silent make commands present on some mappings.

I've some mappings to execute tasks such as [build], [clean], [clean+build] and [build+run] that are based on silent make. The problem is that when gVim is fullscreen and silent make is executed it leaves fullscreen for a while, as a command prompt get the window focus. This also make the start menu bar to hide gVim statusline, which is used to display some status messages.

I was wondering if it is possible to use xolox#shell#execute() to run the make command, but it isn't easy to see how this can be accomplished. I was thinking about using 'makeprg' and 'shell' options, but as 'shell' is already used by xolox#shell#execute() this probably won't work.

Have you already went through this issue, or have any ideas?

xolox added a commit that referenced this issue May 1, 2013

Owner

xolox commented May 1, 2013

Hi & thanks for the feedback! I just released a new version of the vim-shell plug-in which comes with a new command :MakeWithShell. For simple use cases this command can be used as a drop in replacement for Vim's built-in :make command, so just change your mappings to use this new command and you should be good to go :-). I'm closing this issue now. If you have any trouble with the new feature feel free to reopen this issue or create a new one.

@xolox xolox closed this May 1, 2013

Contributor

mMontu commented May 3, 2013

Hello!! I'm glad that you are back improving your great plugins :D

I've tested the :MakeWithShell and noticed that it doesn't work well with my mappings, because they use cwindow and v:shell_error to change the screen layout.

Is it possible to change this new command to work like make for those features?

No problem if it is not, as this plugin is very useful due to :Open command.
I've been using it for some time by itself and associated with Ctrlp plugin: kien/ctrlp.vim#232. I find this very useful, maybe it could be included in the documentation.

@xolox xolox reopened this May 3, 2013

Owner

xolox commented May 3, 2013

Hello!! I'm glad that you are back improving your great plugins :D

Glad to be back ;-)

I've tested the :MakeWithShell and noticed that it doesn't work well with my mappings, because they use cwindow and v:shell_error to change the screen layout.

Is it possible to change this new command to work like make for those features?

It's a shame :MakeWithShell doesn't work out of the box. The v:shell_error is a read-only variable which cannot be set from Vim script, so I can't fix this. I can think of a dirty way to set the variable despite the restriction, but it involves executing the system() function which will pop up a console window on Microsoft Windows, and ... we're back to square one :-p.

I'm not sure what problem you are having with the :cwindow command? The :MakeWithShell command actually uses it internally and it worked fine in my tests (as in a quick-fix window popped up and presented me with a list of errors).

Anyway, I'm wondering about something: You already changed your mappings to execute :MakeWithShell instead of :make. I'm not sure how much code is contained in your mappings, but wouldn't it be easier to rewrite the mappings instead of making vim-shell compatible with :make? (as it seems that this is becoming more complex that I thought).

Contributor

mMontu commented May 14, 2013

You are right, :cwindow works fine - I noticed that actually :MakeWithShell differs from :make in that it automatically executes :cwindow, which is fine for me.

I use v:shell_error when working with embedded systems and target program on makefile to load the binary file on target processor. This target usually involves calling an external command to control the emulator/loader, and v:shell_error indicates if the loading was successful.

Filtering the output of external commands could be an alternative. The problem is that there are several versions of external commands and loaders, and there are always new versions, so the filter is likely to require frequent updates.

I didn't noticed that v:shell_error is read-only. I was wondering if it is possible to MakeWithShell have its own shell_error variable, so it would be possible to know the return status without filtering.

Anyway, the plugin is great on its current state, so if this is going to make the plugin overly complex I believed that it can be ignored.

xolox added a commit that referenced this issue May 14, 2013

Owner

xolox commented May 14, 2013

I use v:shell_error when working with embedded systems and target program on makefile to load the binary file on target processor. This target usually involves calling an external command to control the emulator/loader, and v:shell_error indicates if the loading was successful.

Sure it makes a lot of sense to want to know whether make succeeded or failed :-)

Filtering the output of external commands could be an alternative. The problem is that there are several versions of external commands and loaders, and there are always new versions, so the filter is likely to require frequent updates.

That sounds dirty and fragile :-p (I'm speaking from experience here ;-). Fortunately I recently improved another aspect of the vim-shell plug-in: It can now reliably report exit codes on Windows and other platforms and the exit code is now exposed as one of the return values.

Based on that work it was very easy to add a variable with the latest exit code, so I just released a new version of vim-shell which includes the new g:xolox#shell#make_exit_code variable. Here's the relevant bit I added to the documentation:

Because Vim’s v:shell_error variable is read only (which means it cannot be set by a Vim plug-in) the vim-shell plug-in defines its own variable with the exit code of the make process executed by :MakeWithShell. This variable is called g:xolox#shell#make_exit_code. The semantics are exactly the same as for v:shell_error.

I think this is the best I can do given the circumstances so I'm closing this issue now, however if you have any remaining trouble with :MakeWithShell feel free to reopen this issue or create a new one. Thanks for your feedback & happy Vimming!

@xolox xolox closed this May 14, 2013

Contributor

mMontu commented May 20, 2013

This new variable solved the problem; it works like a charm! Thanks!

Just for reference: I had some trouble to make MakeWithShell work -- for some reason it stops with some messages about redefining xolox#shell#make and a missing endif - both on file ...\vimfiles\bundle\shell_4aada54636\autoload\xolox\shell.vim. I double checked that there were no redefinition of this function on any file on &rtp. I've traced the problem to session.vim plugin; I didn't found what was causing the conflicts, but updating to the latest version (commit 5ad0d15bae) solved the issue.

Contributor

mMontu commented Jun 7, 2013

Hello Peter,

I've just noticed that MakeWithShell doesn't works very well when compiling C# code.

Using compiler msbuild (from https://groups.google.com/forum/?fromgroups=#!topic/vim_dev/q644Mx3ehYM) and make on files with errors, followed by cwindow does open the quickfix window. Replacing make with MakeWithShell doesn't opens the quickfix, similar to sucessful compilation result.

Is it possible to change MakeWithShell so it works like make on this case too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment