4

I have a sizable vim script (a .vim file, in viml syntax). I'd like to check (but not execute!) the file for simple syntax errors.

How do I accomplish this?

I just want a very rough syntax check. Something along the lines of perl -c or pyflakes.

Charles
  • 50,943
  • 13
  • 104
  • 142
bukzor
  • 37,539
  • 11
  • 77
  • 111
  • 1
    Uhmm, is there a specific reason why you don't want to execute it? – Rook Jan 24 '12 at 01:44
  • Any number of reasons. The script needs inputs that I don't have, or it makes changes to a git repository, which I don't want to do everytime I need to test the script. I'm sure a creative mind can think of more. – bukzor Jan 24 '12 at 04:46
  • couldn't Vim syntax highlighter suffice? – Benoit Jan 24 '12 at 09:32
  • 1
    @Benoit That one that thinks `map` being a command no matter where it appears on the line if not inside parenthesis? What when you put a start of function call on one line and use line continuation will say that last closing parenthesis is an error unless you do this inside a function? There are more examples of such errors: Vim syntax highlighting of VimL files is the worst among other languages I use, so one must not ever trust it. – ZyX Jan 24 '12 at 13:49

4 Answers4

2

Here is a syntax checker for VimL. https://github.com/syngan/vim-vimlint/

  • Very interesting! I must try it. If it works, I'll work on integrating it to [syntastic](https://github.com/scrooloose/syntastic). – bukzor Dec 11 '13 at 20:08
1

I don't think (I'm relatively sure, as much as one can be) one exists. VimL is an internal language of Vim (and only Vim), and there aren't many tools developed for it.

I tried searching on vim.org and several other places, with no luck. Not suprising, because I've never heard of one either.

So you're either stuck with running the script, or switching to an outside language like Python, Perl or Ruby.

Rook
  • 60,248
  • 49
  • 165
  • 242
  • Is there no vim function which reads a .vim file without executing it? – bukzor Jan 24 '12 at 23:21
  • @bukzor - I don't believe so. Honestly, I see no need for it. The usual way of doing this is simply running the code. VimL is not that big of a language that people are going to make enterprise-class applications in it. – Rook Jan 24 '12 at 23:24
0

https://github.com/osyo-manga/vim-watchdogs

vim-watchdogs, apparently, is a syntax checker for vim, it says that it supports many languages, including vimL

if you use vundle, you can just drop this into your vimrc:

Plugin 'git://github.com/osyo-manga/vim-watchdogs.git'

..and then run:

:PluginInstall

..to set it up (vundle is a very nifty plugin manager) If you have syntastic, you might want to be careful and disable it first, and then see if it is an adequate replacement (since it says it supports all those languages anyway).

It is a safe bet that when you have multiple syntax checkers going, you will need to put your "dogs on a leash", so to speak; by configuring one to check languages that the other one does not, and vice-versa. If you do not, there will be at best collisions, duplications, or misdirections. At worst, you will have all of the above and more.

Make sure that you always backup your ~/.vim directory (or your VIMRUNTIME directory if you install things on a global level), you will be glad you did. Hope that helped you or someone else out, good luck! Sorry you had to wait 7.5 months for a response, heh :)

osirisgothra
  • 2,163
  • 24
  • 19
0

There's now a second option: vim-lint (as opposed to vimlint)

bukzor
  • 37,539
  • 11
  • 77
  • 111