syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.7k stars 4.9k forks source link

CoffeeScript Syntax-Highlighting does not work #2106

Closed hoffi closed 9 years ago

hoffi commented 9 years ago

The Syntax-Highlighting for CoffeeScript does not work for .coffee files.

When i rename my CoffeeScript file to .js it does work however.

ryanlntn commented 9 years ago

I'm seeing the same issue. Mode doesn't change unless the file extension is .js. Not even .js.coffee works.

bmag commented 9 years ago

What is the value of auto-mode-alist? (type SPC h d v auto-mode-alist) If you add this line to your dotspacemacs/config, does it work?

(add-to-list 'auto-mode-alist '("\\.coffee\\'" . coffee-mode))
ryanlntn commented 9 years ago

Adding that to dotspacemacs/config gives me File mode specification error: (void-function coffee-mode)

The value of auto-mode-alist is:

Value: (("\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'" nil epa-file)
 ("\\.\\(?:3fr\\|arw\\|bmp\\|cr[2w]\\|d\\(?:cr\\|ng\\)\\|exr\\|gif\\|ico\\|jp\\(?:2\\|eg\\)\\|mrw\\|nef\\|orf\\|p\\(?:ef\\|ict\\|ng\\|sd\\)\\|raf\\|s\\(?:gi\\|r[2f]\\)\\|t\\(?:ga\\|iff\\)\\)\\'" . image-mode)
 ("\\.elc\\'" . emacs-lisp-byte-code-mode)
 ("\\.dz\\'" nil jka-compr)
 ("\\.xz\\'" nil jka-compr)
 ("\\.lzma\\'" nil jka-compr)
 ("\\.lz\\'" nil jka-compr)
 ("\\.g?z\\'" nil jka-compr)
 ("\\.bz2\\'" nil jka-compr)
 ("\\.Z\\'" nil jka-compr)
 ("\\.vr[hi]?\\'" . vera-mode)
 ("\\(?:\\.rb\\|ru\\|rake\\|thor\\|jbuilder\\|gemspec\\|podspec\\|/\\(?:Gem\\|Rake\\|Cap\\|Thor\\|Vagrant\\|Guard\\|Pod\\)file\\)\\'" . ruby-mode)
 ("\\.re?st\\'" . rst-mode)
 ("\\.py\\'" . python-mode)
 ("\\.awk\\'" . awk-mode)
 ("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode)
 ("\\.idl\\'" . idl-mode)
 ("\\.java\\'" . java-mode)
 ("\\.m\\'" . objc-mode)
 ("\\.ii\\'" . c++-mode)
 ("\\.i\\'" . c-mode)
 ("\\.lex\\'" . c-mode)
 ("\\.y\\(acc\\)?\\'" . c-mode)
 ("\\.[ch]\\'" . c-mode)
 ("\\.\\(CC?\\|HH?\\)\\'" . c++-mode)
 ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode)
 ("\\.\\(cc\\|hh\\)\\'" . c++-mode)
 ("\\.\\(bat\\|cmd\\)\\'" . bat-mode)
 ("\\.[sx]?html?\\(\\.[a-zA-Z_]+\\)?\\'" . html-mode)
 ("\\.svgz?\\'" . image-mode)
 ("\\.svgz?\\'" . xml-mode)
 ("\\.x[bp]m\\'" . image-mode)
 ("\\.x[bp]m\\'" . c-mode)
 ("\\.p[bpgn]m\\'" . image-mode)
 ("\\.tiff?\\'" . image-mode)
 ("\\.gif\\'" . image-mode)
 ("\\.png\\'" . image-mode)
 ("\\.jpe?g\\'" . image-mode)
 ("\\.te?xt\\'" . text-mode)
 ("\\.[tT]e[xX]\\'" . tex-mode)
 ("\\.ins\\'" . tex-mode)
 ("\\.ltx\\'" . latex-mode)
 ("\\.dtx\\'" . doctex-mode)
 ("\\.org\\'" . org-mode)
 ("\\.el\\'" . emacs-lisp-mode)
 ("Project\\.ede\\'" . emacs-lisp-mode)
 ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
 ("\\.l\\'" . lisp-mode)
 ("\\.li?sp\\'" . lisp-mode)
 ("\\.[fF]\\'" . fortran-mode)
 ("\\.for\\'" . fortran-mode)
 ("\\.p\\'" . pascal-mode)
 ("\\.pas\\'" . pascal-mode)
 ("\\.\\(dpr\\|DPR\\)\\'" . delphi-mode)
 ("\\.ad[abs]\\'" . ada-mode)
 ("\\.ad[bs].dg\\'" . ada-mode)
 ("\\.\\([pP]\\([Llm]\\|erl\\|od\\)\\|al\\)\\'" . perl-mode)
 ("Imakefile\\'" . makefile-imake-mode)
 ("Makeppfile\\(?:\\.mk\\)?\\'" . makefile-makepp-mode)
 ("\\.makepp\\'" . makefile-makepp-mode)
 ("\\.mk\\'" . makefile-bsdmake-mode)
 ("\\.make\\'" . makefile-bsdmake-mode)
 ("GNUmakefile\\'" . makefile-gmake-mode)
 ("[Mm]akefile\\'" . makefile-bsdmake-mode)
 ("\\.am\\'" . makefile-automake-mode)
 ("\\.texinfo\\'" . texinfo-mode)
 ("\\.te?xi\\'" . texinfo-mode)
 ("\\.[sS]\\'" . asm-mode)
 ("\\.asm\\'" . asm-mode)
 ("\\.css\\'" . css-mode)
 ("\\.mixal\\'" . mixal-mode)
 ("\\.gcov\\'" . compilation-mode)
 ("/\\.[a-z0-9-]*gdbinit" . gdb-script-mode)
 ("-gdb\\.gdb" . gdb-script-mode)
 ("[cC]hange\\.?[lL]og?\\'" . change-log-mode)
 ("[cC]hange[lL]og[-.][0-9]+\\'" . change-log-mode)
 ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
 ("\\.scm\\.[0-9]*\\'" . scheme-mode)
 ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
 ("\\.bash\\'" . sh-mode)
 ("\\(/\\|\\`\\)\\.\\(bash_\\(profile\\|history\\|log\\(in\\|out\\)\\)\\|z?log\\(in\\|out\\)\\)\\'" . sh-mode)
 ("\\(/\\|\\`\\)\\.\\(shrc\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode)
 ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode)
 ("\\.m?spec\\'" . sh-mode)
 ("\\.m[mes]\\'" . nroff-mode)
 ("\\.man\\'" . nroff-mode)
 ("\\.sty\\'" . latex-mode)
 ("\\.cl[so]\\'" . latex-mode)
 ("\\.bbl\\'" . latex-mode)
 ("\\.bib\\'" . bibtex-mode)
 ("\\.bst\\'" . bibtex-style-mode)
 ("\\.sql\\'" . sql-mode)
 ("\\.m[4c]\\'" . m4-mode)
 ("\\.mf\\'" . metafont-mode)
 ("\\.mp\\'" . metapost-mode)
 ("\\.vhdl?\\'" . vhdl-mode)
 ("\\.article\\'" . text-mode)
 ("\\.letter\\'" . text-mode)
 ("\\.i?tcl\\'" . tcl-mode)
 ("\\.exp\\'" . tcl-mode)
 ("\\.itk\\'" . tcl-mode)
 ("\\.icn\\'" . icon-mode)
 ("\\.sim\\'" . simula-mode)
 ("\\.mss\\'" . scribe-mode)
 ("\\.f9[05]\\'" . f90-mode)
 ("\\.f0[38]\\'" . f90-mode)
 ("\\.indent\\.pro\\'" . fundamental-mode)
 ("\\.\\(pro\\|PRO\\)\\'" . idlwave-mode)
 ("\\.srt\\'" . srecode-template-mode)
 ("\\.prolog\\'" . prolog-mode)
 ("\\.tar\\'" . tar-mode)
 ("\\.\\(arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'" . archive-mode)
 ("\\.oxt\\'" . archive-mode)
 ("\\.\\(deb\\|[oi]pk\\)\\'" . archive-mode)
 ("\\`/tmp/Re" . text-mode)
 ("/Message[0-9]*\\'" . text-mode)
 ("\\`/tmp/fol/" . text-mode)
 ("\\.oak\\'" . scheme-mode)
 ("\\.sgml?\\'" . sgml-mode)
 ("\\.x[ms]l\\'" . xml-mode)
 ("\\.dbk\\'" . xml-mode)
 ("\\.dtd\\'" . sgml-mode)
 ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
 ("\\.js\\'" . javascript-mode)
 ("\\.json\\'" . javascript-mode)
 ("\\.[ds]?vh?\\'" . verilog-mode)
 ("\\.by\\'" . bovine-grammar-mode)
 ("\\.wy\\'" . wisent-grammar-mode)
 ("[]>:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode)
 ("\\`\\..*emacs\\'" . emacs-lisp-mode)
 ("[:/]_emacs\\'" . emacs-lisp-mode)
 ("/crontab\\.X*[0-9]+\\'" . shell-script-mode)
 ("\\.ml\\'" . lisp-mode)
 ("\\.ld[si]?\\'" . ld-script-mode)
 ("ld\\.?script\\'" . ld-script-mode)
 ("\\.xs\\'" . c-mode)
 ("\\.x[abdsru]?[cnw]?\\'" . ld-script-mode)
 ("\\.zone\\'" . dns-mode)
 ("\\.soa\\'" . dns-mode)
 ("\\.asd\\'" . lisp-mode)
 ("\\.\\(asn\\|mib\\|smi\\)\\'" . snmp-mode)
 ("\\.\\(as\\|mi\\|sm\\)2\\'" . snmpv2-mode)
 ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode)
 ("\\.\\(dif\\|pat\\)\\'" . diff-mode)
 ("\\.[eE]?[pP][sS]\\'" . ps-mode)
 ("\\.\\(?:PDF\\|DVI\\|OD[FGPST]\\|DOCX?\\|XLSX?\\|PPTX?\\|pdf\\|djvu\\|dvi\\|od[fgpst]\\|docx?\\|xlsx?\\|pptx?\\)\\'" . doc-view-mode-maybe)
 ("configure\\.\\(ac\\|in\\)\\'" . autoconf-mode)
 ("\\.s\\(v\\|iv\\|ieve\\)\\'" . sieve-mode)
 ("BROWSE\\'" . ebrowse-tree-mode)
 ("\\.ebrowse\\'" . ebrowse-tree-mode)
 ("#\\*mail\\*" . mail-mode)
 ("\\.g\\'" . antlr-mode)
 ("\\.mod\\'" . m2-mode)
 ("\\.ses\\'" . ses-mode)
 ("\\.docbook\\'" . sgml-mode)
 ("\\.com\\'" . dcl-mode)
 ("/config\\.\\(?:bat\\|log\\)\\'" . fundamental-mode)
 ("\\.\\(?:[iI][nN][iI]\\|[lL][sS][tT]\\|[rR][eE][gG]\\|[sS][yY][sS]\\)\\'" . conf-mode)
 ("\\.\\(?:desktop\\|la\\)\\'" . conf-unix-mode)
 ("\\.ppd\\'" . conf-ppd-mode)
 ("java.+\\.conf\\'" . conf-javaprop-mode)
 ("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-javaprop-mode)
 ("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\(?:\\.d/.+\\)?\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
 ("\\`/etc/\\(?:acpid?/.+\\|aliases\\(?:\\.d/.+\\)?\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\|sysconfig/.+\\)\\'" . conf-mode)
 ("[cC]hange[lL]og[-.][-0-9a-z]+\\'" . change-log-mode)
 ("/\\.?\\(?:gnokiirc\\|kde.*rc\\|mime\\.types\\|wgetrc\\)\\'" . conf-mode)
 ("/\\.\\(?:enigma\\|gltron\\|gtk\\|hxplayer\\|net\\|neverball\\|qt/.+\\|realplayer\\|scummvm\\|sversion\\|sylpheed/.+\\|xmp\\)rc\\'" . conf-mode)
 ("/\\.\\(?:gdbtkinit\\|grip\\|orbital/.+txt\\|rhosts\\|tuxracer/options\\)\\'" . conf-mode)
 ("/\\.?X\\(?:default\\|resource\\|re\\)s\\>" . conf-xdefaults-mode)
 ("/X11.+app-defaults/" . conf-xdefaults-mode)
 ("/X11.+locale/.+/Compose\\'" . conf-colon-mode)
 ("/X11.+locale/compose\\.dir\\'" . conf-javaprop-mode)
 ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t)
 ("\\.\\(?:orig\\|in\\|[bB][aA][kK]\\)\\'" nil t)
 ("[/.]c\\(?:on\\)?f\\(?:i?g\\)?\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-mode-maybe)
 ("\\.[1-9]\\'" . nroff-mode)
 ("\\.tgz\\'" . tar-mode)
 ("\\.tbz2?\\'" . tar-mode)
 ("\\.txz\\'" . tar-mode))
bmag commented 9 years ago

I am assuming you got the mode specification error when you tried to open a coffee file.

Good news: emacs tried to open your coffee file in coffee-mode. Bad news: coffee-mode was not loaded yet. To load coffee-mode, add this line before changing auto-mode-alist:

(require 'coffee-mode)

In theory, coffee-mode should be auto-loaded when it's needed so you shouldn't be getting this error at all. There could be a few reasons for coffee-mode not being loaded:

Out of curiosity, what happens if you try to open a 2nd coffee file (after you already received the error once)?

ryanlntn commented 9 years ago

If you enabled the javascript layer, it should install coffee-mode for you.

Thanks for this. I'm still very new to Spacemacs (and Emacs for that matter) and didn't realize I had enable the configuration layer. Adding this line to ~/.spacemacs resolves the issue:

(setq-default dotspacemacs-configuration-layers '(javascript))

bmag commented 9 years ago

Great. By the way, I hope you didn't literally put that line in your config. There should already be a dotspacemacs-configuration-layers variable in your .spacemacs, you should just add javascript to it. You can search github for examples (searching "spacemacs config" gives me some results).