26.32. Vim

26.32.1. Overview

The Vim Sensor collects data regarding developer activities using the Vim editor. The Vim sensor represents this data using the Activity sensor data type, documented in Section 25.2, “Activity”. Currently, the most important Activity event recorded by the Vim sensor is the "state change" event, which is used to generate the Active Time abstraction.

The Vim sensor consists of a Vim plugin (called VIMsensor.vim) that runs at startup and performs initializations, including the invocation of a separate stand-alone Java process (sensor.vim.jar). This Java process, once invoked, monitors a temporary file written out periodically by the Vim sensor that specifies the file you are working on, its size, and a timestamp. When you exit Vim, this temporary file is deleted by the Vim sensor. The next time the Java process checks for this temporary file and finds it is no longer available, it will also exit.

[Important]Important

The VIM plugin architecture does not support timer-based subprocesses. This limitation requires a non-standard approach to gathering state change events. Instead of having a process wake up every HACKYSTAT_STATE_CHANGE_INTERVAL and check for changes to the active buffer, the VIM sensor binds a special action to the carriage return key, which writes out a file indicating the current buffer and its size, which is then polled regularly by a separate Java process. There are several important implications of this design.

  • After typing a carriage return, the string :call <SNR>l_s:UpdateHSDataOnCR() may appear in the bottom line of the VIM window. This indicates that the VIM sensor has recorded information about your current file. This is either a feature (if you like seeing feedback when the sensor runs) or a bug (if you don't). We personally view this behavior as the latter, and are searching for ways to remove it.

  • The sensor will not function accurately if the same user runs multiple Vim processes simultaneously.

  • The user must type a carriage return regularly (ideally, at least as often as HACKYSTAT_STATE_CHANGE_INTERVAL) so that the active buffer and its size can be communicated to the underlying Java process.

  • If Vim exits abnormally, it is possible in some circumstances for an 'orphan' Java process to continue to run. Under normal circumstances, the Java process will terminate itself within HACKYSTAT_STATE_CHANGE_INTERVAL seconds after the Vim process exits. If you notice a Java process running well after termination of Vim, you should kill this process manually.

We continue to search for better solutions to Activity data recording for the Vim sensor, and welcome your suggestions.

26.32.2. Installation

26.32.2.1. Prerequisites

The Vim sensor requires Vim 6.3 or later and Java 1.5.0 or later. It must be possible to invoke this version of Java at the command line using 'java'. At this time, only Vim on Unix is supported.

26.32.2.2. Download HackyInstaller and set your Hackystat Host and User Key

Follow the instructions in Chapter 2, Client-side configuration: Tool sensor installation to set your Hackystat host and user key.

26.32.2.3. Configure and install the Vim sensor

In the HackyInstaller main window, select the Vim sensor and press "Configure Selected Sensor". Figure 26.57, “ Vim sensor installer configuration window ” shows what the configuration window should look like after the various sensor settings have been set and Applied and the sensor has been installed.

Figure 26.57.  Vim sensor installer configuration window


Vim sensor installer configuration window

This sensor supports the following properties and paths:

  • Enable Vim Sensor: This property controls whether the sensor is active or not. If not checked, the sensor will not collect or send data even if installed.

  • Vim Swap Update interval (milliseconds): 250 is a reasonable default value.

  • Vim Swap Character interval: Ensures that the swap file is updated after a certain number of characters edited. 4 is reasonable.

  • Vim data file directory: The location for the vim data file, such as /usr/home/dport/.hackystat/vim

26.32.3. Installation verification

26.32.3.1. Lower the Hackystat Autosend interval to 1 minute

To simplify Vim testing, go to the HackyInstaller main page, and change the Common Setting for automatic background sending of Hackystat data to 1 minute.

26.32.3.2. Hackystat Startup Message

Invoke Vim on a sample file for editing. When Vim comes up, you should see the messsage "Hackystat Sensor Active" appear at the bottom of the window, as illustrated in Figure 26.58, “ Vim displaying Hackystat startup message ”.

Figure 26.58.  Vim displaying Hackystat startup message


Vim displaying Hackystat startup message

26.32.3.3. List Sensor Data

Once you confirm the Hackystat startup message, edit your sample file for at least one minute. Be sure that you insert at least one carriage return into the file you are editing, so that the VIM sensor can detect your editing activities.

Once you are done editing the file, login to your account on your Hackystat server, and use the "List Sensor Data" command on the Extras page to verify that Activity data for today's date was received by the server for the Vim tool, as illustrated in Figure 26.59, “ List Sensor Data with Vim data ”.

Figure 26.59.  List Sensor Data with Vim data


List Sensor Data with Vim data

26.32.3.4. Daily Diary

If the List Sensor Data command verifies that you are receiving data at the server, then the final check is to use the Daily Diary command to verify that state change events are being sent and abstracted into the Most Active File, as illustrated in Figure 26.60, “ Daily Diary with Vim data ”.

Figure 26.60.  Daily Diary with Vim data


Daily Diary with Vim data

Once you have successfully edited a file, verified that it was sent to the server, and found it listed as the Most Active File in the Daily Diary, you can feel confident that the Vim sensor was installed correctly.

26.32.3.5. Revert autosend interval

Once you have finished verifying your installation, you may want to revert your autosend interval back to a higher value, such as 10. This is optional, but does reduce the level of network usage by the sensor.

26.32.4. Installation troubleshooting

26.32.4.1. Troubleshooting general client-server problems

The first step in troubleshooting your sensor installation is to verify that your Hackystat host and key settings are valid and that you can contact the Hackystat server, as described in Section 2.4, “HackyInstaller GUI: Setting and verifying the Hackystat host and user key”

26.32.4.2. Using an old version of Vim

If client-server connections check out, the next most commonly reported problem results from the use of a version of Vim prior to Vim 6.3 or later. To check your version invoke 'vim -version'.

26.32.4.3. Checking client-side logging

The Vim sensor writes out a file called vim.0.log to the .hackystat/logs directory that can be useful in debugging your installation. Under normal conditions, this file should look similar to Figure 26.61, “ Log file for Vim sensor ”.

Figure 26.61.  Log file for Vim sensor


Log file for Vim sensor

26.32.4.4. Submit a trouble report

If none of the above troubleshooting activities solves your problem, then you should send an email to your Hackystat Administrator to request help. Please include in your email the following information:

  • The output from 'java -version'.

  • The output from 'vim --version'.

  • The output from 'java -jar sensorshell.jar -verify'.

  • The contents of your sensor.properties file.

  • The contents of the vim.0.log file.

  • A description of the problem you are having.

26.32.5. Uninstallation

To disable Vim sensor data collection temporarily, invoke HackyInstaller, bring up the Vim configuration window, and uncheck the "Enable Vim sensor" property, and apply the setting. To permanently uninstall the Vim sensor, press the "Uninstall" button.