People who code: we want your input. Take the Survey

Hot answers tagged

10

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


8

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

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.


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

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


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


4

This is happening because while :make! doesn't jump to the first error message, it actually sets the quickfix cursor at it. So when you use :cnext it will actually try to go to the second error, which in your case doesn't exist. (You can easily prove that yourself by creating a test case that produces more than one error.) If you use :make! and then want to ...


4

There are, in fact, some predefined build scripts, and it is relatively straightforward to create your own. These are known as compiler plugins or scripts, and live in the compiler directory of runtimepath. You can switch to a compiler with the :compiler command, or by setting makeprg and errorformat (which is what most of these scripts do). You then build ...


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

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


3

how to debug it? You can use the :verbose command to increase verbosity of a specific command. In this particular case, you need verbosity level above 3 to see the actual shell command executed by Vim, so this should work: :4verbose make Calling shell to execute: "pylint --output-format=text --msg-template="{path}:{line}:{column}:{C}: [{symbol}] {...


3

Assuming that the plugin is using the standard scheme for filetype specific configuration... Probably the simplest way to override is by creating a file in $MYVIMDIR/after/ftplugin with filename that matches the filetype (aka ft) setting when such a file is loaded. The plugin likely has a file of the same name and it will either be in directory ftplugin ...


3

Yes. This is basically a 2 part question. Can you compile a program in vim, yes :make will run your Makefile, you can also set makeprg to your compile program if its different. type :he :make and :he makeprg for more info Can you see the output of a command in vim, yes :vertical terminal ++shell ++cols=40 dir Will run the command dir and show the output ...


3

This happens because a 'shellpipe' of the default of > (which is the default on Windows) doesn't really work on Powershell. It seems to have it produce a file that uses UTF-16 encoding and then NeoVim has trouble parsing the Unicode BOM character at the beginning of it. The 'shellredir' setting gives us a good clue of how to solve it... So just setting '...


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.


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