From 405df92c21d2550d6859ef8f869f9f1c7b424e0c Mon Sep 17 00:00:00 2001 From: Mike Williamson Date: Thu, 24 May 2012 20:35:40 -0400 Subject: [PATCH] Set filetype based on node shebang Recognizes the node shebang line and sets the filetype to javascript. Syntax highlights the shebang as well. --- ftdetect/javascript.vim | 6 ++++++ syntax/javascript.vim | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 ftdetect/javascript.vim diff --git a/ftdetect/javascript.vim b/ftdetect/javascript.vim new file mode 100644 index 0000000..be611e6 --- /dev/null +++ b/ftdetect/javascript.vim @@ -0,0 +1,6 @@ +function! s:DetectJS() + if getline(1) =~# '^#!.*/bin/env\s\+node\>' + setfiletype javascript + endif +endfunction +autocmd BufNewFile,BufRead * call s:DetectJS() diff --git a/syntax/javascript.vim b/syntax/javascript.vim index b5e345d..a2c14d5 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -28,6 +28,10 @@ setlocal iskeyword+=$ syntax sync fromstart +"" syntax coloring for Node.js shebang line +syn match shebang "^#!.*/bin/env\s\+node\>" +hi link shebang Comment + "" JavaScript comments"{{{ syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained syn match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo