4

This question has been asked, in one form or another, a dozen times here, and it blows my mind how not a single one actually addresses how to configure syntastic or jslint such that it actually does what it is supposed to do (its README file is completely useless)

see here

Can anyone provide some step by step instructions, or a link to such instructions. I tried to install jslint and spidermonkey, and I got nowhere.


I managed to get the syntax check to work (thanks to romainl). A few things I learned along the way that may help anyone with a similar problem

  1. To build Javascript Lint look for the README file nested in jsl-x.x.x/src/README.html
  2. The build instructions are gmake -f Makefile.ref but gmake is the same thing as make so issue the command sudo ln -s /usr/bin/make /usr/bin/gmake
  3. jsl will now be found in jsl-0.3.0/src/Linux_All_DBG.OBJ/jsl. To make it generally accessible do something like: ln -s /whatever/jsl-0.3.0/src/Linux_All_DBG.OBJ /home/ForestGump/bin/jsl. More information here
  4. To check that jsl actually works find a test file ( here) then issue the command jsl -process test.js. It should list all the errors.
  5. To customize your command line, add this to your vimrc file set statusline=%{SyntasticStatuslineFlag()}
Community
  • 1
  • 1
puk
  • 16,318
  • 29
  • 119
  • 199

2 Answers2

2

Setup vundle according to its README.

Put this into your .vimrc:

Bundle 'scrooloose/syntastic'

Then enter this command in vim:

:BundleInstall

That's it.

EDIT: Vundle has changed its syntax since I originally wrote this. Nowadays, you use

Plugin 'scrooloose/syntastic'

and then enter

:PluginInstall
Cody Poll
  • 7,690
  • 3
  • 27
  • 22
2

What did you do? What works and what doesn't? Do you get error messages?

Here is what I did:

  1. Downloaded the jsl sources from the JavaScript Lint site.
  2. Built jsl and moved it somewhere in my $PATH.
  3. Checked if it worked by running it against a random .js file
  4. Downloaded and installed Syntastic as a Pathogen bundle.
  5. Typed :helptags /path/to/syntastic/doc because for some reason Pathogen's automatic help tags generation doesn't work for me.
  6. Read Syntastic's documentation: :help syntastic.

Steps 1 to 5 didn't take more than 3 or 4 minutes, maybe less.

Step 6 is obligatory, whatever new tool you try. RTFM.

I didn't have to configure anything beside these 3 lines in my .vimrc (and I believe the third is redundant):

let g:syntastic_auto_loc_list=1
let g:syntastic_disabled_filetypes=['html']
let g:syntastic_enable_signs=1

and customizing my statusline a bit with:

%{SyntasticStatuslineFlag()}

EDIT

Here is my statusline:

set statusline=%<\ %n:%f\ %m%r%y%{SyntasticStatuslineFlag()}%=line:\ %l\ of\ %L,\ col:\ %c%V,\ win:\ %{WindowNumber()}\ 

Don't copy it verbatim or you'll get some errors due to the function call at the end. There is a paragraph about that in syntastic's help.

END EDIT

After all that, 10 or 12 minutes if you count reading the documentation, I have a very helpful location list and signs poping up each time I save a .js file with syntax errors.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • I passed step 1), but how do I build it? There's no config file, make file, or even a README file (or anything on the website) – puk Oct 28 '11 at 09:07
  • 1
    OK I found the README file in the src directory, now I have to go install a command called `gmake` – puk Oct 28 '11 at 09:14
  • I am not sure if what I did works, I don't understand what to do with `%{SyntasticStatuslineFlag()}`. Does that go in my vimrc file? It generates an error when I put it there. It does not look like a command – puk Oct 28 '11 at 09:38
  • Thanks so much for your help, I'll edit the question with some additional information for anyone else that comes across this. – puk Oct 28 '11 at 09:47
  • The `%{SyntasticStatuslineFlag()}` goes into your statusline. See my edit. – romainl Oct 28 '11 at 10:04
  • I'm very grateful for your help, but I want to point out that 10 or 12 minutes is best case scenario. Worst case is 6+ hours. Someone might not know what `gmake` is, someone could do everything right, but not correctly set the statusline. Maybe they don't know that they have find the jsl binary and make it accessible to PATH... It's definitely no `sudo apt-get install` – puk Oct 28 '11 at 10:12
  • I agree it's not very easy or straightforward. Tinkering with this, hacking that is something I enjoy a bit too much, actually. Most of what relates to augmenting Vim's functions tends to be very hacky. The "hacker type" loves it but other users accustomed to other editors like NP++ or TextMate may find it frustrating. – romainl Oct 28 '11 at 10:56
  • I actually started using vim 2 days ago! I have a lot of experience with Unix so it wasn't a culture shock. Since you're a hacker, do you have any other upgrades to vim you'd recommend? – puk Oct 28 '11 at 11:08
  • Hoho, don't go too fast. I wouldn't say I'm a hacker, I reserve this name to people a lot better than me. Has a wannabee hacker, though, I'd recommend to modify Vim the less possible. However, beside Syntastic I would recommend SnipMate, Sparkup, Surround, either Taglist or Tagbar and VCSCommand. – romainl Oct 28 '11 at 20:15