Sonntag, 6. November 2011

How to install doctorjs/jsctags on Windows (for Vim)

This is a short guide that explains how I  installed doctorjs aka jsctags on my Windows 7 machine.

node.js Installation
First we have to get a working node.js binary. You can find a precompiled node.exe file in the apropriate  folder under . At the time of this writing the newest version is 0.5.10, so I used the following address:

Clone doctorjs repository
Now get the newest version of doctorjs by cloning the repository with git. I used Git for Windows (portable version) for this. To clone it use the following command:
F:\> git clone --recursive
Alternatively, github provides a packed zip file of the repo.

Test run
Open up the command line and navigate to the folder where you saved node.exe (F:\nodejs in my case).
Use the following command to set the environment variable NODE_PATH in this test session:
F:\nodejs> set NODE_PATH=F:\doctorjs\lib\jsctags  
This is necessary because otherwise it's not possible for node.js to locate the required libraries to run doctorjs:
Finally we can test our setup:
F:\nodejs> node.exe F:\doctorjs\bin\jsctags.js -h
Vim and tagbar plugin
I created an batch file jsctags.bat that basically executes these steps above.

With this script it is possible to use the tagbar plugin for Vim (or any other plugin generating tag files via jsctags).  As a last step we add the path of the directory containing jsctags.bat to the environment variable PATH. To do so, add something like the next line to your _vimrc configuration file:
let $PATH = 'F:\jsctags;' . $PATH

1 Kommentar:

  1. Thanks for writing this. I got jsctags working following your instructions. I notice that in the tagbar window the function names are double space -- do you know how to make them single spaced?