Previous Up Next

Chapter 12  Configuring your environment

12.1  Editor

12.1.1  Vim

The Tom distribution contains some filetype plugins for Tom and Gom support in Vim. They are located in ${TOM_HOME}/share/contrib/vim.

To install them, you should put the content of the contrib/vim directory in ${HOME}/.vim/. Then in order for these plugins to be automatically used whenever it is necessary, you can put in your ${HOME}/.vimrc:
" indentation depends on the filetype
filetype indent on
filetype plugin on
Also, to have vim automatically loading Tom and Gom plugins when editing Tom and Gom files, you can edit (or create) the file {HOME}/.vim/filetype.vim:
if exists("did_load_filetypes")
  finish
endif
augroup filetypedetect
  au! BufNewFile,BufRead *.t   setfiletype tom
  au! BufNewFile,BufRead *.tom setfiletype tom
  au! BufNewFile,BufRead *.gom setfiletype gom
augroup END
For Tom developers, the preferred setup for indenting Tom and Java code is as follows, to be placed in ${HOME}/.vimrc:
autocmd FileType ant   set expandtab
autocmd FileType ant   set sw=2

" automatically indent tom and java code
autocmd FileType java,tom,gom set cindent autoindent
autocmd FileType java,tom,gom set encoding=utf-8
autocmd FileType java,tom,gom set fileencoding=utf-8

" how to indent: in java and tom, 2 spaces, no tabs
autocmd FileType java,tom,gom set expandtab
autocmd FileType java,tom,gom set sw=2
autocmd FileType java,tom,gom set tabstop=2
autocmd FileType java,tom,gom set nosmarttab

Compiling Tom under Vim

To compile Tom programs (like Tom) under Vim, and get a correct error reporting, you will have to set the ${CLASSPATH} environment value to the path of junit.jar, and use the makeprg variable to have :make call ant through a script maintaining the link between Tom and the generated Java files. We suppose here that Tom was installed in ${HOME}, i.e. ${TOM_HOME} is ${HOME}/workspace/jtom.
let $CLASSPATH = "${HOME}/workspace/jtom/src/lib/junit.jar"
set makeprg=ant\ -find\ build.xml\ -emacs\ $*\\\|\
            \ awk\ -f\ \"${HOME}/workspace/jtom/utils/ant-tom.awk\"

12.2  Shell

12.2.1  Zsh

Zsh completion functions for Tom and Gom are available in the share/contrib/zsh directory. To install them, you only have to add those files to zsh's fpath variable.

For example, assuming you already set up the TOM_HOME environment variable to the Tom installation directory, you can add to your ${HOME}/.zshrc:
fpath=(${TOM_HOME} $fpath)

12.3  Build Tom projects using Ant

To build complex projects using Tom, it is useful to use Ant as build system, to manage generation of data structure using Gom and the compilation of Tom and Java code.

To ease the use of Ant, the file ${TOM_HOME}/lib/tom-common.xml is provided in the Tom distribution. This file provide initialization for Tom and Gom Ant tasks. To load tom-common.xml, you just have to put in your Ant script:
  <property environment="env"/>
  <property name="tom.home" value="${env.TOM_HOME}"/>
  <import file="${tom.home}/lib/tom-common.xml"/>


Then, each target depending on the "tom.init" task will allow the use of the Gom and Tom ant tasks, as well as tom.preset and javac.preset, providing usual values for the attributes of those tasks. Also, tom-common.xml provides several properties, as tomconfigfile and gomconfigfile, providing the location of the configuration files for Tom and Gom, and tom.classpath, containing all classes related to the Tom installation.


Previous Up Next