Thursday, September 19, 2013

Setting up VIM as IDE in MAC OS X


To setup VIM in mac os x :
#####################

1. By default MAC OS X comes with vim installed.

2. Download and install cscope-15.8a.tar.gz (601.2 kB) from cscope.org.

3. Unzip the cscope-15.8a.tar.gz from terminal. (tar -xvzf cscope-15.8a.tar.gz).

4. cd cscope-15.8.a folder, and do ./configure, make, and make install.

5. the above install may fail due to ncurses dependency with following error.
 
In file included from main.c:49:
/usr/include/ncurses.h:539:40: error: macro "cbreak" passed 1 arguments, but takes just 0
/usr/include/ncurses.h:564:44: error: macro "erasechar" passed 1 arguments, but takes just 0
/usr/include/ncurses.h:600:43: error: macro "killchar" passed 1 arguments, but takes just 0
make[2]: *** [main.o] Error 1

6. The above error can be resolved by making changes in src/constants.h file. Open this file in vim and modify the below line
 
 #if (BSD || V9 ) && !__NetBSD__ && !__FreeBSD__
with this
#if (BSD || V9 ) && !__NetBSD__ && !__FreeBSD__ && !__APPLE__

 
7. Now repeat step 4. It will succeed.
 
8. Download and install Exuberant Ctags from crags website http://ctags.sourceforge.net

9. Follow the similar procedure to install ctags
tar xzvf ctags-5.8.tar.gz
cd ctags-5.8
./configure
make
sudo make install
 
10. After exuberant crags installed, you can verify it using the below commands
which -a ctags

/usr/bin/ctags ==> original ctags
/usr/local/bin/ctags ==> exuberant ctags

11. To set OS X to use exuberant crags, just export the path
 
  export PATH="/usr/local/bin:$PATH"

12. Downlod Taglist plugin and unzip using tar -xzvf and do the following
 
Copy the tag list.vim to /usr/share/vim/vim73/plugin/.
Copy the tag list.txt to /usr/share/vim/vim73/doc/.

13. Thats it you are ready to go. If any problem such as Taglist showing empty or no tags appears add the following lines in vimrc file

let Taglist_Ctags_Cmd = "/usr/local/bin/ctags"
"to inform vim about filetype
filetype on
"to inform vim about syntax highlighting
  syntax on

14. To permanently avoid exporting path export PATH="/usr/local/bin:$PATH" each time, add following line in top of /etc/paths
 
/usr/local/bin

15. Add the below line  vimrc file to automatically find the tags file generated in current directory , all the way to root

 set tags = ./tags; /

If any doubt related to creating scope db and others refer to my previous posts. thank you.

Ref: http://vim-taglist.sourceforge.net/faq.html

No comments:

Post a Comment