sponsor Vim development Vim logo Vim Book Ad

SpamAssassin syntax : Syntax highlighting for SpamAssassin config files

 script karma  Rating 46/25, Downloaded by 2589  Comments, bugs, improvements  Vim wiki

created by
Adam Katz
 
script type
syntax
 
description
* Regular expression highlighting (from perl)
* COMPLETE recognition of all settings with a good understanding of syntax
* Settings recognized include all plugins shipped with SA plus a few 3rd-party plugins.

Spell-check is enabled on various pieces for which it is appropriate (vim 7+, you must turn it on first).

This has also been posted to the spamassassin users mailing list.
 
install details
Just like any syntax file.

Save this file to ~/.vim/syntax/spamassassin.vim and add the following to your ~/.vim/filetype.vim:

augroup filedetect
    au BufRead,BufNewFile user_prefs,*.cf,*.pre setfiletype spamassassin
augroup END

Note that this will override Postfix's main.cf and Sendmail's sendmail.cf ... I'm not sure how to rectify that.

To install it system-wide, save the attached file as /usr/share/vim/vim[0-9]*/syntax/spamassassin.vim and edit
/usr/share/vim/vim[0-9]*/filetype.vim in a manner similar to the local filetype.vim edit noted above.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
spamassassin.vim 3.3 2011-06-21 6.0 Adam Katz Mark any non-comment following a regex as an error, fix bug with comment recognition.  I'm now date-stamping my versions (see file comments) so that unpublished edits can be tracked without destroying the published versions.
spamassassin.vim 3.2 2010-11-06 6.0 Adam Katz Fixed saFunction (it needs to be in a cluster after all, I was previously highlighting /anything/ that looked like a function).  Added support for new 'reuse' option.
spamassassin.vim 3.1 2010-11-03 6.0 Adam Katz Extensive use of syn-cluster makes this more easily abstracted for additional plugins.  Plugin section broken into how it ships; enabled, disabled, not (third-party).  Each plugin section is fully independent and therefore can easily be deactivated or used as a model for a new plugin.  Rewrapped to wider view since lines were way over the 80-col size anyway.  Things are more properly contained now as well.  Removed abstraction for highlighting due to increased version dependency.  Added support for sa3.3 plugins and the remaining missing shipped plugins, plus iXhash.  Fixed regex detection (m// and friends were broken in 3.0).
spamassassin.vim 3.0 2010-11-02 6.0 Adam Katz MAJOR efficiency increase.  This is now usable on large files.  

Removed most \%(inefficient zero-width lookbehind\)\@<= portions in favor of using nextgroup since \%(this zero-width lookbehind can't contain ANY highlighting\)\zs  also fixed several outstanding minor bugs and added a few new highlighted areas (specifically for meta rules).  

Now that I've tested this with a genuine vim 5.8, I'm pretty sure it never worked.  Required vim version bumped to 6.0.  

Offline edits put this at 2.8 before 3.0, though 2.6+ were all very minor and I tend to err on the side of bumping up the version when my systems are out of sync.
spamassassin.vim 2.0 2009-11-04 5.7 Adam Katz Cleanup; no longer taking perl.vim wholesale (by require), now importing only the regexp matcher.  Also made other regexp tweaks.  Version bump to a .0-release to indicate pseudo-independence from perl syntax garbage (no more dependency and version mismatches), also indicating the parts newly implemented from scratch rather than free from perl.vim.
spamassassin.vim 1.11 2009-11-03 5.7 Adam Katz Fixed syntax clearing bug found in 7.0 (but not 6.x or 7.1+)
spamassassin.vim 1.10 2009-10-29 5.7 Adam Katz fix bug introduced in 1.9 (header regexps using just // weren't colored)
spamassassin.vim 1.9 2009-10-29 5.7 Adam Katz Updates include fixed alt regexp handling, support for :name and the like, if-unset, SA pseudo-headers, better handling of exists and eval.
spamassassin.vim 1.8 2009-07-01 5.7 Adam Katz Faster regexs using \%(query\) notation (equiv to perl's (?:query) notation) and other extremely minor tweaks like 'exists' no longer accepting functions.  I haven't touched this since 5/4/9, as reflected in internal release date, but I (wrongly) figured I'd tweak it more before another release.  It's pretty much done now, so I don't expect more releases.  There are two remaining TODO items:  one for reorganization (code cleanup) which is mostly unnecessary, and one assuming there is more perl highlighting to disable/tweak (though I haven't seen any evidence recently).  One more TODO is the recognition of regexs using alternate bounding characters like apostrophe instead of slash.
spamassassin.vim 1.7 2009-05-01 5.7 Adam Katz Oops, there were some things unique to vim6+ and 7+ in there (removed perl syntax groups).  I've cleaned that up.  This has been tested with vim7.1, vim7.0, vim6.0, and vim6.0 with the perl.vim syntax from vim5.5.
spamassassin.vim 1.6 2009-05-01 5.7 Adam Katz Fixed remaining known bugs.  Template Tags are now contained in the header-modifying portions only.  Functions are now colored properly, with known common ones showing a different color (but do we care?).  Arguments to functions are better handled.  Parentheses are now colored.  Operators in meta lines are now colored.  URIBL types are recognized.
spamassassin.vim 1.5 2009-04-28 5.7 Adam Katz Added the missing two plugins, better clearing of unwanted perl bits, fixed path and IP address recognizing, better handling of spelling on overflowed describe lines, and support for 3rd-party plugins URICountry (thanks Stefan Luetje) and SAGrey.
spamassassin.vim 1.2 2009-04-23 5.7 Adam Katz Initial upload
ip used for rating: 3.135.216.174

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github