0

I am pretty new to Vim and coding in general. I'm trying to improve my compile-edit-compile cycle for Python. I just learned about Vim's :make and quickfix system; it's really cool. I would like to do static analysis to catch syntax errors etc.

I have NVim running and in my nvim/runtime/compiler/ directory I have a file called pylint.vim. I think it came as a default. Here is the text of it:

" Vim compiler file
" Compiler: Pylint for Python
" Maintainer: Daniel Moch <daniel@danielmoch.com>
" Last Change: 2016 May 20

if exists("current_compiler")
  finish
endif
let current_compiler = "pylint"

if exists(":CompilerSet") != 2      " older Vim always used :setlocal
  command -nargs=* CompilerSet setlocal <args>
endif

CompilerSet makeprg=pylint\ --output-format=text\ --msg-template=\"{path}:{line}:{column}:{C}:\ [{symbol}]\ {msg}\"\ --reports=no
CompilerSet errorformat=%A%f:%l:%c:%t:\ %m,%A%f:%l:\ %m,%A%f:(%l):\ %m,%-Z%p^%.%#,%-G%.%#

When I use the :make command with this compile script set using :compile pylint, I get the following output of the terminal:

:!pylint --output-format=text --msg-template="{path}:{line}:{column}:{C}: [{symbol}] {msg}" --report
s=no  2>&1| tee /tmp/nvimXypd20/2

Usage: pylint [options]

Options:
  -h, --help            show this help message and exit
  --long-help           more verbose help.

  Master:
    --init-hook=<code>  Python code to execute, usually for sys.path
                        manipulation such as pygtk.require().

I have omitted the rest of the long pylint stuff.

So this makeprg is configured to run without any filepaths as arguments to the bash command? Is that the normal way of doing it? Should I just use :make % or is there a better way?

1 Answer 1

2

Yes, you probably want to use :make %. The version presented is flexible in that you can pass filenames other than the current one.

But you can always :setlocal makeprg+=\ % after the :compiler pylint so that :make uses the current file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.