Browse Source

utils/misc: added vim syntax and auto-detect scripts

Daniel-Constantin Mierla 15 years ago
commit
d3c5b5e87b
3 changed files with 89 additions and 0 deletions
  1. 14 0
      README
  2. 21 0
      ftdetect/ser.vim
  3. 54 0
      syntax/ser.vim

+ 14 - 0
README

@@ -0,0 +1,14 @@
+Vim scripts to auto-detect SER and Kamailio configuration files and
+enable syntax highlighting for them.
+
+Install:
+
+- copy ftdetect/ser.vim to ~/.vim/ftdetect/ser.vim
+- copy syntax/ser.vim to ~/.vim/syntax/ser.vim
+
+Usage:
+
+- autodetection is based on .cfg extension and match of #!SER,
+#!KAMAILIO (and other variants), modparam or route keywords in
+first 400 lines of file. You can enable syntax highlighting for files
+not auto-detected with vim command: "setf ser".

+ 21 - 0
ftdetect/ser.vim

@@ -0,0 +1,21 @@
+" Copy this file to $HOME/.vim/ftdetect/ser.vim
+
+func! s:cfgType() 
+   let max = line("$") > 400 ? 400 : line("$") 
+   for n in range(1, max) 
+      if getline(n) =~ '^\s*#!\(KAMAILIO\|OPENSER\|SER\|ALL\|MAXCOMPAT\)' 
+         set filetype=ser 
+         return 
+	 elseif getline(n) =~ '^\s*modparam\s*(\s*"[^"]\+"' 
+         set filetype=ser 
+         return 
+      elseif getline(n) =~ '^\s*route\s*{\s*' 
+         set filetype=ser 
+         return 
+      endif 
+   endfor 
+   setf cfg 
+endfunc
+
+au BufNewFile,BufRead *.cfg   call s:cfgType() 
+

File diff suppressed because it is too large
+ 54 - 0
syntax/ser.vim


Some files were not shown because too many files changed in this diff