Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Temporary compiler arguments #350

Closed
hseg opened this issue Sep 1, 2024 · 14 comments
Closed

Documentation: Temporary compiler arguments #350

hseg opened this issue Sep 1, 2024 · 14 comments

Comments

@hseg
Copy link

hseg commented Sep 1, 2024

I've been looking for a way to volatilely set makeprg to some combination of a base program and arguments. That is, I'd like something like

:Compiler pylint --disable=C0116 %:S

to have the effect of

:compiler pylint
:let &makeprg.="--disable=C0116 " . expand("%:S")

or at least have

:Oneshot pylint --disable=C0116 %:S

with the effect of

:compiler pylint
:make --disable=C0116 %:S

Of course, I could just write a command to do that, but I was looking for something built-in first. Reading the README, I initially thought :Dispatch or one of its variants would do so, however the docs suggest :Dispatch prog args uses args to identify the particular plugin to use. (Incidentally, the comment about using the 'errorformat' to construct the :Make invocation doesn't make much sense to me, I'd appreciate clarification). In particular, my initial thought to use :FocusDispatch to set the current argument combination wouldn't've worked.

I then found plain :make does work for the second option I wanted, but of course it foregrounds the process. Then I tried :Make. To my delighted surprise, it behaves like the first option -- i.e. invoking :Make args will have the side effect of setting makeprg to makeprg . args.

Is this intended? If so, it is undocumented. If not, please keep this behaviour around in some capacity -- at least in my workflow it is currently useful.

@tpope
Copy link
Owner

tpope commented Sep 1, 2024

I then found plain :make does work for the second option I wanted, but of course it foregrounds the process. Then I tried :Make. To my delighted surprise, it behaves like the first option -- i.e. invoking :Make args will have the side effect of setting makeprg to makeprg . args.

The way I would phrase this is that :Make is a drop-in replacement for :make. Hence the name.

Is this intended? If so, it is undocumented. If not, please keep this behaviour around in some capacity -- at least in my workflow it is currently useful.

The existing documentation seems clear enough to me, but I'll tweak the wording a bit.

@tpope tpope closed this as completed in 63e4570 Sep 1, 2024
@hseg
Copy link
Author

hseg commented Sep 1, 2024 via email

@tpope
Copy link
Owner

tpope commented Sep 1, 2024

In particular, unlike :make args, it persists the choice of arguments, so that a subsequent :Make runs with the same arguments.

It does not do this.

@hseg
Copy link
Author

hseg commented Sep 1, 2024

I don't know what to tell you, but on my machine

:compiler pylint
:set makeprg
makeprg=pylint --output-format=text --msg-template="{path}:{line}:{column}:{msg_id}: [{symbol}] {msg}" --reports=no
:Make %:S
<makes>
:set makeprg
makeprg=pylint --output-format=text --msg-template="{path}:{line}:{column}:{msg_id}: [{symbol}] {msg}" --reports=no %:S

whereas the same with :make does not change makeprg

@hseg
Copy link
Author

hseg commented Sep 1, 2024

I'm currently trying to set up a temp config to confirm this is due to Dispatch, and not a poor interaction with something else

@hseg
Copy link
Author

hseg commented Sep 1, 2024

OK, it seems to be an interaction with something in my .vimrc, bisecting to find it

@tpope
Copy link
Owner

tpope commented Sep 1, 2024

You can check :verbose set makeprg? to find what last changed the option.

@hseg
Copy link
Author

hseg commented Sep 1, 2024

Ah, OK -- it appears to be due to these lines in my vimrc, though I have no idea why:

augroup tooling
    autocmd!
    autocmd QuickFixCmdPost [^l]* cwindow " open quickfix if errors exist
augroup END

@hseg
Copy link
Author

hseg commented Sep 1, 2024

You can check :verbose set makeprg? to find what last changed the option.

With my autocmd restored, this blames dispatch/autoload/dispatch/job.vim line 112

tpope added a commit that referenced this issue Sep 2, 2024
@hseg
Copy link
Author

hseg commented Sep 2, 2024 via email

@tpope
Copy link
Owner

tpope commented Sep 2, 2024

67a49fa now makes :Make throw errors after any compiler is set

Fixed in aeb5242.

In re my request to keep the current behaviour, I guess I can work around it by instead using m<Space><Up> and history editing, though that's a little more annoying.

Note that even by your own requirements the behavior I fixed wasn't very helpful. Repeated calls to :Make <args> would make the argument list longer and longer.

In particular, my initial thought to use :FocusDispatch to set the current argument combination wouldn't've worked.

There actually is an undocumented incantation to use :FocusDispatch to build on the currently active compiler plugin:

:FocusDispatch -- --disable=C0116 %:S

@hseg
Copy link
Author

hseg commented Sep 2, 2024 via email

tpope added a commit that referenced this issue Sep 2, 2024
tpope added a commit that referenced this issue Sep 2, 2024
@tpope
Copy link
Owner

tpope commented Sep 2, 2024

Still not the case here:

Gah, I keep forgetting to I need to test it with an existing compiler plugin already enabled. Should be fixed now.

@hseg
Copy link
Author

hseg commented Sep 3, 2024 via email

hseg added a commit to hseg/vim-dispatch that referenced this issue Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants