Syntax highlighting for apache-config

1,462 views
Skip to first unread message

saspijkerman

unread,
Nov 19, 2009, 4:09:21 AM11/19/09
to vim_mac
Hi,

I often edit apache configuration files on the mac. Syntax
Highlighting never 'auto-starts'. I found out why:

In the following file are the filename-checks for syntax modus:

/Applications/MacVim.app/Contents/Resources/vim/runtime/filetype.vim

The lines for Apache Syntax mode are the following:

" Apache style config file
au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle')
" Apache config file
au BufNewFile,BufRead .htaccess setf apache
au BufNewFile,BufRead
httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/
apache2/*.conf* call s:StarSetf('apache')
" More Apache files.
au BufNewFile,BufRead /etc/apache2/conf.*/*,/etc/apache2/sites-*/*,/
etc/apache2/mods-*/* call s:StarSetf('apache')

But on OSX Snow Leopard the default apache location is

/private/etc/apache2/ in stead of /etc/apache2/

So I replaced the line:

au BufNewFile,BufRead
httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/
apache2/*.conf* call s:StarSetf('apache')

with the following line:

au BufNewFile,BufRead
httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/
apache2/*.conf*,/private/etc/apache2/*.conf* call s:StarSetf('apache')


It works perfectly for now but I am afraid that this file will be
replaced if there is an update for the MacVim App.
How can I stop this from happening (and don't update doesn't count)?

björn

unread,
Nov 19, 2009, 11:42:49 AM11/19/09
to vim...@googlegroups.com
2009/11/19 saspijkerman:

Send a patch to vim_dev and ask Bram to include it in the mainline
(carefully explain why you made the patch).

In the meantime I guess you could just add the above autocommand (with
the "/private/etc/apache2/*.conf*" line only) to your ~/.vimrc file.

Björn

Niklas Lindström

unread,
Nov 19, 2009, 12:25:58 PM11/19/09
to vim...@googlegroups.com
Hi,

.. or in a <~/.vim/filetype.vim> file (which is also read). See:

:help new-filetype

Best regards,
Niklas

saspijkerman

unread,
Nov 20, 2009, 4:42:15 AM11/20/09
to vim_mac
Hi Niklas,

Thanks for that option. I didn't know that.

I created the <.vim/filetype.vim> file and added the following line:

$ cat .vim/filetype.vim
au BufNewFile,BufRead /private/etc/apache2/*.conf* setf apache

It works like a charm.

Stef
Reply all
Reply to author
Forward
0 new messages