We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

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 unstack plugin may be of ...


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 ...


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

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 ...


3

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>...


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

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 ...


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

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


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

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 %' ...


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

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


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 ...


1

Plugin vim-dispatch by Tim Pope This plugin provides as one of its main features running makeprg non-blocking either in the foreground or the background. Quote from :h dispatch: Leverage the power of Vim's compiler system without being constrained by synchronicity. The first command by vim-dispatch is :Make (note the capital M): :Make [arguments] ...


1

Vim includes a feature called quickfix that consists of a way of compiling source code using an external program and processing its output. Any failures are loaded as an iterable list into the quickfix-window. You can also check the vim help pages for errorformat, which defines filtering expressions to identify error messages in the output of 'makeprg' (the ...


1

It's possible, with Vim8. First you'll need to register the current time with reltime() function. Then, start a job that'll run the content of &makeprg with $* replaced with the target you wish to used (it may be an empty string). Don't forget to register a hook that'll listen for any line produced by the compilation. You'll certainly wish to add it to ...


1

Unless you're using a non-properly configured version of gnumake (Solaris OS, or mingw distribution of gcc under windows), you don't need to modify &makeprg. Its default value is already perfect for GNU compilation tools. All you need to do is to set $CFLAGS with :let $CFLAGS="-g -Wall", and compile with :make %<.


1

TL;DR try the asyncrun.vim plugin, it will allow you run shell commands in background and read output from quickfix window in realtime. You can define shell scripts in your dotfiles repository and execute the script with F3: nnoremap <F3> :AsyncRun -cwd=<root> sh /path/to/your/dotfiles/script/build_advanced.sh <cr> The following shell ...


1

I can't tell about the first step as I'm not using Dispatch, and my CMake integration is different. As this isn't something we do that often, this isn't an important issue -- Normally, this isn't required more than once per project and per build type to initialise a build configuration ; I know, sometimes we add variables and need to run (c)cmake again ; IMO ...


1

My solution to have color working into vim and console is to use https://github.com/jcgay/maven-color Then set the colored log pattern into /opt/apache-maven-3.3.9/conf/logging/log4j2.xml <Console name="maven-color-true" target="SYSTEM_OUT"> <PatternLayout pattern="%highlight{[%p] %mavenMsg%n%rEx}{FATAL=red, ERROR=red, WAR> </Console> ...


1

Solved by comment from @jjaderberg. The problem is related to the compiler command. To quote Vim's help: 6. Selecting a compiler compiler-select :comp :compiler E666 :comp[iler][!] {name} Set options to work with compiler {name}. ...


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