This is discussed at :h :source_crnl
.
On UNIX systems, which includes Mac OS X, there is no automatic CRLF detection, and an actual CR at the end of a line will may raise an error, e.g. in a mapping. From the help:
On other systems, Vim expects ":source"ed files to end in a <NL>. These always work. If you are using a file with <CR><NL> <EOL>s (for example, a file made on MS-DOS), all lines will have a trailing <CR>.
For best compatibility, it is best to have Vim script files always use NL newlines. These will always work everywhere, provided that the first line of the script doesn't for some reason end in a CR and 'fileformats'
is not empty (it isn't empty by default).
In short, consider converting your line endings to LF.