Hot answers tagged

7

Built in compiler plugin pyunit As already suggested by jamessan, one option is to use the built in compiler plugin pyunit: :compiler pyunit :set makeprg=python3\ % :make This has the downside, that it collapses the stack trace to a single error message. For example the following python script: def lumberjack(): bright_side_of_death() def ...


7

Vim comes with a set of "compiler" scripts, one of which is called "pyunit". If you run :compiler pyunit and then :make (with your suggested value for 'makeprg'), quickfix is populated as you expect. However, it only works well if there's one level to the stack trace. Improving that compiler script would be a useful exercise. The ...


6

You can modify what is being expanded using so called filename modifiers. See the help at :h filename-modifiers (link). In your case you can e.g. use :set makeprg=gcc\ -Wall\ -g\ %\ -o\ %< See also the faq


5

Use :compiler!. From :h :compiler: :comp[iler][!] {name} Set options to work with compiler {name}. Without the "!" options are set for the current buffer. With "!" global options are set.


5

From :h :make: The ":make" command executes the command given with the 'makeprg' option. This is done by passing the command to the shell given with the 'shell' option. This works almost like typing ":!{makeprg} [arguments] {shellpipe} {errorfile}". {makeprg} is the string given with the 'makeprg' option. Any command can be used, not just "make". ...


5

The right-hand side of let &makeprg = ... is evaluated only once. If you put that command in your .vimrc as it is, %expands to /home/sporty/.vimrc and you get the interesting effect you describe. You need to put it in an autocmd, so that it gets re-evaluated every time you open a file of the relevant type. Also, you probably want to use the local ...


5

Yes, Vim has the built in :make command which executes make by default, but you can set up other build systems by setting makeprg. There’s no progress visualisation by default, but once :make is done you can move through errors an earnings encountered with :cnext and :cprev. Calling :copen will show you all of them. One disadvantage though is that :make is ...


4

The trick is to forget about wrapping your mind around set syntax, and use let instead: let &makeprg = 'make -f ' . fnameescape(substitute(expand('%'), '\m_test\.cpp$', '.makefile', '')) See :help :let-& for details.


4

Actually asyncrun has that feature. According to the document: AsyncRun displays its output in quickfix window, so if you don't use :copen {height} to open quickfix window, you won't see any output. For convenience there is an option g:asyncrun_open for you. So you just put this code :let g:asyncrun_open = 8 in your .vimrc. When you press <leader>...


4

My understanding is that the makeprg setting is primarily used to change the actual make/build program and in your case the program isn't changing...it's always 'make'. Since :make accepts arguments I suggest leaving 'makeprg' alone and passing your build command args to :make in the two mappings... noremap <F4> :make -f ~/makefile1 %<<CR> ...


4

why is stderr redirected to stdin, In order to have both end up in the quickfix list. what is that second command with tee doing, man tee. It redirects stdin into a file and into stdout. It's an extremely useful command to log and watch the execution of commands that send a massive amount of lines into stdout and/or stderr. and how do I remove both ...


3

As of 7.4.1802, Vim is supposed to quickfix lines up to 4096 bytes long instead of truncating them.


3

Make and Ninja offer a -C flag. From Ninja: -C DIR change to DIR before doing anything else If I run Ninja in a shell with the -C flag pointing somewhere that isn't the working directory, then the reported paths are the same as if I had cd'd over to the build directory. Nonetheless, Vim knows to become more intelligent when you use this flag in your ...


3

As stated on the question, :h map-bar suggests escaping the pipe with with \|. However, grep apparently understands that as a literal bar, thus the backslash needs to be escaped as well. This should work for grep: :grep -E 'foo\\|baz' *.c NOTE: there's no need to escape the backslash with vimgrep (:h :vimgrep). The following seems to give the same results ...


3

quickfix.py parses the traceback into a vim-friendly errorformat. Here is an example of running it on a file with a single line 1 / 0. ❯❯❯ quickfix.py tests/errors/div_by_zero.py "tests/errors/div_by_zero.py":1: ZeroDivisionError: division by zero By default, it shows user files, but it can show system files too (running it on a file containing import os; ...


3

Your first command was closer: :vnew makes a new vertical window. :vertical is the modifier that changes how other commands work: :vertical terminal make ts run-server Will get you the terminal. If you want that and the quickfix list, try tpope's Dispatch plugin: :Dispatch make ts run-server


3

Using 'makeprg': set makeprg=docker\ run\ --rm\ -v\ $(pwd):/src\ container\ make Unfortunately, the \ are necessary for set to keep the spaces; single quoting won't work here. Now you can run :make [arguments] and have it expanded to !docker run --rm -v $(pwd):/src container make [arguments] {shellpipe} {errorfile} (see :help :make and scroll down a bit)...


2

I suggest doing it like this: let &errorformat = \ '%E%\m:%\%%(compileJava%\|compileTarget%\)%f:%l: error: %m,' . \ '%E%f:%l: error: %m,' . \ '%Z%p^,' . \ '%-G%.%#' Proof: cgetexpr [':compileJava/file/path/Main.java:52: error: cannot find symbol', \ ' public static ABC abc;', \ ' ^', \ ' symbol: class ...


2

For example, if your ninja output directory is '$SRC/out' :set makeprg=ninja\ -C\ $SRC/out Note: the space should escape by backslash


2

Vim does not support Ansi escape color codes. The AnsiEsc.vim plugin attempts to fix this for some cases. However I doubt AnsiEsc can be combined with the quickfix list in any meaningful way. I suggest you remove the color from your maven output so you can use the quickfix functionality like :cnext/:cprev. Here is a simple 'errorformat' value for maven 3: ...


2

saginaw pointed out in a now deleted comment that running :silent! make | redraw! | cw instead of :make solves my problem. If I run it the program compiles, and if there is an error the QuickFix list is opened on the bottom and the line with the error highlighted. I expanded his solution further to deal with something else: Whenever the free pascal ...


2

You can run :make to lint and then run :terminal if there are no errors. command! -nargs=* -bang -complete=file_in_path PythonMake call <SID>PythonMake("<bang>", <q-args>) function! s:PythonMake(bang, args) execute 'make' . a:bang . ' ' . a:args if empty(filter(getqflist(), 'v:val.valid')) execute 'terminal python -i %' ...


2

I have made a small plugin vpager. That allows to dump the terminal output back into Vim. The last commit in addition allows to use the output and dump it into the quickfix list. So you can simply do :make |vpager -Q and it should be loaded back in Vim. (It might need adjustments for the errorformat setting, not sure). excerpt from the README: git diff | ...


2

I guess caddbuffer is currently the best way to achieve what I want.


2

Running wincmd p after the copen should work; you jump to the quickfix window and then right back to the window you were in e.g. autocmd QuickFixCmdPost * botright copen 8 | wincmd p see :h wincmd, :h CTRL-W_p


2

If you need to do sh/bash commands, you should run it via sh -c let &makeprg = 'sh -c "..."'


1

I had the same thinking for a solution as the other answer here has (wincmd p). But I found it was not 100% reliable depending on what quickfix command type is being used. If you have issues with that solution you might have some better luck with a solution that uses explicit window/buffer references. An easy approach is to save the current buffer name in a ...


1

Not exactly what you asked for (using the terminal new vim 8.1 feature) but you should check asyncrun plugin which let you execute whatever you want asynchronously and get the output in quick fix (using errorformat to parse the output...). asyncrun.vim


1

On windows gvim only, you can use set guioptions+=! to run make in a terminal. This isn't yet supported on other platforms so you will have to find an alternative. If you want to create a new terminal each time, command -nargs=* Make execute 'terminal' &makeprg.(empty(<q-args>)?'':' '.<q-args>)


1

After reading and trials, I understood where is the problem. PC-Lint (the linting tool I use) produces messages in specific format. For example, first comes the name of the file where the error is located %f, then comes the line number %l, then the message itself %m. This message format can be configured in PC-Lint. On the other hand, quickfix should be ...


Only top voted, non community-wiki answers of a minimum length are eligible